diff options
| author | 2022-09-06 12:42:55 +0200 | |
|---|---|---|
| committer | 2022-09-06 12:42:55 +0200 | |
| commit | a872ddebe67c7b76cbb78667224b393a847834ac (patch) | |
| tree | 28b7d0081ee12ab9928eff0aecd6b55d32d8228d /internal/db/bundb/bundb.go | |
| parent | [bugfix] Catch json syntax errors in the frontend + display a more helpful me... (diff) | |
| download | gotosocial-a872ddebe67c7b76cbb78667224b393a847834ac.tar.xz | |
[feature] Custom emoji updates (serve emoji via s2s api, tune db models) (#805)
* migrate emojis
* add get emoji to s2s (federation) API
* add new emoji db + cache functions
* add shortcodeDomain lookup for emojis
* check existing emojis w/cache, not w/constraints
* go fmt
* add putEmoji func
* use new db emoji funcs instead of where
* remove emojistringstotags func
* add unique constraint back in
* fix up broken migration
* update index
Diffstat (limited to 'internal/db/bundb/bundb.go')
| -rw-r--r-- | internal/db/bundb/bundb.go | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/internal/db/bundb/bundb.go b/internal/db/bundb/bundb.go index 6bf3571b4..b944ae3ea 100644 --- a/internal/db/bundb/bundb.go +++ b/internal/db/bundb/bundb.go @@ -154,6 +154,7 @@ func NewBunDBService(ctx context.Context) (db.DB, error) { // Create DB structs that require ptrs to each other accounts := &accountDB{conn: conn, cache: cache.NewAccountCache()} status := &statusDB{conn: conn, cache: cache.NewStatusCache()} + emoji := &emojiDB{conn: conn, cache: cache.NewEmojiCache()} timeline := &timelineDB{conn: conn} // Setup DB cross-referencing @@ -188,9 +189,7 @@ func NewBunDBService(ctx context.Context) (db.DB, error) { conn: conn, cache: blockCache, }, - Emoji: &emojiDB{ - conn: conn, - }, + Emoji: emoji, Instance: &instanceDB{ conn: conn, }, @@ -440,22 +439,3 @@ func (ps *bunDBService) TagStringsToTags(ctx context.Context, tags []string, ori } return newTags, nil } - -func (ps *bunDBService) EmojiStringsToEmojis(ctx context.Context, emojis []string) ([]*gtsmodel.Emoji, error) { - newEmojis := []*gtsmodel.Emoji{} - for _, e := range emojis { - emoji := >smodel.Emoji{} - err := ps.conn.NewSelect().Model(emoji).Where("shortcode = ?", e).Where("visible_in_picker = true").Where("disabled = false").Scan(ctx) - if err != nil { - if err == sql.ErrNoRows { - // no result found for this username/domain so just don't include it as an emoji and carry on about our business - log.Debugf("no emoji found with shortcode %s, skipping it", e) - continue - } - // a serious error has happened so bail - return nil, fmt.Errorf("error getting emoji with shortcode %s: %s", e, err) - } - newEmojis = append(newEmojis, emoji) - } - return newEmojis, nil -} |
