mirror of
1
Fork 0

fix emojis not showing in spoiler text (#878)

This commit is contained in:
tobi 2022-10-02 14:01:47 +02:00 committed by GitHub
parent 651303d970
commit 196e474e43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 1 deletions

View File

@ -139,6 +139,41 @@ func (suite *StatusCreateTestSuite) TestProcessStatusMarkdownWithUnderscoreEmoji
suite.NotEmpty(apiStatus.Emojis) suite.NotEmpty(apiStatus.Emojis)
} }
func (suite *StatusCreateTestSuite) TestProcessStatusMarkdownWithSpoilerTextEmoji() {
ctx := context.Background()
creatingAccount := suite.testAccounts["local_account_1"]
creatingApplication := suite.testApplications["application_1"]
statusCreateForm := &model.AdvancedStatusCreateForm{
StatusCreateRequest: model.StatusCreateRequest{
Status: "poopoo peepee",
SpoilerText: "testing something :rainbow:",
MediaIDs: []string{},
Poll: nil,
InReplyToID: "",
Sensitive: false,
Visibility: model.VisibilityPublic,
ScheduledAt: "",
Language: "en",
Format: model.StatusFormatMarkdown,
},
AdvancedVisibilityFlagsForm: model.AdvancedVisibilityFlagsForm{
Federated: nil,
Boostable: nil,
Replyable: nil,
Likeable: nil,
},
}
apiStatus, err := suite.status.Create(ctx, creatingAccount, creatingApplication, statusCreateForm)
suite.NoError(err)
suite.NotNil(apiStatus)
suite.Equal("<p>poopoo peepee</p>", apiStatus.Content)
suite.Equal("testing something :rainbow:", apiStatus.SpoilerText)
suite.NotEmpty(apiStatus.Emojis)
}
func TestStatusCreateTestSuite(t *testing.T) { func TestStatusCreateTestSuite(t *testing.T) {
suite.Run(t, new(StatusCreateTestSuite)) suite.Run(t, new(StatusCreateTestSuite))
} }

View File

@ -250,7 +250,7 @@ func (p *processor) ProcessTags(ctx context.Context, form *apimodel.AdvancedStat
func (p *processor) ProcessEmojis(ctx context.Context, form *apimodel.AdvancedStatusCreateForm, accountID string, status *gtsmodel.Status) error { func (p *processor) ProcessEmojis(ctx context.Context, form *apimodel.AdvancedStatusCreateForm, accountID string, status *gtsmodel.Status) error {
// for each emoji shortcode in the text, check if it's an enabled // for each emoji shortcode in the text, check if it's an enabled
// emoji on this instance, and if so, add it to the status // emoji on this instance, and if so, add it to the status
emojiShortcodes := util.DeriveEmojisFromText(form.Status) emojiShortcodes := util.DeriveEmojisFromText(form.SpoilerText + "\n\n" + form.Status)
status.Emojis = make([]*gtsmodel.Emoji, 0, len(emojiShortcodes)) status.Emojis = make([]*gtsmodel.Emoji, 0, len(emojiShortcodes))
status.EmojiIDs = make([]string, 0, len(emojiShortcodes)) status.EmojiIDs = make([]string, 0, len(emojiShortcodes))