Merge branch 'kb_development' into kb_migration
This commit is contained in:
commit
ed6acbf542
32 changed files with 509 additions and 275 deletions
|
@ -15,6 +15,7 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
|||
attribute :bookmarked, if: :current_user?
|
||||
attribute :pinned, if: :pinnable?
|
||||
attribute :reactions, if: :reactions?
|
||||
attribute :expires_at, if: :will_expire?
|
||||
has_many :filtered, serializer: REST::FilterResultSerializer, if: :current_user?
|
||||
|
||||
attribute :content, unless: :source_requested?
|
||||
|
@ -122,7 +123,7 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
|||
end
|
||||
|
||||
def emoji_reactions
|
||||
object.emoji_reactions_grouped_by_name(current_user&.account)
|
||||
show_emoji_reaction? ? object.emoji_reactions_grouped_by_name(current_user&.account, permitted_account_ids: emoji_reaction_permitted_account_ids) : []
|
||||
end
|
||||
|
||||
def emoji_reactions_count
|
||||
|
@ -131,7 +132,17 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
|||
|
||||
object.account.emoji_reaction_policy == :allow ? object.emoji_reactions_count : 0
|
||||
else
|
||||
object.account.show_emoji_reaction?(current_user.account) ? object.emoji_reactions_count : 0
|
||||
show_emoji_reaction? ? object.emoji_reactions_count : 0
|
||||
end
|
||||
end
|
||||
|
||||
def show_emoji_reaction?
|
||||
if relationships
|
||||
return true if relationships.emoji_reaction_allows_map.nil?
|
||||
|
||||
relationships.emoji_reaction_allows_map[object.account_id] || false
|
||||
else
|
||||
object.account.show_emoji_reaction?(current_user.account)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -205,12 +216,24 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
|||
object.active_mentions.to_a.sort_by(&:id)
|
||||
end
|
||||
|
||||
def will_expire?
|
||||
object.scheduled_expiration_status.present?
|
||||
end
|
||||
|
||||
def expires_at
|
||||
object.scheduled_expiration_status.scheduled_at
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def relationships
|
||||
instance_options && instance_options[:relationships]
|
||||
end
|
||||
|
||||
def emoji_reaction_permitted_account_ids
|
||||
current_user.present? && instance_options && instance_options[:emoji_reaction_permitted_account_ids]&.permitted_account_ids
|
||||
end
|
||||
|
||||
class ApplicationSerializer < ActiveModel::Serializer
|
||||
attributes :name, :website
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue