Skip to content

Commit

Permalink
[bugfix] Don't nil emojis + fields on blocked accounts (superseriousb…
Browse files Browse the repository at this point in the history
…usiness#2968)

* [bugfix] Don't nil emojis + fields on blocked accounts

* comment

* swagger
  • Loading branch information
tsmethurst authored and nyarla committed Jun 19, 2024
1 parent 878088d commit c7e1b25
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
8 changes: 6 additions & 2 deletions docs/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ definitions:
type: string
x-go-name: DisplayName
emojis:
description: Array of custom emojis used in this account's note or display name.
description: |-
Array of custom emojis used in this account's note or display name.
Empty for blocked accounts.
items:
$ref: '#/definitions/emoji'
type: array
Expand All @@ -235,7 +237,9 @@ definitions:
type: boolean
x-go-name: EnableRSS
fields:
description: Additional metadata attached to this account's profile.
description: |-
Additional metadata attached to this account's profile.
Empty for blocked accounts.
items:
$ref: '#/definitions/field'
type: array
Expand Down
2 changes: 2 additions & 0 deletions internal/api/model/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ type Account struct {
// example: 2021-07-30T09:20:25+00:00
LastStatusAt *string `json:"last_status_at"`
// Array of custom emojis used in this account's note or display name.
// Empty for blocked accounts.
Emojis []Emoji `json:"emojis"`
// Additional metadata attached to this account's profile.
// Empty for blocked accounts.
Fields []Field `json:"fields"`
// Account has been suspended by our instance.
Suspended bool `json:"suspended,omitempty"`
Expand Down
4 changes: 4 additions & 0 deletions internal/typeutils/internaltofrontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ func (c *Converter) AccountToAPIAccountBlocked(ctx context.Context, a *gtsmodel.
Bot: *a.Bot,
CreatedAt: util.FormatISO8601(a.CreatedAt),
URL: a.URL,
// Empty array (not nillable).
Emojis: make([]apimodel.Emoji, 0),
// Empty array (not nillable).
Fields: make([]apimodel.Field, 0),
Suspended: !a.SuspendedAt.IsZero(),
Role: role,
}
Expand Down
4 changes: 2 additions & 2 deletions internal/typeutils/internaltofrontend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,8 @@ func (suite *InternalToFrontendTestSuite) TestLocalInstanceAccountToFrontendBloc
"following_count": 0,
"statuses_count": 0,
"last_status_at": null,
"emojis": null,
"fields": null
"emojis": [],
"fields": []
}`, string(b))
}

Expand Down

0 comments on commit c7e1b25

Please sign in to comment.