mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-24 09:20:59 +00:00
[bugfix] Fix login on Mastodon iOS app for users with no statuses (#1042)
* Fix login on Mastodon iOS app for users with no statuses Mastodon for iOS can't cope with an empty string for a date and expect a JSON `null` instead. Fixes https://github.com/superseriousbusiness/gotosocial/issues/1010 * Fix expected values in tests to match
This commit is contained in:
parent
e8c733da3f
commit
96f11e757c
4 changed files with 6 additions and 5 deletions
|
@ -70,7 +70,7 @@ func (suite *GetTestSuite) TestGet() {
|
||||||
b, err := ioutil.ReadAll(result.Body)
|
b, err := ioutil.ReadAll(result.Body)
|
||||||
assert.NoError(suite.T(), err)
|
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:28.000Z","note":"i'm a real son of a gun","url":"http://example.org/@some_user","avatar":"","avatar_static":"","header":"http://localhost:8080/assets/default_header.png","header_static":"http://localhost:8080/assets/default_header.png","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.000Z","note":"i'm a real son of a gun","url":"http://example.org/@some_user","avatar":"","avatar_static":"","header":"http://localhost:8080/assets/default_header.png","header_static":"http://localhost:8080/assets/default_header.png","followers_count":0,"following_count":0,"statuses_count":0,"last_status_at":null,"emojis":[],"fields":[]}]`, string(b))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetTestSuite(t *testing.T) {
|
func TestGetTestSuite(t *testing.T) {
|
||||||
|
|
|
@ -78,7 +78,7 @@ type Account struct {
|
||||||
StatusesCount int `json:"statuses_count"`
|
StatusesCount int `json:"statuses_count"`
|
||||||
// When the account's most recent status was posted (ISO 8601 Datetime).
|
// When the account's most recent status was posted (ISO 8601 Datetime).
|
||||||
// example: 2021-07-30T09:20:25+00:00
|
// example: 2021-07-30T09:20:25+00:00
|
||||||
LastStatusAt string `json:"last_status_at"`
|
LastStatusAt *string `json:"last_status_at"`
|
||||||
// Array of custom emojis used in this account's note or display name.
|
// Array of custom emojis used in this account's note or display name.
|
||||||
Emojis []Emoji `json:"emojis"`
|
Emojis []Emoji `json:"emojis"`
|
||||||
// Additional metadata attached to this account's profile.
|
// Additional metadata attached to this account's profile.
|
||||||
|
|
|
@ -105,10 +105,11 @@ func (c *converter) AccountToAPIAccountPublic(ctx context.Context, a *gtsmodel.A
|
||||||
}
|
}
|
||||||
|
|
||||||
// check when the last status was
|
// check when the last status was
|
||||||
var lastStatusAt string
|
var lastStatusAt *string
|
||||||
lastPosted, err := c.db.GetAccountLastPosted(ctx, a.ID, false)
|
lastPosted, err := c.db.GetAccountLastPosted(ctx, a.ID, false)
|
||||||
if err == nil && !lastPosted.IsZero() {
|
if err == nil && !lastPosted.IsZero() {
|
||||||
lastStatusAt = util.FormatISO8601(lastPosted)
|
lastStatusAtTemp := util.FormatISO8601(lastPosted)
|
||||||
|
lastStatusAt = &lastStatusAtTemp
|
||||||
}
|
}
|
||||||
|
|
||||||
// set account avatar fields if available
|
// set account avatar fields if available
|
||||||
|
|
|
@ -138,7 +138,7 @@ func (suite *InternalToFrontendTestSuite) TestInstanceToFrontendWithAdminAccount
|
||||||
b, err := json.Marshal(apiInstance)
|
b, err := json.Marshal(apiInstance)
|
||||||
suite.NoError(err)
|
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:28.000Z","note":"i'm a real son of a gun","url":"http://example.org/@some_user","avatar":"","avatar_static":"","header":"http://localhost:8080/assets/default_header.png","header_static":"http://localhost:8080/assets/default_header.png","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.000Z","note":"i'm a real son of a gun","url":"http://example.org/@some_user","avatar":"","avatar_static":"","header":"http://localhost:8080/assets/default_header.png","header_static":"http://localhost:8080/assets/default_header.png","followers_count":0,"following_count":0,"statuses_count":0,"last_status_at":null,"emojis":[],"fields":[]},"max_toot_chars":0}`, string(b))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *InternalToFrontendTestSuite) TestEmojiToFrontend() {
|
func (suite *InternalToFrontendTestSuite) TestEmojiToFrontend() {
|
||||||
|
|
Loading…
Reference in a new issue