mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-01-11 00:50:13 +00:00
[bugfix] If status URL is empty, use URI instead and don't log unnecessary error (#597)
* test parse status with no URL * if no status URL is available, use the URI instead
This commit is contained in:
parent
469da93678
commit
a09e101931
|
@ -184,10 +184,11 @@ func (c *converter) ASStatusToStatus(ctx context.Context, statusable ap.Statusab
|
||||||
l := logrus.WithField("statusURI", status.URI)
|
l := logrus.WithField("statusURI", status.URI)
|
||||||
|
|
||||||
// web url for viewing this status
|
// web url for viewing this status
|
||||||
if statusURL, err := ap.ExtractURL(statusable); err != nil {
|
if statusURL, err := ap.ExtractURL(statusable); err == nil {
|
||||||
l.Infof("ASStatusToStatus: error extracting status URL: %s", err)
|
|
||||||
} else {
|
|
||||||
status.URL = statusURL.String()
|
status.URL = statusURL.String()
|
||||||
|
} else {
|
||||||
|
// if no URL was set, just take the URI
|
||||||
|
status.URL = status.URI
|
||||||
}
|
}
|
||||||
|
|
||||||
// the html-formatted content of this status
|
// the html-formatted content of this status
|
||||||
|
|
|
@ -74,6 +74,27 @@ func (suite *ASToInternalTestSuite) TestParsePublicStatus() {
|
||||||
suite.Equal(`<p>> So we have to examine critical thinking as a signifier, dynamic and ambiguous. It has a normative definition, a tacit definition, and an ideal definition. One of the hallmarks of graduate training is learning to comprehend those definitions and applying the correct one as needed for professional success.</p>`, status.Content)
|
suite.Equal(`<p>> So we have to examine critical thinking as a signifier, dynamic and ambiguous. It has a normative definition, a tacit definition, and an ideal definition. One of the hallmarks of graduate training is learning to comprehend those definitions and applying the correct one as needed for professional success.</p>`, status.Content)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (suite *ASToInternalTestSuite) TestParsePublicStatusNoURL() {
|
||||||
|
m := make(map[string]interface{})
|
||||||
|
err := json.Unmarshal([]byte(publicStatusActivityJsonNoURL), &m)
|
||||||
|
suite.NoError(err)
|
||||||
|
|
||||||
|
t, err := streams.ToType(context.Background(), m)
|
||||||
|
suite.NoError(err)
|
||||||
|
|
||||||
|
rep, ok := t.(ap.Statusable)
|
||||||
|
suite.True(ok)
|
||||||
|
|
||||||
|
status, err := suite.typeconverter.ASStatusToStatus(context.Background(), rep)
|
||||||
|
suite.NoError(err)
|
||||||
|
|
||||||
|
suite.Equal("reading: Punishment and Reward in the Corporate University", status.ContentWarning)
|
||||||
|
suite.Equal(`<p>> So we have to examine critical thinking as a signifier, dynamic and ambiguous. It has a normative definition, a tacit definition, and an ideal definition. One of the hallmarks of graduate training is learning to comprehend those definitions and applying the correct one as needed for professional success.</p>`, status.Content)
|
||||||
|
|
||||||
|
// on statuses with no URL in them (like ones we get from pleroma sometimes) we should use the AP URI of the status as URL
|
||||||
|
suite.Equal("http://fossbros-anonymous.io/users/foss_satan/statuses/108138763199405167", status.URL)
|
||||||
|
}
|
||||||
|
|
||||||
func (suite *ASToInternalTestSuite) TestParseGargron() {
|
func (suite *ASToInternalTestSuite) TestParseGargron() {
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
err := json.Unmarshal([]byte(gargronAsActivityJson), &m)
|
err := json.Unmarshal([]byte(gargronAsActivityJson), &m)
|
||||||
|
|
|
@ -367,6 +367,53 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
publicStatusActivityJsonNoURL = `
|
||||||
|
{
|
||||||
|
"@context": [
|
||||||
|
"https://www.w3.org/ns/activitystreams",
|
||||||
|
{
|
||||||
|
"ostatus": "http://ostatus.org#",
|
||||||
|
"atomUri": "ostatus:atomUri",
|
||||||
|
"inReplyToAtomUri": "ostatus:inReplyToAtomUri",
|
||||||
|
"conversation": "ostatus:conversation",
|
||||||
|
"sensitive": "as:sensitive",
|
||||||
|
"toot": "http://joinmastodon.org/ns#",
|
||||||
|
"votersCount": "toot:votersCount"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"id": "http://fossbros-anonymous.io/users/foss_satan/statuses/108138763199405167",
|
||||||
|
"type": "Note",
|
||||||
|
"summary": "reading: Punishment and Reward in the Corporate University",
|
||||||
|
"inReplyTo": "http://fossbros-anonymous.io/users/foss_satan/statuses/108138729399508469",
|
||||||
|
"published": "2022-04-15T23:49:37Z",
|
||||||
|
"attributedTo": "http://fossbros-anonymous.io/users/foss_satan",
|
||||||
|
"to": [
|
||||||
|
"https://www.w3.org/ns/activitystreams#Public"
|
||||||
|
],
|
||||||
|
"cc": [
|
||||||
|
"http://fossbros-anonymous.io/users/foss_satan/followers"
|
||||||
|
],
|
||||||
|
"sensitive": true,
|
||||||
|
"atomUri": "http://fossbros-anonymous.io/users/foss_satan/statuses/108138763199405167",
|
||||||
|
"inReplyToAtomUri": "http://fossbros-anonymous.io/users/foss_satan/statuses/108138729399508469",
|
||||||
|
"content": "<p>> So we have to examine critical thinking as a signifier, dynamic and ambiguous. It has a normative definition, a tacit definition, and an ideal definition. One of the hallmarks of graduate training is learning to comprehend those definitions and applying the correct one as needed for professional success.</p>",
|
||||||
|
"contentMap": {
|
||||||
|
"en": "<p>> So we have to examine critical thinking as a signifier, dynamic and ambiguous. It has a normative definition, a tacit definition, and an ideal definition. One of the hallmarks of graduate training is learning to comprehend those definitions and applying the correct one as needed for professional success.</p>"
|
||||||
|
},
|
||||||
|
"attachment": [],
|
||||||
|
"tag": [],
|
||||||
|
"replies": {
|
||||||
|
"id": "http://fossbros-anonymous.io/users/foss_satan/statuses/108138763199405167/replies",
|
||||||
|
"type": "Collection",
|
||||||
|
"first": {
|
||||||
|
"type": "CollectionPage",
|
||||||
|
"next": "http://fossbros-anonymous.io/users/foss_satan/statuses/108138763199405167/replies?only_other_accounts=true&page=true",
|
||||||
|
"partOf": "http://fossbros-anonymous.io/users/foss_satan/statuses/108138763199405167/replies",
|
||||||
|
"items": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
)
|
)
|
||||||
|
|
||||||
type TypeUtilsTestSuite struct {
|
type TypeUtilsTestSuite struct {
|
||||||
|
|
Loading…
Reference in a new issue