mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-12-22 10:12:11 +00:00
[chore] Mastodon api fixups (#617)
* don't omitempty on description * don't omitempty on any fields * add ms to timestamp format * don't omitempty on text_url * rearrange attachment fields a bit * just give URL again as attachment text url * update tests * fix accidental replace
This commit is contained in:
parent
323dbca4f7
commit
ae5402ada6
|
@ -154,7 +154,7 @@ func addressable4() vocab.ActivityStreamsAnnounce {
|
|||
"cc": "https://another.instance/users/someone_else",
|
||||
"id": "https://example.org/users/someone/statuses/107043888547829808/activity",
|
||||
"object": "https://another.instance/users/someone_else/statuses/107026674805188668",
|
||||
"published": "2021-10-04T15:08:35Z",
|
||||
"published": "2021-10-04T15:08:35.00Z",
|
||||
"to": "https://example.org/users/someone/followers",
|
||||
"type": "Announce"
|
||||
}`)
|
||||
|
|
|
@ -70,7 +70,7 @@ func (suite *GetTestSuite) TestGet() {
|
|||
b, err := ioutil.ReadAll(result.Body)
|
||||
assert.NoError(suite.T(), err)
|
||||
|
||||
suite.Equal(`[{"id":"01FHMQX3GAABWSM0S2VZEC2SWC","username":"some_user","acct":"some_user@example.org","display_name":"some user","locked":true,"bot":false,"created_at":"2020-08-10T12:13:28Z","note":"i'm a real son of a gun","url":"http://example.org/@some_user","avatar":"","avatar_static":"","header":"","header_static":"","followers_count":0,"following_count":0,"statuses_count":0,"last_status_at":"","emojis":[],"fields":[]}]`, string(b))
|
||||
suite.Equal(`[{"id":"01FHMQX3GAABWSM0S2VZEC2SWC","username":"some_user","acct":"some_user@example.org","display_name":"some user","locked":true,"bot":false,"created_at":"2020-08-10T12:13:28.00Z","note":"i'm a real son of a gun","url":"http://example.org/@some_user","avatar":"","avatar_static":"","header":"","header_static":"","followers_count":0,"following_count":0,"statuses_count":0,"last_status_at":"","emojis":[],"fields":[]}]`, string(b))
|
||||
}
|
||||
|
||||
func TestGetTestSuite(t *testing.T) {
|
||||
|
|
|
@ -62,7 +62,7 @@ func (suite *InstancePatchTestSuite) TestInstancePatch1() {
|
|||
b, err := io.ReadAll(result.Body)
|
||||
suite.NoError(err)
|
||||
|
||||
suite.Equal(`{"uri":"http://localhost:8080","title":"Example Instance","description":"","short_description":"","email":"someone@example.org","version":"","registrations":true,"approval_required":true,"invites_enabled":false,"urls":{"streaming_api":"wss://localhost:8080"},"stats":{"domain_count":0,"status_count":16,"user_count":4},"thumbnail":"","contact_account":{"id":"01F8MH17FWEB39HZJ76B6VXSKF","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2022-05-17T13:10:59Z","note":"","url":"http://localhost:8080/@admin","avatar":"","avatar_static":"","header":"","header_static":"","followers_count":1,"following_count":1,"statuses_count":4,"last_status_at":"2021-10-20T10:41:37Z","emojis":[],"fields":[]},"max_toot_chars":5000}`, string(b))
|
||||
suite.Equal(`{"uri":"http://localhost:8080","title":"Example Instance","description":"","short_description":"","email":"someone@example.org","version":"","registrations":true,"approval_required":true,"invites_enabled":false,"urls":{"streaming_api":"wss://localhost:8080"},"stats":{"domain_count":0,"status_count":16,"user_count":4},"thumbnail":"","contact_account":{"id":"01F8MH17FWEB39HZJ76B6VXSKF","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2022-05-17T13:10:59.00Z","note":"","url":"http://localhost:8080/@admin","avatar":"","avatar_static":"","header":"","header_static":"","followers_count":1,"following_count":1,"statuses_count":4,"last_status_at":"2021-10-20T10:41:37.00Z","emojis":[],"fields":[]},"max_toot_chars":5000}`, string(b))
|
||||
}
|
||||
|
||||
func (suite *InstancePatchTestSuite) TestInstancePatch2() {
|
||||
|
|
|
@ -69,25 +69,25 @@ type Attachment struct {
|
|||
// The location of the original full-size attachment.
|
||||
// example: https://example.org/fileserver/some_id/attachments/some_id/original/attachment.jpeg
|
||||
URL string `json:"url"`
|
||||
// A shorter URL for the attachment.
|
||||
// In our case, we just give the URL again since we don't create smaller URLs.
|
||||
TextURL string `json:"text_url"`
|
||||
// The location of a scaled-down preview of the attachment.
|
||||
// example: https://example.org/fileserver/some_id/attachments/some_id/small/attachment.jpeg
|
||||
PreviewURL string `json:"preview_url"`
|
||||
// The location of the full-size original attachment on the remote server.
|
||||
// Only defined for instances other than our own.
|
||||
// example: https://some-other-server.org/attachments/original/ahhhhh.jpeg
|
||||
RemoteURL string `json:"remote_url,omitempty"`
|
||||
RemoteURL string `json:"remote_url"`
|
||||
// The location of a scaled-down preview of the attachment on the remote server.
|
||||
// Only defined for instances other than our own.
|
||||
// example: https://some-other-server.org/attachments/small/ahhhhh.jpeg
|
||||
PreviewRemoteURL string `json:"preview_remote_url,omitempty"`
|
||||
// A shorter URL for the attachment.
|
||||
// Not currently used.
|
||||
TextURL string `json:"text_url,omitempty"`
|
||||
PreviewRemoteURL string `json:"preview_remote_url"`
|
||||
// Metadata for this attachment.
|
||||
Meta MediaMeta `json:"meta,omitempty"`
|
||||
// Alt text that describes what is in the media attachment.
|
||||
// example: This is a picture of a kitten.
|
||||
Description string `json:"description,omitempty"`
|
||||
Description string `json:"description"`
|
||||
// A hash computed by the BlurHash algorithm, for generating colorful preview thumbnails when media has not been downloaded yet.
|
||||
// See https://github.com/woltapp/blurhash
|
||||
Blurhash string `json:"blurhash,omitempty"`
|
||||
|
|
|
@ -30,10 +30,10 @@ type Status struct {
|
|||
CreatedAt string `json:"created_at"`
|
||||
// ID of the status being replied to.
|
||||
// example: 01FBVD42CQ3ZEEVMW180SBX03B
|
||||
InReplyToID string `json:"in_reply_to_id,omitempty"`
|
||||
InReplyToID string `json:"in_reply_to_id"`
|
||||
// ID of the account being replied to.
|
||||
// example: 01FBVD42CQ3ZEEVMW180SBX03B
|
||||
InReplyToAccountID string `json:"in_reply_to_account_id,omitempty"`
|
||||
InReplyToAccountID string `json:"in_reply_to_account_id"`
|
||||
// Status contains sensitive content.
|
||||
// example: false
|
||||
Sensitive bool `json:"sensitive"`
|
||||
|
@ -67,13 +67,13 @@ type Status struct {
|
|||
// This status has been bookmarked by the account viewing it.
|
||||
Bookmarked bool `json:"bookmarked"`
|
||||
// This status has been pinned by the account viewing it (only relevant for your own statuses).
|
||||
Pinned bool `json:"pinned,omitempty"`
|
||||
Pinned bool `json:"pinned"`
|
||||
// The content of this status. Should be HTML, but might also be plaintext in some cases.
|
||||
// example: <p>Hey this is a status!</p>
|
||||
Content string `json:"content"`
|
||||
// The status that this status reblogs/boosts.
|
||||
// nullable: true
|
||||
Reblog *StatusReblogged `json:"reblog,omitempty"`
|
||||
Reblog *StatusReblogged `json:"reblog"`
|
||||
// The application used to post this status, if visible.
|
||||
Application *Application `json:"application"`
|
||||
// The account that authored this status.
|
||||
|
|
|
@ -44,7 +44,7 @@ func (suite *NotificationTestSuite) TestStreamNotification() {
|
|||
notification := &apimodel.Notification{
|
||||
ID: "01FH57SJCMDWQGEAJ0X08CE3WV",
|
||||
Type: "follow",
|
||||
CreatedAt: "2021-10-04T08:52:36Z",
|
||||
CreatedAt: "2021-10-04T08:52:36.00Z",
|
||||
Account: followAccountAPIModel,
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ func (suite *NotificationTestSuite) TestStreamNotification() {
|
|||
suite.NoError(err)
|
||||
|
||||
msg := <-openStream.Messages
|
||||
suite.Equal(`{"id":"01FH57SJCMDWQGEAJ0X08CE3WV","type":"follow","created_at":"2021-10-04T08:52:36Z","account":{"id":"01F8MH5ZK5VRH73AKHQM6Y9VNX","username":"foss_satan","acct":"foss_satan@fossbros-anonymous.io","display_name":"big gerald","locked":false,"bot":false,"created_at":"2021-09-26T10:52:36Z","note":"i post about like, i dunno, stuff, or whatever!!!!","url":"http://fossbros-anonymous.io/@foss_satan","avatar":"","avatar_static":"","header":"","header_static":"","followers_count":0,"following_count":0,"statuses_count":1,"last_status_at":"2021-09-20T10:40:37Z","emojis":[],"fields":[]}}`, msg.Payload)
|
||||
suite.Equal(`{"id":"01FH57SJCMDWQGEAJ0X08CE3WV","type":"follow","created_at":"2021-10-04T08:52:36.00Z","account":{"id":"01F8MH5ZK5VRH73AKHQM6Y9VNX","username":"foss_satan","acct":"foss_satan@fossbros-anonymous.io","display_name":"big gerald","locked":false,"bot":false,"created_at":"2021-09-26T10:52:36.00Z","note":"i post about like, i dunno, stuff, or whatever!!!!","url":"http://fossbros-anonymous.io/@foss_satan","avatar":"","avatar_static":"","header":"","header_static":"","followers_count":0,"following_count":0,"statuses_count":1,"last_status_at":"2021-09-20T10:40:37.00Z","emojis":[],"fields":[]}}`, msg.Payload)
|
||||
}
|
||||
|
||||
func TestNotificationTestSuite(t *testing.T) {
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
"id": "http://fossbros-anonymous.io/users/foss_satan/statuses/106221634728637552/activity",
|
||||
"type": "Create",
|
||||
"actor": "http://fossbros-anonymous.io/users/foss_satan",
|
||||
"published": "2021-05-12T09:58:38Z",
|
||||
"published": "2021-05-12T09:58:38.00Z",
|
||||
"to": [
|
||||
"http://fossbros-anonymous.io/users/foss_satan/followers"
|
||||
],
|
||||
|
@ -57,7 +57,7 @@
|
|||
"type": "Note",
|
||||
"summary": null,
|
||||
"inReplyTo": "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY",
|
||||
"published": "2021-05-12T09:58:38Z",
|
||||
"published": "2021-05-12T09:58:38.00Z",
|
||||
"url": "https://ondergrond.org/@dumpsterqueer/106221634728637552",
|
||||
"attributedTo": "http://fossbros-anonymous.io/users/foss_satan",
|
||||
"to": [
|
||||
|
@ -115,7 +115,7 @@
|
|||
"id": "http://fossbros-anonymous.io/users/foss_satan/statuses/106221567884565704/activity",
|
||||
"type": "Create",
|
||||
"actor": "http://fossbros-anonymous.io/users/foss_satan",
|
||||
"published": "2021-05-12T09:41:38Z",
|
||||
"published": "2021-05-12T09:41:38.00Z",
|
||||
"to": [
|
||||
"http://fossbros-anonymous.io/users/foss_satan/followers"
|
||||
],
|
||||
|
@ -127,7 +127,7 @@
|
|||
"type": "Note",
|
||||
"summary": null,
|
||||
"inReplyTo": null,
|
||||
"published": "2021-05-12T09:41:38Z",
|
||||
"published": "2021-05-12T09:41:38.00Z",
|
||||
"url": "https://ondergrond.org/@dumpsterqueer/106221567884565704",
|
||||
"attributedTo": "http://fossbros-anonymous.io/users/foss_satan",
|
||||
"to": [
|
||||
|
@ -160,7 +160,7 @@
|
|||
"id": "https://ondergrond.org/emojis/2390",
|
||||
"type": "Emoji",
|
||||
"name": ":party_parrot:",
|
||||
"updated": "2020-11-06T13:42:11Z",
|
||||
"updated": "2020-11-06T13:42:11.00Z",
|
||||
"icon": {
|
||||
"type": "Image",
|
||||
"mediaType": "image/gif",
|
||||
|
@ -171,7 +171,7 @@
|
|||
"id": "https://ondergrond.org/emojis/2395",
|
||||
"type": "Emoji",
|
||||
"name": ":amaze:",
|
||||
"updated": "2020-09-26T12:29:56Z",
|
||||
"updated": "2020-09-26T12:29:56.00Z",
|
||||
"icon": {
|
||||
"type": "Image",
|
||||
"mediaType": "image/png",
|
||||
|
@ -182,7 +182,7 @@
|
|||
"id": "https://ondergrond.org/emojis/764",
|
||||
"type": "Emoji",
|
||||
"name": ":blobsunglasses:",
|
||||
"updated": "2020-09-26T12:13:23Z",
|
||||
"updated": "2020-09-26T12:13:23.00Z",
|
||||
"icon": {
|
||||
"type": "Image",
|
||||
"mediaType": "image/png",
|
||||
|
@ -337,7 +337,7 @@
|
|||
"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",
|
||||
"published": "2022-04-15T23:49:37.00Z",
|
||||
"url": "http://fossbros-anonymous.io/@foss_satan/108138763199405167",
|
||||
"attributedTo": "http://fossbros-anonymous.io/users/foss_satan",
|
||||
"to": [
|
||||
|
@ -385,7 +385,7 @@
|
|||
"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",
|
||||
"published": "2022-04-15T23:49:37.00Z",
|
||||
"attributedTo": "http://fossbros-anonymous.io/users/foss_satan",
|
||||
"to": [
|
||||
"https://www.w3.org/ns/activitystreams#Public"
|
||||
|
@ -447,7 +447,7 @@
|
|||
"owner": "https://owncast.example.org/federation/user/rgh",
|
||||
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAurN+lUNwcGV2poLNtaoT\naRtJzN6s4SDcBmIFk82lxhdMKC6/Nssm+hvDuxWGqL0+dHwSvrG11rA6irGuSzRk\niHjYyVwYe/p1CxqJxzUfZVJAWdsCFWy+HtDrTWs5sggj1MiL59uGxvkCep+OYBuG\nBI8CvSOMLrDp8soCg3EY+zSgpXtGMuRaaUukavsfuglApShB61ny7W8LG252iKC5\nmyO8L7l8TNa5BrIi/pRHLzvv9aWiCa8VKtvmqj+mClEhpkRhImSk5GPJXgouTTgl\ntT28NYYciSf9YYgZ0SNWHdLUCdkMF592j4+BbkPvdgzc70G4yyu2GcWnTzBuvF5X\nYwIDAQAB\n-----END PUBLIC KEY-----\n"
|
||||
},
|
||||
"published": "2022-05-22T18:44:57Z",
|
||||
"published": "2022-05-22T18:44:57.00Z",
|
||||
"summary": "linux audio stuff ",
|
||||
"tag": [
|
||||
{
|
||||
|
|
|
@ -238,6 +238,7 @@ func (c *converter) AttachmentToAPIAttachment(ctx context.Context, a *gtsmodel.M
|
|||
ID: a.ID,
|
||||
Type: strings.ToLower(string(a.Type)),
|
||||
URL: a.URL,
|
||||
TextURL: a.URL,
|
||||
PreviewURL: a.Thumbnail.URL,
|
||||
RemoteURL: a.RemoteURL,
|
||||
PreviewRemoteURL: a.Thumbnail.RemoteURL,
|
||||
|
|
|
@ -40,7 +40,7 @@ func (suite *InternalToFrontendTestSuite) TestAccountToFrontend() {
|
|||
|
||||
b, err := json.Marshal(apiAccount)
|
||||
suite.NoError(err)
|
||||
suite.Equal(`{"id":"01F8MH1H7YV1Z7D2C8K2730QBF","username":"the_mighty_zork","acct":"the_mighty_zork","display_name":"original zork (he/they)","locked":false,"bot":false,"created_at":"2022-05-20T11:09:18Z","note":"\u003cp\u003ehey yo this is my profile!\u003c/p\u003e","url":"http://localhost:8080/@the_mighty_zork","avatar":"http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/original/01F8MH58A357CV5K7R7TJMSH6S.jpeg","avatar_static":"http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/small/01F8MH58A357CV5K7R7TJMSH6S.jpeg","header":"http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/header/original/01PFPMWK2FF0D9WMHEJHR07C3Q.jpeg","header_static":"http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/header/small/01PFPMWK2FF0D9WMHEJHR07C3Q.jpeg","followers_count":2,"following_count":2,"statuses_count":5,"last_status_at":"2022-05-20T11:37:55Z","emojis":[],"fields":[]}`, string(b))
|
||||
suite.Equal(`{"id":"01F8MH1H7YV1Z7D2C8K2730QBF","username":"the_mighty_zork","acct":"the_mighty_zork","display_name":"original zork (he/they)","locked":false,"bot":false,"created_at":"2022-05-20T11:09:18.00Z","note":"\u003cp\u003ehey yo this is my profile!\u003c/p\u003e","url":"http://localhost:8080/@the_mighty_zork","avatar":"http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/original/01F8MH58A357CV5K7R7TJMSH6S.jpeg","avatar_static":"http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/small/01F8MH58A357CV5K7R7TJMSH6S.jpeg","header":"http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/header/original/01PFPMWK2FF0D9WMHEJHR07C3Q.jpeg","header_static":"http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/header/small/01PFPMWK2FF0D9WMHEJHR07C3Q.jpeg","followers_count":2,"following_count":2,"statuses_count":5,"last_status_at":"2022-05-20T11:37:55.00Z","emojis":[],"fields":[]}`, string(b))
|
||||
}
|
||||
|
||||
func (suite *InternalToFrontendTestSuite) TestStatusToFrontend() {
|
||||
|
@ -52,7 +52,7 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontend() {
|
|||
b, err := json.Marshal(apiStatus)
|
||||
suite.NoError(err)
|
||||
|
||||
suite.Equal(`{"id":"01F8MH75CBF9JFX4ZAD54N0W0R","created_at":"2021-10-20T11:36:45Z","sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost:8080/users/admin/statuses/01F8MH75CBF9JFX4ZAD54N0W0R","url":"http://localhost:8080/@admin/statuses/01F8MH75CBF9JFX4ZAD54N0W0R","replies_count":0,"reblogs_count":0,"favourites_count":1,"favourited":true,"reblogged":false,"muted":false,"bookmarked":false,"content":"hello world! #welcome ! first post on the instance :rainbow: !","application":{"name":"superseriousbusiness","website":"https://superserious.business"},"account":{"id":"01F8MH17FWEB39HZJ76B6VXSKF","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2022-05-17T13:10:59Z","note":"","url":"http://localhost:8080/@admin","avatar":"","avatar_static":"","header":"","header_static":"","followers_count":1,"following_count":1,"statuses_count":4,"last_status_at":"2021-10-20T10:41:37Z","emojis":[],"fields":[]},"media_attachments":[{"id":"01F8MH6NEM8D7527KZAECTCR76","type":"image","url":"http://localhost:8080/fileserver/01F8MH17FWEB39HZJ76B6VXSKF/attachment/original/01F8MH6NEM8D7527KZAECTCR76.jpeg","preview_url":"http://localhost:8080/fileserver/01F8MH17FWEB39HZJ76B6VXSKF/attachment/small/01F8MH6NEM8D7527KZAECTCR76.jpeg","meta":{"original":{"width":1200,"height":630,"size":"1200x630","aspect":1.9047619},"small":{"width":256,"height":134,"size":"256x134","aspect":1.9104477},"focus":{"x":0,"y":0}},"description":"Black and white image of some 50's style text saying: Welcome On Board","blurhash":"LNJRdVM{00Rj%Mayt7j[4nWBofRj"}],"mentions":[],"tags":[{"name":"welcome","url":"http://localhost:8080/tags/welcome"}],"emojis":[{"shortcode":"rainbow","url":"http://localhost:8080/fileserver/01F8MH261H1KSV3GW3016GZRY3/emoji/original/01F8MH9H8E4VG3KDYJR9EGPXCQ.png","static_url":"http://localhost:8080/fileserver/01F8MH261H1KSV3GW3016GZRY3/emoji/static/01F8MH9H8E4VG3KDYJR9EGPXCQ.png","visible_in_picker":true}],"card":null,"poll":null,"text":""}`, string(b))
|
||||
suite.Equal(`{"id":"01F8MH75CBF9JFX4ZAD54N0W0R","created_at":"2021-10-20T11:36:45.00Z","in_reply_to_id":"","in_reply_to_account_id":"","sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost:8080/users/admin/statuses/01F8MH75CBF9JFX4ZAD54N0W0R","url":"http://localhost:8080/@admin/statuses/01F8MH75CBF9JFX4ZAD54N0W0R","replies_count":0,"reblogs_count":0,"favourites_count":1,"favourited":true,"reblogged":false,"muted":false,"bookmarked":false,"pinned":false,"content":"hello world! #welcome ! first post on the instance :rainbow: !","reblog":null,"application":{"name":"superseriousbusiness","website":"https://superserious.business"},"account":{"id":"01F8MH17FWEB39HZJ76B6VXSKF","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2022-05-17T13:10:59.00Z","note":"","url":"http://localhost:8080/@admin","avatar":"","avatar_static":"","header":"","header_static":"","followers_count":1,"following_count":1,"statuses_count":4,"last_status_at":"2021-10-20T10:41:37.00Z","emojis":[],"fields":[]},"media_attachments":[{"id":"01F8MH6NEM8D7527KZAECTCR76","type":"image","url":"http://localhost:8080/fileserver/01F8MH17FWEB39HZJ76B6VXSKF/attachment/original/01F8MH6NEM8D7527KZAECTCR76.jpeg","text_url":"http://localhost:8080/fileserver/01F8MH17FWEB39HZJ76B6VXSKF/attachment/original/01F8MH6NEM8D7527KZAECTCR76.jpeg","preview_url":"http://localhost:8080/fileserver/01F8MH17FWEB39HZJ76B6VXSKF/attachment/small/01F8MH6NEM8D7527KZAECTCR76.jpeg","remote_url":"","preview_remote_url":"","meta":{"original":{"width":1200,"height":630,"size":"1200x630","aspect":1.9047619},"small":{"width":256,"height":134,"size":"256x134","aspect":1.9104477},"focus":{"x":0,"y":0}},"description":"Black and white image of some 50's style text saying: Welcome On Board","blurhash":"LNJRdVM{00Rj%Mayt7j[4nWBofRj"}],"mentions":[],"tags":[{"name":"welcome","url":"http://localhost:8080/tags/welcome"}],"emojis":[{"shortcode":"rainbow","url":"http://localhost:8080/fileserver/01F8MH261H1KSV3GW3016GZRY3/emoji/original/01F8MH9H8E4VG3KDYJR9EGPXCQ.png","static_url":"http://localhost:8080/fileserver/01F8MH261H1KSV3GW3016GZRY3/emoji/static/01F8MH9H8E4VG3KDYJR9EGPXCQ.png","visible_in_picker":true}],"card":null,"poll":null,"text":""}`, string(b))
|
||||
}
|
||||
|
||||
func (suite *InternalToFrontendTestSuite) TestInstanceToFrontend() {
|
||||
|
@ -97,7 +97,7 @@ func (suite *InternalToFrontendTestSuite) TestInstanceToFrontendWithAdminAccount
|
|||
b, err := json.Marshal(apiInstance)
|
||||
suite.NoError(err)
|
||||
|
||||
suite.Equal(`{"uri":"https://example.org","title":"example instance","description":"a much longer description","short_description":"a little description","email":"someone@example.org","version":"software-from-hell 0.666","registrations":false,"approval_required":false,"invites_enabled":false,"thumbnail":"","contact_account":{"id":"01FHMQX3GAABWSM0S2VZEC2SWC","username":"some_user","acct":"some_user@example.org","display_name":"some user","locked":true,"bot":false,"created_at":"2020-08-10T12:13:28Z","note":"i'm a real son of a gun","url":"http://example.org/@some_user","avatar":"","avatar_static":"","header":"","header_static":"","followers_count":0,"following_count":0,"statuses_count":0,"last_status_at":"","emojis":[],"fields":[]},"max_toot_chars":0}`, string(b))
|
||||
suite.Equal(`{"uri":"https://example.org","title":"example instance","description":"a much longer description","short_description":"a little description","email":"someone@example.org","version":"software-from-hell 0.666","registrations":false,"approval_required":false,"invites_enabled":false,"thumbnail":"","contact_account":{"id":"01FHMQX3GAABWSM0S2VZEC2SWC","username":"some_user","acct":"some_user@example.org","display_name":"some user","locked":true,"bot":false,"created_at":"2020-08-10T12:13:28.00Z","note":"i'm a real son of a gun","url":"http://example.org/@some_user","avatar":"","avatar_static":"","header":"","header_static":"","followers_count":0,"following_count":0,"statuses_count":0,"last_status_at":"","emojis":[],"fields":[]},"max_toot_chars":0}`, string(b))
|
||||
}
|
||||
|
||||
func TestInternalToFrontendTestSuite(t *testing.T) {
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
import "time"
|
||||
|
||||
// ISO8601 is a formatter for serializing times that forces ISO8601 behavior.
|
||||
const ISO8601 = "2006-01-02T15:04:05Z"
|
||||
const ISO8601 = "2006-01-02T15:04:05.00Z"
|
||||
|
||||
// FormatISO8601 converts the given time to UTC and then formats it
|
||||
// using the ISO8601 const, which the Mastodon API is able to understand.
|
||||
|
|
|
@ -33,19 +33,19 @@ type TimeSuite struct {
|
|||
func (suite *TimeSuite) TestISO8601Format1() {
|
||||
testTime := testrig.TimeMustParse("2022-05-17T13:10:59Z")
|
||||
testTimeString := util.FormatISO8601(testTime)
|
||||
suite.Equal("2022-05-17T13:10:59Z", testTimeString)
|
||||
suite.Equal("2022-05-17T13:10:59.00Z", testTimeString)
|
||||
}
|
||||
|
||||
func (suite *TimeSuite) TestISO8601Format2() {
|
||||
testTime := testrig.TimeMustParse("2022-05-09T07:34:35+02:00")
|
||||
testTimeString := util.FormatISO8601(testTime)
|
||||
suite.Equal("2022-05-09T05:34:35Z", testTimeString)
|
||||
suite.Equal("2022-05-09T05:34:35.00Z", testTimeString)
|
||||
}
|
||||
|
||||
func (suite *TimeSuite) TestISO8601Format3() {
|
||||
testTime := testrig.TimeMustParse("2021-10-04T10:52:36+02:00")
|
||||
testTimeString := util.FormatISO8601(testTime)
|
||||
suite.Equal("2021-10-04T08:52:36Z", testTimeString)
|
||||
suite.Equal("2021-10-04T08:52:36.00Z", testTimeString)
|
||||
}
|
||||
|
||||
func TestTimeSuite(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue