mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[feature] Serialize local account role via API, and show it via web view (#1045)
* [feature] Add 'role' field to api serialization of local accounts * [chore] Add a bit of license text while I'm here * [frogend] render account role on same line as username in web view of profile * style tweaking on role badges, general profile header layout * profile stats wrapping * don't render standard 'user' role on web view Co-authored-by: f0x <f0x@cthu.lu>
This commit is contained in:
@ -185,13 +185,30 @@ func (c *converter) AccountToAPIAccountPublic(ctx context.Context, a *gtsmodel.A
|
||||
emojis = append(emojis, apiEmoji)
|
||||
}
|
||||
|
||||
var acct string
|
||||
var (
|
||||
acct string
|
||||
role = model.AccountRoleUnknown
|
||||
)
|
||||
|
||||
if a.Domain != "" {
|
||||
// this is a remote user
|
||||
acct = fmt.Sprintf("%s@%s", a.Username, a.Domain)
|
||||
acct = a.Username + "@" + a.Domain
|
||||
} else {
|
||||
// this is a local user
|
||||
acct = a.Username
|
||||
user, err := c.db.GetUserByAccountID(ctx, a.ID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("AccountToAPIAccountPublic: error getting user from database for account id %s: %s", a.ID, err)
|
||||
}
|
||||
|
||||
switch {
|
||||
case *user.Admin:
|
||||
role = model.AccountRoleAdmin
|
||||
case *user.Moderator:
|
||||
role = model.AccountRoleModerator
|
||||
default:
|
||||
role = model.AccountRoleUser
|
||||
}
|
||||
}
|
||||
|
||||
var suspended bool
|
||||
@ -222,6 +239,7 @@ func (c *converter) AccountToAPIAccountPublic(ctx context.Context, a *gtsmodel.A
|
||||
Suspended: suspended,
|
||||
CustomCSS: a.CustomCSS,
|
||||
EnableRSS: *a.EnableRSS,
|
||||
Role: role,
|
||||
}
|
||||
|
||||
c.ensureAvatar(accountFrontend)
|
||||
|
Reference in New Issue
Block a user