[bugfix] Fix report serialization errors caused by user delete (#1659)

* [bugfix] Fix report serialization errors caused by user delete

* fix tests
This commit is contained in:
tobi
2023-03-31 15:01:29 +02:00
committed by GitHub
parent 344c7e5cbd
commit d9bbcc60a6
6 changed files with 430 additions and 20 deletions

View File

@ -270,7 +270,7 @@ func (c *converter) AccountToAdminAPIAccount(ctx context.Context, a *gtsmodel.Ac
)
// take user-level information if possible
if a.Domain != "" {
if a.IsRemote() {
domain = &a.Domain
} else {
user, err := c.db.GetUserByAccountID(ctx, a.ID)
@ -289,7 +289,9 @@ func (c *converter) AccountToAdminAPIAccount(ctx context.Context, a *gtsmodel.Ac
}
locale = user.Locale
inviteRequest = &user.Account.Reason
if user.Account.Reason != "" {
inviteRequest = &user.Account.Reason
}
if *user.Admin {
role.Name = apimodel.AccountRoleAdmin
} else if *user.Moderator {
@ -298,11 +300,12 @@ func (c *converter) AccountToAdminAPIAccount(ctx context.Context, a *gtsmodel.Ac
confirmed = !user.ConfirmedAt.IsZero()
approved = *user.Approved
disabled = *user.Disabled
silenced = !user.Account.SilencedAt.IsZero()
suspended = !user.Account.SuspendedAt.IsZero()
createdByApplicationID = user.CreatedByApplicationID
}
silenced = !a.SilencedAt.IsZero()
suspended = !a.SuspendedAt.IsZero()
apiAccount, err := c.AccountToAPIAccountPublic(ctx, a)
if err != nil {
return nil, fmt.Errorf("AccountToAdminAPIAccount: error converting account to api account for account id %s: %w", a.ID, err)