[chore] Text formatting overhaul (#1406)

* Implement goldmark debug print for hashtags and mentions

* Minify HTML in FromPlain

* Convert plaintext status parser to goldmark

* Move mention/tag/emoji finding logic into formatter

* Combine mention and hashtag boundary characters

* Normalize unicode when rendering hashtags
This commit is contained in:
Autumn!
2023-02-03 10:58:58 +00:00
committed by GitHub
parent 271da016b9
commit 49beb17a8f
26 changed files with 826 additions and 1314 deletions

View File

@@ -27,14 +27,12 @@ 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"
"github.com/superseriousbusiness/gotosocial/internal/media"
"github.com/superseriousbusiness/gotosocial/internal/messages"
"github.com/superseriousbusiness/gotosocial/internal/text"
"github.com/superseriousbusiness/gotosocial/internal/util"
"github.com/superseriousbusiness/gotosocial/internal/validate"
)
@@ -47,14 +45,20 @@ func (p *processor) Update(ctx context.Context, account *gtsmodel.Account, form
account.Bot = form.Bot
}
var updateEmojis bool
account.Emojis = []*gtsmodel.Emoji{}
account.EmojiIDs = []string{}
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
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 {
@@ -66,36 +70,19 @@ func (p *processor) Update(ctx context.Context, account *gtsmodel.Account, form
account.NoteRaw = *form.Note
// Process note to generate a valid HTML representation
note, err := p.processNote(ctx, *form.Note, account)
if err != nil {
return nil, gtserror.NewErrorBadRequest(err)
var f text.FormatFunc
if account.StatusFormat == "markdown" {
f = p.formatter.FromMarkdown
} else {
f = p.formatter.FromPlain
}
formatted := f(ctx, p.parseMention, account.ID, "", *form.Note)
// 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)
}
account.Note = formatted.HTML
for _, emoji := range formatted.Emojis {
account.Emojis = append(account.Emojis, emoji)
account.EmojiIDs = append(account.EmojiIDs, emoji.ID)
}
}
@@ -240,35 +227,3 @@ func (p *processor) UpdateHeader(ctx context.Context, header *multipart.FileHead
return processingMedia.LoadAttachment(ctx)
}
func (p *processor) processNote(ctx context.Context, note string, account *gtsmodel.Account) (string, error) {
if note == "" {
return "", nil
}
tagStrings := util.DeriveHashtagsFromText(note)
tags, err := p.db.TagStringsToTags(ctx, tagStrings, account.ID)
if err != nil {
return "", err
}
mentionStrings := util.DeriveMentionNamesFromText(note)
mentions := []*gtsmodel.Mention{}
for _, mentionString := range mentionStrings {
mention, err := p.parseMention(ctx, mentionString, account.ID, "")
if err != nil {
continue
}
mentions = append(mentions, mention)
}
// TODO: support emojis in account notes
// emojiStrings := util.DeriveEmojisFromText(note)
// emojis, err := p.db.EmojiStringsToEmojis(ctx, emojiStrings)
if account.StatusFormat == "markdown" {
return p.formatter.FromMarkdown(ctx, note, mentions, tags, nil), nil
}
return p.formatter.FromPlain(ctx, note, mentions, tags), nil
}

View File

@@ -76,8 +76,8 @@ func (suite *AccountUpdateTestSuite) TestAccountUpdateWithMention() {
var (
locked = true
displayName = "new display name"
note = "#hello here i am!\n\ngo check out @1happyturtle, they have a cool account!\n"
noteExpected = "<p><a href=\"http://localhost:8080/tags/hello\" class=\"mention hashtag\" rel=\"tag nofollow noreferrer noopener\" target=\"_blank\">#<span>hello</span></a> here i am!<br/><br/>go check out <span class=\"h-card\"><a href=\"http://localhost:8080/@1happyturtle\" class=\"u-url mention\" rel=\"nofollow noreferrer noopener\" target=\"_blank\">@<span>1happyturtle</span></a></span>, they have a cool account!</p>"
note = "#hello here i am!\n\ngo check out @1happyturtle, they have a cool account!"
noteExpected = "<p><a href=\"http://localhost:8080/tags/hello\" class=\"mention hashtag\" rel=\"tag nofollow noreferrer noopener\" target=\"_blank\">#<span>hello</span></a> here i am!<br><br>go check out <span class=\"h-card\"><a href=\"http://localhost:8080/@1happyturtle\" class=\"u-url mention\" rel=\"nofollow noreferrer noopener\" target=\"_blank\">@<span>1happyturtle</span></a></span>, they have a cool account!</p>"
)
form := &apimodel.UpdateCredentialsRequest{

View File

@@ -76,18 +76,6 @@ func (p *processor) Create(ctx context.Context, account *gtsmodel.Account, appli
return nil, gtserror.NewErrorInternalError(err)
}
if err := p.ProcessMentions(ctx, form, account.ID, newStatus); err != nil {
return nil, gtserror.NewErrorInternalError(err)
}
if err := p.ProcessTags(ctx, form, account.ID, newStatus); err != nil {
return nil, gtserror.NewErrorInternalError(err)
}
if err := p.ProcessEmojis(ctx, form, account.ID, newStatus); err != nil {
return nil, gtserror.NewErrorInternalError(err)
}
if err := p.ProcessContent(ctx, form, account.ID, newStatus); err != nil {
return nil, gtserror.NewErrorInternalError(err)
}

View File

@@ -67,9 +67,6 @@ type Processor interface {
ProcessReplyToID(ctx context.Context, form *apimodel.AdvancedStatusCreateForm, thisAccountID string, status *gtsmodel.Status) gtserror.WithCode
ProcessMediaIDs(ctx context.Context, form *apimodel.AdvancedStatusCreateForm, thisAccountID string, status *gtsmodel.Status) gtserror.WithCode
ProcessLanguage(ctx context.Context, form *apimodel.AdvancedStatusCreateForm, accountDefaultLanguage string, status *gtsmodel.Status) error
ProcessMentions(ctx context.Context, form *apimodel.AdvancedStatusCreateForm, accountID string, status *gtsmodel.Status) error
ProcessTags(ctx context.Context, form *apimodel.AdvancedStatusCreateForm, accountID string, status *gtsmodel.Status) error
ProcessEmojis(ctx context.Context, form *apimodel.AdvancedStatusCreateForm, accountID string, status *gtsmodel.Status) error
ProcessContent(ctx context.Context, form *apimodel.AdvancedStatusCreateForm, accountID string, status *gtsmodel.Status) error
}

View File

@@ -28,8 +28,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/log"
"github.com/superseriousbusiness/gotosocial/internal/util"
"github.com/superseriousbusiness/gotosocial/internal/text"
)
func (p *processor) ProcessVisibility(ctx context.Context, form *apimodel.AdvancedStatusCreateForm, accountDefaultVis gtsmodel.Visibility, status *gtsmodel.Status) error {
@@ -212,80 +211,6 @@ func (p *processor) ProcessLanguage(ctx context.Context, form *apimodel.Advanced
return nil
}
func (p *processor) ProcessMentions(ctx context.Context, form *apimodel.AdvancedStatusCreateForm, accountID string, status *gtsmodel.Status) error {
mentionedAccountNames := util.DeriveMentionNamesFromText(form.Status)
mentions := []*gtsmodel.Mention{}
mentionIDs := []string{}
for _, mentionedAccountName := range mentionedAccountNames {
gtsMention, err := p.parseMention(ctx, mentionedAccountName, accountID, status.ID)
if err != nil {
log.Errorf("ProcessMentions: error parsing mention %s from status: %s", mentionedAccountName, err)
continue
}
if err := p.db.Put(ctx, gtsMention); err != nil {
log.Errorf("ProcessMentions: error putting mention in db: %s", err)
}
mentions = append(mentions, gtsMention)
mentionIDs = append(mentionIDs, gtsMention.ID)
}
// add full populated gts menchies to the status for passing them around conveniently
status.Mentions = mentions
// add just the ids of the mentioned accounts to the status for putting in the db
status.MentionIDs = mentionIDs
return nil
}
func (p *processor) ProcessTags(ctx context.Context, form *apimodel.AdvancedStatusCreateForm, accountID string, status *gtsmodel.Status) error {
tags := []string{}
gtsTags, err := p.db.TagStringsToTags(ctx, util.DeriveHashtagsFromText(form.Status), accountID)
if err != nil {
return fmt.Errorf("error generating hashtags from status: %s", err)
}
for _, tag := range gtsTags {
if err := p.db.Put(ctx, tag); err != nil {
if !errors.Is(err, db.ErrAlreadyExists) {
return fmt.Errorf("error putting tags in db: %s", err)
}
}
tags = append(tags, tag.ID)
}
// add full populated gts tags to the status for passing them around conveniently
status.Tags = gtsTags
// add just the ids of the used tags to the status for putting in the db
status.TagIDs = tags
return nil
}
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.SpoilerText + "\n\n" + form.Status)
status.Emojis = make([]*gtsmodel.Emoji, 0, len(emojiShortcodes))
status.EmojiIDs = make([]string, 0, len(emojiShortcodes))
for _, shortcode := range emojiShortcodes {
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 {
status.Emojis = append(status.Emojis, emoji)
status.EmojiIDs = append(status.EmojiIDs, emoji.ID)
}
}
return nil
}
func (p *processor) ProcessContent(ctx context.Context, form *apimodel.AdvancedStatusCreateForm, accountID string, status *gtsmodel.Status) error {
// if there's nothing in the status at all we can just return early
if form.Status == "" {
@@ -311,16 +236,43 @@ func (p *processor) ProcessContent(ctx context.Context, form *apimodel.AdvancedS
}
// parse content out of the status depending on what format has been submitted
var formatted string
var f text.FormatFunc
switch form.Format {
case apimodel.StatusFormatPlain:
formatted = p.formatter.FromPlain(ctx, form.Status, status.Mentions, status.Tags)
f = p.formatter.FromPlain
case apimodel.StatusFormatMarkdown:
formatted = p.formatter.FromMarkdown(ctx, form.Status, status.Mentions, status.Tags, status.Emojis)
f = p.formatter.FromMarkdown
default:
return fmt.Errorf("format %s not recognised as a valid status format", form.Format)
}
formatted := f(ctx, p.parseMention, accountID, status.ID, form.Status)
status.Content = formatted
// add full populated gts {mentions, tags, emojis} to the status for passing them around conveniently
// add just their ids to the status for putting in the db
status.Mentions = formatted.Mentions
status.MentionIDs = make([]string, 0, len(formatted.Mentions))
for _, gtsmention := range formatted.Mentions {
status.MentionIDs = append(status.MentionIDs, gtsmention.ID)
}
status.Tags = formatted.Tags
status.TagIDs = make([]string, 0, len(formatted.Tags))
for _, gtstag := range formatted.Tags {
status.TagIDs = append(status.TagIDs, gtstag.ID)
}
status.Emojis = formatted.Emojis
status.EmojiIDs = make([]string, 0, len(formatted.Emojis))
for _, gtsemoji := range formatted.Emojis {
status.EmojiIDs = append(status.EmojiIDs, gtsemoji.ID)
}
spoilerformatted := p.formatter.FromPlainEmojiOnly(ctx, p.parseMention, accountID, status.ID, form.SpoilerText)
for _, gtsemoji := range spoilerformatted.Emojis {
status.Emojis = append(status.Emojis, gtsemoji)
status.EmojiIDs = append(status.EmojiIDs, gtsemoji.ID)
}
status.Content = formatted.HTML
return nil
}

View File

@@ -29,22 +29,23 @@ import (
)
const (
statusText1 = "Another test @foss_satan@fossbros-anonymous.io\n\n#Hashtag\n\nText"
statusText1ExpectedFull = "<p>Another test <span class=\"h-card\"><a href=\"http://fossbros-anonymous.io/@foss_satan\" class=\"u-url mention\" rel=\"nofollow noreferrer noopener\" target=\"_blank\">@<span>foss_satan</span></a></span><br/><br/><a href=\"http://localhost:8080/tags/Hashtag\" class=\"mention hashtag\" rel=\"tag nofollow noreferrer noopener\" target=\"_blank\">#<span>Hashtag</span></a><br/><br/>Text</p>"
statusText1ExpectedPartial = "<p>Another test <span class=\"h-card\"><a href=\"http://fossbros-anonymous.io/@foss_satan\" class=\"u-url mention\" rel=\"nofollow noreferrer noopener\" target=\"_blank\">@<span>foss_satan</span></a></span><br/><br/>#Hashtag<br/><br/>Text</p>"
statusText2 = "Another test @foss_satan@fossbros-anonymous.io\n\n#Hashtag\n\n#hashTAG"
status2TextExpectedFull = "<p>Another test <span class=\"h-card\"><a href=\"http://fossbros-anonymous.io/@foss_satan\" class=\"u-url mention\" rel=\"nofollow noreferrer noopener\" target=\"_blank\">@<span>foss_satan</span></a></span><br/><br/><a href=\"http://localhost:8080/tags/Hashtag\" class=\"mention hashtag\" rel=\"tag nofollow noreferrer noopener\" target=\"_blank\">#<span>Hashtag</span></a><br/><br/><a href=\"http://localhost:8080/tags/Hashtag\" class=\"mention hashtag\" rel=\"tag nofollow noreferrer noopener\" target=\"_blank\">#<span>hashTAG</span></a></p>"
status2TextExpectedPartial = "<p>Another test <span class=\"h-card\"><a href=\"http://fossbros-anonymous.io/@foss_satan\" class=\"u-url mention\" rel=\"nofollow noreferrer noopener\" target=\"_blank\">@<span>foss_satan</span></a></span><br/><br/>#Hashtag<br/><br/>#hashTAG</p>"
statusText1 = "Another test @foss_satan@fossbros-anonymous.io\n\n#Hashtag\n\nText"
statusText1Expected = "<p>Another test <span class=\"h-card\"><a href=\"http://fossbros-anonymous.io/@foss_satan\" class=\"u-url mention\" rel=\"nofollow noreferrer noopener\" target=\"_blank\">@<span>foss_satan</span></a></span><br><br><a href=\"http://localhost:8080/tags/Hashtag\" class=\"mention hashtag\" rel=\"tag nofollow noreferrer noopener\" target=\"_blank\">#<span>Hashtag</span></a><br><br>Text</p>"
statusText2 = "Another test @foss_satan@fossbros-anonymous.io\n\n#Hashtag\n\n#hashTAG"
status2TextExpected = "<p>Another test <span class=\"h-card\"><a href=\"http://fossbros-anonymous.io/@foss_satan\" class=\"u-url mention\" rel=\"nofollow noreferrer noopener\" target=\"_blank\">@<span>foss_satan</span></a></span><br><br><a href=\"http://localhost:8080/tags/Hashtag\" class=\"mention hashtag\" rel=\"tag nofollow noreferrer noopener\" target=\"_blank\">#<span>Hashtag</span></a><br><br><a href=\"http://localhost:8080/tags/Hashtag\" class=\"mention hashtag\" rel=\"tag nofollow noreferrer noopener\" target=\"_blank\">#<span>hashTAG</span></a></p>"
)
type UtilTestSuite struct {
StatusStandardTestSuite
}
func (suite *UtilTestSuite) TestProcessMentions1() {
func (suite *UtilTestSuite) TestProcessContent1() {
/*
TEST PREPARATION
*/
// we need to partially process the status first since processContent expects a status with some stuff already set on it
creatingAccount := suite.testAccounts["local_account_1"]
mentionedAccount := suite.testAccounts["remote_account_1"]
form := &apimodel.AdvancedStatusCreateForm{
StatusCreateRequest: apimodel.StatusCreateRequest{
Status: statusText1,
@@ -70,8 +71,13 @@ func (suite *UtilTestSuite) TestProcessMentions1() {
ID: "01FCTDD78JJMX3K9KPXQ7ZQ8BJ",
}
err := suite.status.ProcessMentions(context.Background(), form, creatingAccount.ID, status)
/*
ACTUAL TEST
*/
err := suite.status.ProcessContent(context.Background(), form, creatingAccount.ID, status)
suite.NoError(err)
suite.Equal(statusText1Expected, status.Content)
suite.Len(status.Mentions, 1)
newMention := status.Mentions[0]
@@ -88,102 +94,13 @@ func (suite *UtilTestSuite) TestProcessMentions1() {
suite.Equal(newMention.ID, status.MentionIDs[0])
}
func (suite *UtilTestSuite) TestProcessContentFull1() {
func (suite *UtilTestSuite) TestProcessContent2() {
/*
TEST PREPARATION
*/
// we need to partially process the status first since processContent expects a status with some stuff already set on it
creatingAccount := suite.testAccounts["local_account_1"]
form := &apimodel.AdvancedStatusCreateForm{
StatusCreateRequest: apimodel.StatusCreateRequest{
Status: statusText1,
MediaIDs: []string{},
Poll: nil,
InReplyToID: "",
Sensitive: false,
SpoilerText: "",
Visibility: apimodel.VisibilityPublic,
ScheduledAt: "",
Language: "en",
Format: apimodel.StatusFormatPlain,
},
AdvancedVisibilityFlagsForm: apimodel.AdvancedVisibilityFlagsForm{
Federated: nil,
Boostable: nil,
Replyable: nil,
Likeable: nil,
},
}
status := &gtsmodel.Status{
ID: "01FCTDD78JJMX3K9KPXQ7ZQ8BJ",
}
err := suite.status.ProcessMentions(context.Background(), form, creatingAccount.ID, status)
suite.NoError(err)
suite.Empty(status.Content) // shouldn't be set yet
err = suite.status.ProcessTags(context.Background(), form, creatingAccount.ID, status)
suite.NoError(err)
suite.Empty(status.Content) // shouldn't be set yet
/*
ACTUAL TEST
*/
err = suite.status.ProcessContent(context.Background(), form, creatingAccount.ID, status)
suite.NoError(err)
suite.Equal(statusText1ExpectedFull, status.Content)
}
func (suite *UtilTestSuite) TestProcessContentPartial1() {
/*
TEST PREPARATION
*/
// we need to partially process the status first since processContent expects a status with some stuff already set on it
creatingAccount := suite.testAccounts["local_account_1"]
form := &apimodel.AdvancedStatusCreateForm{
StatusCreateRequest: apimodel.StatusCreateRequest{
Status: statusText1,
MediaIDs: []string{},
Poll: nil,
InReplyToID: "",
Sensitive: false,
SpoilerText: "",
Visibility: apimodel.VisibilityPublic,
ScheduledAt: "",
Language: "en",
Format: apimodel.StatusFormatPlain,
},
AdvancedVisibilityFlagsForm: apimodel.AdvancedVisibilityFlagsForm{
Federated: nil,
Boostable: nil,
Replyable: nil,
Likeable: nil,
},
}
status := &gtsmodel.Status{
ID: "01FCTDD78JJMX3K9KPXQ7ZQ8BJ",
}
err := suite.status.ProcessMentions(context.Background(), form, creatingAccount.ID, status)
suite.NoError(err)
suite.Empty(status.Content) // shouldn't be set yet
/*
ACTUAL TEST
*/
err = suite.status.ProcessContent(context.Background(), form, creatingAccount.ID, status)
suite.NoError(err)
suite.Equal(statusText1ExpectedPartial, status.Content)
}
func (suite *UtilTestSuite) TestProcessMentions2() {
creatingAccount := suite.testAccounts["local_account_1"]
mentionedAccount := suite.testAccounts["remote_account_1"]
form := &apimodel.AdvancedStatusCreateForm{
StatusCreateRequest: apimodel.StatusCreateRequest{
Status: statusText2,
@@ -209,9 +126,15 @@ func (suite *UtilTestSuite) TestProcessMentions2() {
ID: "01FCTDD78JJMX3K9KPXQ7ZQ8BJ",
}
err := suite.status.ProcessMentions(context.Background(), form, creatingAccount.ID, status)
/*
ACTUAL TEST
*/
err := suite.status.ProcessContent(context.Background(), form, creatingAccount.ID, status)
suite.NoError(err)
suite.Equal(status2TextExpected, status.Content)
suite.Len(status.Mentions, 1)
newMention := status.Mentions[0]
suite.Equal(mentionedAccount.ID, newMention.TargetAccountID)
@@ -227,96 +150,6 @@ func (suite *UtilTestSuite) TestProcessMentions2() {
suite.Equal(newMention.ID, status.MentionIDs[0])
}
func (suite *UtilTestSuite) TestProcessContentFull2() {
/*
TEST PREPARATION
*/
// we need to partially process the status first since processContent expects a status with some stuff already set on it
creatingAccount := suite.testAccounts["local_account_1"]
form := &apimodel.AdvancedStatusCreateForm{
StatusCreateRequest: apimodel.StatusCreateRequest{
Status: statusText2,
MediaIDs: []string{},
Poll: nil,
InReplyToID: "",
Sensitive: false,
SpoilerText: "",
Visibility: apimodel.VisibilityPublic,
ScheduledAt: "",
Language: "en",
Format: apimodel.StatusFormatPlain,
},
AdvancedVisibilityFlagsForm: apimodel.AdvancedVisibilityFlagsForm{
Federated: nil,
Boostable: nil,
Replyable: nil,
Likeable: nil,
},
}
status := &gtsmodel.Status{
ID: "01FCTDD78JJMX3K9KPXQ7ZQ8BJ",
}
err := suite.status.ProcessMentions(context.Background(), form, creatingAccount.ID, status)
suite.NoError(err)
suite.Empty(status.Content) // shouldn't be set yet
err = suite.status.ProcessTags(context.Background(), form, creatingAccount.ID, status)
suite.NoError(err)
suite.Empty(status.Content) // shouldn't be set yet
/*
ACTUAL TEST
*/
err = suite.status.ProcessContent(context.Background(), form, creatingAccount.ID, status)
suite.NoError(err)
suite.Equal(status2TextExpectedFull, status.Content)
}
func (suite *UtilTestSuite) TestProcessContentPartial2() {
/*
TEST PREPARATION
*/
// we need to partially process the status first since processContent expects a status with some stuff already set on it
creatingAccount := suite.testAccounts["local_account_1"]
form := &apimodel.AdvancedStatusCreateForm{
StatusCreateRequest: apimodel.StatusCreateRequest{
Status: statusText2,
MediaIDs: []string{},
Poll: nil,
InReplyToID: "",
Sensitive: false,
SpoilerText: "",
Visibility: apimodel.VisibilityPublic,
ScheduledAt: "",
Language: "en",
Format: apimodel.StatusFormatPlain,
},
AdvancedVisibilityFlagsForm: apimodel.AdvancedVisibilityFlagsForm{
Federated: nil,
Boostable: nil,
Replyable: nil,
Likeable: nil,
},
}
status := &gtsmodel.Status{
ID: "01FCTDD78JJMX3K9KPXQ7ZQ8BJ",
}
err := suite.status.ProcessMentions(context.Background(), form, creatingAccount.ID, status)
suite.NoError(err)
suite.Empty(status.Content)
err = suite.status.ProcessContent(context.Background(), form, creatingAccount.ID, status)
suite.NoError(err)
suite.Equal(status2TextExpectedPartial, status.Content)
}
func TestUtilTestSuite(t *testing.T) {
suite.Run(t, new(UtilTestSuite))
}