Merge remote-tracking branch 'parent/main' into upstream-20240813
This commit is contained in:
commit
e7ccc0539f
358 changed files with 4653 additions and 4261 deletions
|
@ -1,7 +1,22 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class REST::DedupNotificationGroupSerializer < ActiveModel::Serializer
|
||||
class PartialAccountSerializer < REST::AccountSerializer
|
||||
# This is a hack to reset ActiveModel::Serializer internals and only expose the attributes
|
||||
# we care about.
|
||||
self._attributes_data = {}
|
||||
self._reflections = []
|
||||
self._links = []
|
||||
|
||||
attributes :id, :acct, :locked, :bot, :url, :avatar, :avatar_static
|
||||
end
|
||||
|
||||
has_many :accounts, serializer: REST::AccountSerializer
|
||||
has_many :partial_accounts, serializer: PartialAccountSerializer, if: :return_partial_accounts?
|
||||
has_many :statuses, serializer: REST::StatusSerializer
|
||||
has_many :notification_groups, serializer: REST::NotificationGroupSerializer
|
||||
|
||||
def return_partial_accounts?
|
||||
instance_options[:expand_accounts] == 'partial_avatars'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,10 +3,11 @@
|
|||
class REST::NotificationPolicySerializer < ActiveModel::Serializer
|
||||
# Please update `app/javascript/mastodon/api_types/notification_policies.ts` when making changes to the attributes
|
||||
|
||||
attributes :filter_not_following,
|
||||
:filter_not_followers,
|
||||
:filter_new_accounts,
|
||||
:filter_private_mentions,
|
||||
attributes :for_not_following,
|
||||
:for_not_followers,
|
||||
:for_new_accounts,
|
||||
:for_private_mentions,
|
||||
:for_limited_accounts,
|
||||
:summary
|
||||
|
||||
def summary
|
||||
|
|
32
app/serializers/rest/v1/notification_policy_serializer.rb
Normal file
32
app/serializers/rest/v1/notification_policy_serializer.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class REST::V1::NotificationPolicySerializer < ActiveModel::Serializer
|
||||
attributes :filter_not_following,
|
||||
:filter_not_followers,
|
||||
:filter_new_accounts,
|
||||
:filter_private_mentions,
|
||||
:summary
|
||||
|
||||
def summary
|
||||
{
|
||||
pending_requests_count: object.pending_requests_count.to_i,
|
||||
pending_notifications_count: object.pending_notifications_count.to_i,
|
||||
}
|
||||
end
|
||||
|
||||
def filter_not_following
|
||||
!object.accept_not_following?
|
||||
end
|
||||
|
||||
def filter_not_followers
|
||||
!object.accept_not_followers?
|
||||
end
|
||||
|
||||
def filter_new_accounts
|
||||
!object.accept_new_accounts?
|
||||
end
|
||||
|
||||
def filter_private_mentions
|
||||
!object.accept_private_mentions?
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue