Browse Source

Merge pull request #2095 from ClearlyClaire/glitch-soc/merge-upstream

Merge upstream changes
closed-social-glitch-2
Claire 1 year ago
committed by GitHub
parent
commit
cfa92c4ec0
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 5 deletions
  1. +2
    -2
      app/models/status.rb
  2. +18
    -0
      app/serializers/rest/account_serializer.rb
  3. +3
    -3
      spec/fabricators/user_role_fabricator.rb

+ 2
- 2
app/models/status.rb View File

@ -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,
@ -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 }

+ 18
- 0
app/serializers/rest/account_serializer.rb View File

@ -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
@ -118,6 +128,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

+ 3
- 3
spec/fabricators/user_role_fabricator.rb View File

@ -1,5 +1,5 @@
Fabricator(:user_role) do
name "MyString"
color "MyString"
permissions ""
end
color ""
permissions 0
end

Loading…
Cancel
Save