Skip to content

Commit

Permalink
Merge pull request mastodon#2095 from ClearlyClaire/glitch-soc/merge-…
Browse files Browse the repository at this point in the history
…upstream

Merge upstream changes
  • Loading branch information
ClearlyClaire committed Jan 26, 2023
2 parents 20abef6 + fad6633 commit cfa92c4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/models/status.rb
Expand Up @@ -122,7 +122,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,
Expand All @@ -132,7 +132,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 }
Expand Down
18 changes: 18 additions & 0 deletions app/serializers/rest/account_serializer.rb
Expand Up @@ -26,6 +26,16 @@ def moved?
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

Expand Down Expand Up @@ -118,6 +128,14 @@ def silenced
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
Expand Down
6 changes: 3 additions & 3 deletions spec/fabricators/user_role_fabricator.rb
@@ -1,5 +1,5 @@
Fabricator(:user_role) do
name "MyString"
color "MyString"
permissions ""
end
color ""
permissions 0
end

0 comments on commit cfa92c4

Please sign in to comment.