Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pierre Boudes
mastodon
Commits
13a2abac
Unverified
Commit
13a2abac
authored
2 years ago
by
Claire
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add `roles` attribute to Account entities in REST API (#23255)
parent
e5ae75bf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/models/status.rb
+2
-2
2 additions, 2 deletions
app/models/status.rb
app/serializers/rest/account_serializer.rb
+18
-0
18 additions, 0 deletions
app/serializers/rest/account_serializer.rb
spec/fabricators/user_role_fabricator.rb
+3
-3
3 additions, 3 deletions
spec/fabricators/user_role_fabricator.rb
with
23 additions
and
5 deletions
app/models/status.rb
+
2
−
2
View file @
13a2abac
...
...
@@ -117,7 +117,7 @@ class Status < ApplicationRecord
:tags
,
:preview_cards
,
:preloadable_poll
,
account:
[
:account_stat
,
:
user
],
account:
[
:account_stat
,
user
: :role
],
active_mentions:
{
account: :account_stat
},
reblog:
[
:application
,
...
...
@@ -127,7 +127,7 @@ class Status < ApplicationRecord
:conversation
,
:status_stat
,
:preloadable_poll
,
account:
[
:account_stat
,
:
user
],
account:
[
:account_stat
,
user
: :role
],
active_mentions:
{
account: :account_stat
},
],
thread:
{
account: :account_stat
}
...
...
This diff is collapsed.
Click to expand it.
app/serializers/rest/account_serializer.rb
+
18
−
0
View file @
13a2abac
...
...
@@ -26,6 +26,16 @@ class REST::AccountSerializer < ActiveModel::Serializer
end
end
class
RoleSerializer
<
ActiveModel
::
Serializer
attributes
:id
,
:name
,
:color
def
id
object
.
id
.
to_s
end
end
has_many
:roles
,
serializer:
RoleSerializer
,
if: :local?
class
FieldSerializer
<
ActiveModel
::
Serializer
include
FormattingHelper
...
...
@@ -114,6 +124,14 @@ class REST::AccountSerializer < ActiveModel::Serializer
object
.
silenced?
end
def
roles
if
object
.
suspended?
[]
else
[
object
.
user
.
role
].
compact
.
filter
{
|
role
|
role
.
highlighted?
}
end
end
def
noindex
object
.
user_prefers_noindex?
end
...
...
This diff is collapsed.
Click to expand it.
spec/fabricators/user_role_fabricator.rb
+
3
−
3
View file @
13a2abac
Fabricator
(
:user_role
)
do
name
"MyString"
color
"MyString"
permissions
""
end
\ No newline at end of file
color
""
permissions
0
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment