commit 196e474e43b20465d1099bb6e949be05b54ffa26
parent 651303d97002a38c32f929a327e77d66fb439e99
Author: tobi <31960611+tsmethurst@users.noreply.github.com>
Date: Sun, 2 Oct 2022 14:01:47 +0200
fix emojis not showing in spoiler text (#878)
Diffstat:
2 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/internal/processing/status/create_test.go b/internal/processing/status/create_test.go
@@ -139,6 +139,41 @@ func (suite *StatusCreateTestSuite) TestProcessStatusMarkdownWithUnderscoreEmoji
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) {
suite.Run(t, new(StatusCreateTestSuite))
}
diff --git a/internal/processing/status/util.go b/internal/processing/status/util.go
@@ -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 {
// 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
- emojiShortcodes := util.DeriveEmojisFromText(form.Status)
+ emojiShortcodes := util.DeriveEmojisFromText(form.SpoilerText + "\n\n" + form.Status)
status.Emojis = make([]*gtsmodel.Emoji, 0, len(emojiShortcodes))
status.EmojiIDs = make([]string, 0, len(emojiShortcodes))