summaryrefslogtreecommitdiff
path: root/internal/processing
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-09-26 11:56:01 +0200
committerLibravatar GitHub <noreply@github.com>2022-09-26 11:56:01 +0200
commitc4a08292ee44bc731ff90bad18a3f37e5ee8ef22 (patch)
tree1726f8450ec37f744204a857c3be2bfab17f206c /internal/processing
parent[bugfix] more nil checks baybeeeeeeeeeeeeeeeeeeee (#854) (diff)
downloadgotosocial-c4a08292ee44bc731ff90bad18a3f37e5ee8ef22.tar.xz
[feature] Show + federate emojis in accounts (#837)
* Start adding account emoji * get emojis serialized + deserialized nicely * update tests * set / retrieve emojis on accounts * show account emojis in web view * fetch emojis from db based on ids * fix typo in test * lint * fix pg migration * update tests * update emoji checking logic * update comment * clarify comments + add some spacing * tidy up loops a lil (thanks kim)
Diffstat (limited to 'internal/processing')
-rw-r--r--internal/processing/account/delete.go2
-rw-r--r--internal/processing/account/update.go28
-rw-r--r--internal/processing/fromfederator.go10
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)
}