~netlandish/links

c0329c2cc8a49d9b0b088620b6f0b1bb96426dc5 — Peter Sanchez 4 months ago 4f36312
Fixing HTML import hash issue
2 files changed, 9 insertions(+), 1 deletions(-)

M core/import.go
M models/org_link.go
M core/import.go => core/import.go +2 -1
@@ 12,6 12,7 @@ import (

	sq "github.com/Masterminds/squirrel"
	"github.com/labstack/echo/v4"
	"github.com/segmentio/ksuid"
	"golang.org/x/net/html"
	"netlandish.com/x/gobwebs/database"
	"netlandish.com/x/gobwebs/server"


@@ 146,7 147,7 @@ func (h *htmlObj) SetHash(_ string) {
}

func (h htmlObj) GetHash() string {
	return ""
	return ksuid.New().String()
}

func (h htmlObj) IsUnread() bool {

M models/org_link.go => models/org_link.go +7 -0
@@ 10,6 10,7 @@ import (
	"time"

	sq "github.com/Masterminds/squirrel"
	"github.com/segmentio/ksuid"
	"netlandish.com/x/gobwebs/database"
	"netlandish.com/x/gobwebs/timezone"
)


@@ 130,6 131,9 @@ func (o *OrgLink) Store(ctx context.Context) error {
	err := database.WithTx(ctx, nil, func(tx *sql.Tx) error {
		var err error
		if o.ID == 0 {
			if o.Hash == "" {
				o.Hash = ksuid.New().String()
			}
			err = sq.
				Insert("org_links").
				Columns("title", "url", "description", "base_url_id", "org_id", "user_id", "visibility",


@@ 264,6 268,9 @@ func OrgLinkStoreBatch(ctx context.Context, links []*OrgLink) error {
				"hash", "type", "unread")

		for _, link := range links {
			if link.Hash == "" {
				link.Hash = ksuid.New().String()
			}
			batch = batch.Values(link.Title, link.URL, link.Description, link.BaseURLID, link.OrgID,
				link.UserID, link.Visibility, link.Hash, link.Type, link.Unread)
		}