mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-12-22 18:22:11 +00:00
[bugfix] Fix invalid og:description on account w/ empty note (#1733)
This commit is contained in:
parent
c41c1f90a6
commit
a6ec2a5bc2
|
@ -91,7 +91,7 @@ func (og *ogMeta) withAccount(account *apimodel.Account) *ogMeta {
|
|||
if account.Note != "" {
|
||||
og.Description = parseDescription(account.Note)
|
||||
} else {
|
||||
og.Description = "This GoToSocial user hasn't written a bio yet!"
|
||||
og.Description = `content="This GoToSocial user hasn't written a bio yet!"`
|
||||
}
|
||||
|
||||
og.Image = account.Avatar
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
|
||||
)
|
||||
|
||||
type OpenGraphTestSuite struct {
|
||||
|
@ -44,6 +45,72 @@ func (suite *OpenGraphTestSuite) TestParseDescription() {
|
|||
}
|
||||
}
|
||||
|
||||
func (suite *OpenGraphTestSuite) TestWithAccountWithNote() {
|
||||
baseMeta := ogBase(&apimodel.InstanceV1{
|
||||
AccountDomain: "example.org",
|
||||
Languages: []string{"en"},
|
||||
})
|
||||
|
||||
accountMeta := baseMeta.withAccount(&apimodel.Account{
|
||||
Acct: "example_account",
|
||||
DisplayName: "example person!!",
|
||||
URL: "https://example.org/@example_account",
|
||||
Note: "<p>This is my profile, read it and weep! Weep then!</p>",
|
||||
Username: "example_account",
|
||||
})
|
||||
|
||||
suite.EqualValues(ogMeta{
|
||||
Title: "example person!! (@example_account@example.org)",
|
||||
Type: "profile",
|
||||
Locale: "en",
|
||||
URL: "https://example.org/@example_account",
|
||||
SiteName: "example.org",
|
||||
Description: "content=\"This is my profile, read it and weep! Weep then!\"",
|
||||
Image: "",
|
||||
ImageWidth: "",
|
||||
ImageHeight: "",
|
||||
ImageAlt: "Avatar for example_account",
|
||||
ArticlePublisher: "",
|
||||
ArticleAuthor: "",
|
||||
ArticleModifiedTime: "",
|
||||
ArticlePublishedTime: "",
|
||||
ProfileUsername: "example_account",
|
||||
}, *accountMeta)
|
||||
}
|
||||
|
||||
func (suite *OpenGraphTestSuite) TestWithAccountNoNote() {
|
||||
baseMeta := ogBase(&apimodel.InstanceV1{
|
||||
AccountDomain: "example.org",
|
||||
Languages: []string{"en"},
|
||||
})
|
||||
|
||||
accountMeta := baseMeta.withAccount(&apimodel.Account{
|
||||
Acct: "example_account",
|
||||
DisplayName: "example person!!",
|
||||
URL: "https://example.org/@example_account",
|
||||
Note: "", // <- empty
|
||||
Username: "example_account",
|
||||
})
|
||||
|
||||
suite.EqualValues(ogMeta{
|
||||
Title: "example person!! (@example_account@example.org)",
|
||||
Type: "profile",
|
||||
Locale: "en",
|
||||
URL: "https://example.org/@example_account",
|
||||
SiteName: "example.org",
|
||||
Description: "content=\"This GoToSocial user hasn't written a bio yet!\"",
|
||||
Image: "",
|
||||
ImageWidth: "",
|
||||
ImageHeight: "",
|
||||
ImageAlt: "Avatar for example_account",
|
||||
ArticlePublisher: "",
|
||||
ArticleAuthor: "",
|
||||
ArticleModifiedTime: "",
|
||||
ArticlePublishedTime: "",
|
||||
ProfileUsername: "example_account",
|
||||
}, *accountMeta)
|
||||
}
|
||||
|
||||
func TestOpenGraphTestSuite(t *testing.T) {
|
||||
suite.Run(t, &OpenGraphTestSuite{})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue