diff options
Diffstat (limited to 'internal/processing')
-rw-r--r-- | internal/processing/account/delete.go | 2 | ||||
-rw-r--r-- | internal/processing/account/update.go | 28 | ||||
-rw-r--r-- | internal/processing/fromfederator.go | 10 |
3 files changed, 37 insertions, 3 deletions
diff --git a/internal/processing/account/delete.go b/internal/processing/account/delete.go index bf7f60d67..3a5a9c622 100644 --- a/internal/processing/account/delete.go +++ b/internal/processing/account/delete.go @@ -259,6 +259,8 @@ selectStatusesLoop: account.HeaderMediaAttachmentID = "" account.HeaderRemoteURL = "" account.Reason = "" + account.Emojis = []*gtsmodel.Emoji{} + account.EmojiIDs = []string{} account.Fields = []gtsmodel.Field{} hideCollections := true account.HideCollections = &hideCollections diff --git a/internal/processing/account/update.go b/internal/processing/account/update.go index 47c4a2b4b..eddaeab27 100644 --- a/internal/processing/account/update.go +++ b/internal/processing/account/update.go @@ -27,6 +27,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/ap" apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" "github.com/superseriousbusiness/gotosocial/internal/config" + "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/gtserror" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/log" @@ -46,11 +47,14 @@ func (p *processor) Update(ctx context.Context, account *gtsmodel.Account, form account.Bot = form.Bot } + var updateEmojis bool + if form.DisplayName != nil { if err := validate.DisplayName(*form.DisplayName); err != nil { return nil, gtserror.NewErrorBadRequest(err) } account.DisplayName = text.SanitizePlaintext(*form.DisplayName) + updateEmojis = true } if form.Note != nil { @@ -69,6 +73,30 @@ func (p *processor) Update(ctx context.Context, account *gtsmodel.Account, form // Set updated HTML-ified note account.Note = note + updateEmojis = true + } + + if updateEmojis { + // account emojis -- treat the sanitized display name and raw + // note like one long text for the purposes of deriving emojis + accountEmojiShortcodes := util.DeriveEmojisFromText(account.DisplayName + "\n\n" + account.NoteRaw) + account.Emojis = make([]*gtsmodel.Emoji, 0, len(accountEmojiShortcodes)) + account.EmojiIDs = make([]string, 0, len(accountEmojiShortcodes)) + + for _, shortcode := range accountEmojiShortcodes { + emoji, err := p.db.GetEmojiByShortcodeDomain(ctx, shortcode, "") + if err != nil { + if err != db.ErrNoEntries { + log.Errorf("error getting local emoji with shortcode %s: %s", shortcode, err) + } + continue + } + + if *emoji.VisibleInPicker && !*emoji.Disabled { + account.Emojis = append(account.Emojis, emoji) + account.EmojiIDs = append(account.EmojiIDs, emoji.ID) + } + } } if form.Avatar != nil && form.Avatar.Size != 0 { diff --git a/internal/processing/fromfederator.go b/internal/processing/fromfederator.go index ad8273869..29d996502 100644 --- a/internal/processing/fromfederator.go +++ b/internal/processing/fromfederator.go @@ -369,10 +369,14 @@ func (p *processor) processUpdateAccountFromFederator(ctx context.Context, feder return err } + // further database updates occur inside getremoteaccount if _, err := p.federator.GetRemoteAccount(ctx, dereferencing.GetRemoteAccountParams{ - RequestingUsername: federatorMsg.ReceivingAccount.Username, - RemoteAccountID: incomingAccountURL, - Blocking: true, + RequestingUsername: federatorMsg.ReceivingAccount.Username, + RemoteAccountID: incomingAccountURL, + RemoteAccountHost: incomingAccount.Domain, + RemoteAccountUsername: incomingAccount.Username, + PartialAccount: incomingAccount, + Blocking: true, }); err != nil { return fmt.Errorf("error enriching updated account from federator: %s", err) } |