diff options
| author | 2023-07-31 15:47:35 +0200 | |
|---|---|---|
| committer | 2023-07-31 15:47:35 +0200 | |
| commit | 2796a2e82f16ade9872008878cf88299bd66b4e7 (patch) | |
| tree | 76f7b69cc1da57ca10b71c57abf1892575bea100 /internal/db/bundb/bundb.go | |
| parent | [performance] cache follow, follow request and block ID lists (#2027) (diff) | |
| download | gotosocial-2796a2e82f16ade9872008878cf88299bd66b4e7.tar.xz | |
[feature] Hashtag federation (in/out), hashtag client API endpoints (#2032)
* update go-fed
* do the things
* remove unused columns from tags
* update to latest lingo from main
* further tag shenanigans
* serve stub page at tag endpoint
* we did it lads
* tests, oh tests, ohhh tests, oh tests (doo doo doo doo)
* swagger docs
* document hashtag usage + federation
* instanceGet
* don't bother parsing tag href
* rename whereStartsWith -> whereStartsLike
* remove GetOrCreateTag
* dont cache status tag timelineability
Diffstat (limited to 'internal/db/bundb/bundb.go')
| -rw-r--r-- | internal/db/bundb/bundb.go | 48 |
1 files changed, 5 insertions, 43 deletions
diff --git a/internal/db/bundb/bundb.go b/internal/db/bundb/bundb.go index 6a6ff2224..8387bb8d1 100644 --- a/internal/db/bundb/bundb.go +++ b/internal/db/bundb/bundb.go @@ -39,7 +39,6 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/db/bundb/migrations" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" - "github.com/superseriousbusiness/gotosocial/internal/id" "github.com/superseriousbusiness/gotosocial/internal/log" "github.com/superseriousbusiness/gotosocial/internal/state" "github.com/superseriousbusiness/gotosocial/internal/tracing" @@ -77,6 +76,7 @@ type DBService struct { db.Status db.StatusBookmark db.StatusFave + db.Tag db.Timeline db.User db.Tombstone @@ -230,6 +230,10 @@ func NewBunDBService(ctx context.Context, state *state.State) (db.DB, error) { db: db, state: state, }, + Tag: &tagDB{ + conn: db, + state: state, + }, Timeline: &timelineDB{ db: db, state: state, @@ -494,45 +498,3 @@ func sqlitePragmas(ctx context.Context, db *WrappedDB) error { return nil } - -/* - CONVERSION FUNCTIONS -*/ - -func (dbService *DBService) TagStringToTag(ctx context.Context, t string, originAccountID string) (*gtsmodel.Tag, error) { - protocol := config.GetProtocol() - host := config.GetHost() - now := time.Now() - - tag := >smodel.Tag{} - // we can use selectorinsert here to create the new tag if it doesn't exist already - // inserted will be true if this is a new tag we just created - if err := dbService.db.NewSelect().Model(tag).Where("LOWER(?) = LOWER(?)", bun.Ident("name"), t).Scan(ctx); err != nil && err != sql.ErrNoRows { - return nil, fmt.Errorf("error getting tag with name %s: %s", t, err) - } - - if tag.ID == "" { - // tag doesn't exist yet so populate it - newID, err := id.NewRandomULID() - if err != nil { - return nil, err - } - tag.ID = newID - tag.URL = protocol + "://" + host + "/tags/" + t - tag.Name = t - tag.FirstSeenFromAccountID = originAccountID - tag.CreatedAt = now - tag.UpdatedAt = now - useable := true - tag.Useable = &useable - listable := true - tag.Listable = &listable - } - - // bail already if the tag isn't useable - if !*tag.Useable { - return nil, fmt.Errorf("tag %s is not useable", t) - } - tag.LastStatusAt = now - return tag, nil -} |
