[bugfix] don't trash emoji in profile fields on edit (#1440)
This commit is contained in:
parent
ac2bdbbc62
commit
ad6ab037e4
|
@ -53,12 +53,15 @@ func (p *processor) Update(ctx context.Context, account *gtsmodel.Account, form
|
||||||
return nil, gtserror.NewErrorBadRequest(err)
|
return nil, gtserror.NewErrorBadRequest(err)
|
||||||
}
|
}
|
||||||
account.DisplayName = text.SanitizePlaintext(*form.DisplayName)
|
account.DisplayName = text.SanitizePlaintext(*form.DisplayName)
|
||||||
|
}
|
||||||
|
|
||||||
formatResult := p.formatter.FromPlainEmojiOnly(ctx, p.parseMention, account.ID, "", account.DisplayName)
|
// Re-parse for emojis regardless of whether the DisplayName changed
|
||||||
for _, emoji := range formatResult.Emojis {
|
// because we can't otherwise tell which emojis belong to DisplayName
|
||||||
account.Emojis = append(account.Emojis, emoji)
|
// and which belong to Note
|
||||||
account.EmojiIDs = append(account.EmojiIDs, emoji.ID)
|
formatResult := p.formatter.FromPlainEmojiOnly(ctx, p.parseMention, account.ID, "", account.DisplayName)
|
||||||
}
|
for _, emoji := range formatResult.Emojis {
|
||||||
|
account.Emojis = append(account.Emojis, emoji)
|
||||||
|
account.EmojiIDs = append(account.EmojiIDs, emoji.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
if form.Note != nil {
|
if form.Note != nil {
|
||||||
|
@ -68,22 +71,23 @@ func (p *processor) Update(ctx context.Context, account *gtsmodel.Account, form
|
||||||
|
|
||||||
// Set the raw note before processing
|
// Set the raw note before processing
|
||||||
account.NoteRaw = *form.Note
|
account.NoteRaw = *form.Note
|
||||||
|
}
|
||||||
|
|
||||||
// Process note to generate a valid HTML representation
|
// As per DisplayName, we need to reparse regardless to keep emojis straight
|
||||||
var f text.FormatFunc
|
// Process note to generate a valid HTML representation
|
||||||
if account.StatusFormat == "markdown" {
|
var f text.FormatFunc
|
||||||
f = p.formatter.FromMarkdown
|
if account.StatusFormat == "markdown" {
|
||||||
} else {
|
f = p.formatter.FromMarkdown
|
||||||
f = p.formatter.FromPlain
|
} else {
|
||||||
}
|
f = p.formatter.FromPlain
|
||||||
formatted := f(ctx, p.parseMention, account.ID, "", *form.Note)
|
}
|
||||||
|
formatted := f(ctx, p.parseMention, account.ID, "", account.NoteRaw)
|
||||||
|
|
||||||
// Set updated HTML-ified note
|
// Set updated HTML-ified note
|
||||||
account.Note = formatted.HTML
|
account.Note = formatted.HTML
|
||||||
for _, emoji := range formatted.Emojis {
|
for _, emoji := range formatted.Emojis {
|
||||||
account.Emojis = append(account.Emojis, emoji)
|
account.Emojis = append(account.Emojis, emoji)
|
||||||
account.EmojiIDs = append(account.EmojiIDs, emoji.ID)
|
account.EmojiIDs = append(account.EmojiIDs, emoji.ID)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if form.Avatar != nil && form.Avatar.Size != 0 {
|
if form.Avatar != nil && form.Avatar.Size != 0 {
|
||||||
|
|
Loading…
Reference in New Issue