mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[feature] Implement Mastodon-compatible roles (#3136)
* Implement Mastodon-compatible roles - `Account.role` should only be available through verify_credentials for checking current user's permissions - `Account.role` now carries a Mastodon-compatible permissions bitmap and a marker for whether it should be shown to the public - `Account.roles` added for *public* display roles (undocumented but stable since Mastodon 4.1) - Web template now uses only public display roles (no user-visible change here, we already special-cased the `user` role) * Handle verify_credentials case for default role * Update JSON exact-match tests * Address review comments * Add blocks bit to admin permissions bitmap
This commit is contained in:
@@ -304,6 +304,15 @@ definitions:
|
||||
x-go-name: Note
|
||||
role:
|
||||
$ref: '#/definitions/accountRole'
|
||||
roles:
|
||||
description: |-
|
||||
Roles lists the public roles of the account on this instance.
|
||||
Unlike Role, this is always available, but never includes permissions details.
|
||||
Key/value omitted for remote accounts.
|
||||
items:
|
||||
$ref: '#/definitions/accountDisplayRole'
|
||||
type: array
|
||||
x-go-name: Roles
|
||||
source:
|
||||
$ref: '#/definitions/Source'
|
||||
statuses_count:
|
||||
@@ -333,6 +342,29 @@ definitions:
|
||||
type: object
|
||||
x-go-name: Account
|
||||
x-go-package: github.com/superseriousbusiness/gotosocial/internal/api/model
|
||||
accountDisplayRole:
|
||||
description: This is a subset of AccountRole.
|
||||
properties:
|
||||
color:
|
||||
description: |-
|
||||
Color is a 6-digit CSS-style hex color code with leading `#`, or an empty string if this role has no color.
|
||||
Since GotoSocial doesn't use role colors, we leave this empty.
|
||||
type: string
|
||||
x-go-name: Color
|
||||
id:
|
||||
description: |-
|
||||
ID of the role.
|
||||
Not used by GotoSocial, but we set it to the role name, just in case a client expects a unique ID.
|
||||
type: string
|
||||
x-go-name: ID
|
||||
name:
|
||||
description: Name of the role.
|
||||
type: string
|
||||
x-go-name: Name
|
||||
title: AccountDisplayRole models a public, displayable role of an account.
|
||||
type: object
|
||||
x-go-name: AccountDisplayRole
|
||||
x-go-package: github.com/superseriousbusiness/gotosocial/internal/api/model
|
||||
accountExportStats:
|
||||
description: |-
|
||||
AccountExportStats models an account's stats
|
||||
@@ -448,9 +480,32 @@ definitions:
|
||||
x-go-package: github.com/superseriousbusiness/gotosocial/internal/api/model
|
||||
accountRole:
|
||||
properties:
|
||||
color:
|
||||
description: |-
|
||||
Color is a 6-digit CSS-style hex color code with leading `#`, or an empty string if this role has no color.
|
||||
Since GotoSocial doesn't use role colors, we leave this empty.
|
||||
type: string
|
||||
x-go-name: Color
|
||||
highlighted:
|
||||
description: |-
|
||||
Highlighted indicates whether the role is publicly visible on the user profile.
|
||||
This is always true for GotoSocial's built-in admin and moderator roles, and false otherwise.
|
||||
type: boolean
|
||||
x-go-name: Highlighted
|
||||
id:
|
||||
description: |-
|
||||
ID of the role.
|
||||
Not used by GotoSocial, but we set it to the role name, just in case a client expects a unique ID.
|
||||
type: string
|
||||
x-go-name: ID
|
||||
name:
|
||||
description: Name of the role.
|
||||
type: string
|
||||
x-go-name: Name
|
||||
permissions:
|
||||
description: Permissions is a bitmap serialized as a numeric string, indicating which admin/moderation actions a user can perform.
|
||||
type: string
|
||||
x-go-name: Permissions
|
||||
title: AccountRole models the role of an account.
|
||||
type: object
|
||||
x-go-name: AccountRole
|
||||
@@ -2209,6 +2264,15 @@ definitions:
|
||||
x-go-name: Note
|
||||
role:
|
||||
$ref: '#/definitions/accountRole'
|
||||
roles:
|
||||
description: |-
|
||||
Roles lists the public roles of the account on this instance.
|
||||
Unlike Role, this is always available, but never includes permissions details.
|
||||
Key/value omitted for remote accounts.
|
||||
items:
|
||||
$ref: '#/definitions/accountDisplayRole'
|
||||
type: array
|
||||
x-go-name: Roles
|
||||
source:
|
||||
$ref: '#/definitions/Source'
|
||||
statuses_count:
|
||||
|
Reference in New Issue
Block a user