Merge branch 'master' into feature-limited-visibility-bearcaps
This commit is contained in:
commit
98a2603dc1
855 changed files with 32564 additions and 10102 deletions
|
@ -7,10 +7,10 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
|
|||
|
||||
context_extensions :manually_approves_followers, :featured, :also_known_as,
|
||||
:moved_to, :property_value, :identity_proof,
|
||||
:discoverable, :olm
|
||||
:discoverable, :olm, :suspended
|
||||
|
||||
attributes :id, :type, :following, :followers,
|
||||
:inbox, :outbox, :featured,
|
||||
:inbox, :outbox, :featured, :featured_tags,
|
||||
:preferred_username, :name, :summary,
|
||||
:url, :manually_approves_followers,
|
||||
:discoverable
|
||||
|
@ -23,6 +23,7 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
|
|||
attribute :devices, unless: :instance_actor?
|
||||
attribute :moved_to, if: :moved?
|
||||
attribute :also_known_as, if: :also_known_as?
|
||||
attribute :suspended, if: :suspended?
|
||||
|
||||
class EndpointsSerializer < ActivityPub::Serializer
|
||||
include RoutingHelper
|
||||
|
@ -39,7 +40,7 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
|
|||
has_one :icon, serializer: ActivityPub::ImageSerializer, if: :avatar_exists?
|
||||
has_one :image, serializer: ActivityPub::ImageSerializer, if: :header_exists?
|
||||
|
||||
delegate :moved?, :instance_actor?, to: :object
|
||||
delegate :suspended?, :instance_actor?, to: :object
|
||||
|
||||
def id
|
||||
object.instance_actor? ? instance_actor_url : account_url(object)
|
||||
|
@ -74,13 +75,17 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
|
|||
end
|
||||
|
||||
def outbox
|
||||
account_outbox_url(object)
|
||||
object.instance_actor? ? instance_actor_outbox_url : account_outbox_url(object)
|
||||
end
|
||||
|
||||
def featured
|
||||
account_collection_url(object, :featured)
|
||||
end
|
||||
|
||||
def featured_tags
|
||||
account_collection_url(object, :tags)
|
||||
end
|
||||
|
||||
def endpoints
|
||||
object
|
||||
end
|
||||
|
@ -89,12 +94,16 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
|
|||
object.username
|
||||
end
|
||||
|
||||
def discoverable
|
||||
object.suspended? ? false : (object.discoverable || false)
|
||||
end
|
||||
|
||||
def name
|
||||
object.display_name
|
||||
object.suspended? ? '' : object.display_name
|
||||
end
|
||||
|
||||
def summary
|
||||
Formatter.instance.simplified_format(object)
|
||||
object.suspended? ? '' : Formatter.instance.simplified_format(object)
|
||||
end
|
||||
|
||||
def icon
|
||||
|
@ -109,36 +118,44 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
|
|||
object
|
||||
end
|
||||
|
||||
def suspended
|
||||
object.suspended?
|
||||
end
|
||||
|
||||
def url
|
||||
object.instance_actor? ? about_more_url(instance_actor: true) : short_account_url(object)
|
||||
end
|
||||
|
||||
def avatar_exists?
|
||||
object.avatar?
|
||||
!object.suspended? && object.avatar?
|
||||
end
|
||||
|
||||
def header_exists?
|
||||
object.header?
|
||||
!object.suspended? && object.header?
|
||||
end
|
||||
|
||||
def manually_approves_followers
|
||||
object.locked
|
||||
object.suspended? ? false : object.locked
|
||||
end
|
||||
|
||||
def virtual_tags
|
||||
object.emojis + object.tags
|
||||
object.suspended? ? [] : (object.emojis + object.tags)
|
||||
end
|
||||
|
||||
def virtual_attachments
|
||||
object.fields + object.identity_proofs.active
|
||||
object.suspended? ? [] : (object.fields + object.identity_proofs.active)
|
||||
end
|
||||
|
||||
def moved_to
|
||||
ActivityPub::TagManager.instance.uri_for(object.moved_to_account)
|
||||
end
|
||||
|
||||
def moved?
|
||||
!object.suspended? && object.moved?
|
||||
end
|
||||
|
||||
def also_known_as?
|
||||
!object.also_known_as.empty?
|
||||
!object.suspended? && !object.also_known_as.empty?
|
||||
end
|
||||
|
||||
class CustomEmojiSerializer < ActivityPub::EmojiSerializer
|
||||
|
|
|
@ -16,6 +16,8 @@ class ActivityPub::CollectionSerializer < ActivityPub::Serializer
|
|||
ActivityPub::NoteSerializer
|
||||
when 'Device'
|
||||
ActivityPub::DeviceSerializer
|
||||
when 'FeaturedTag'
|
||||
ActivityPub::HashtagSerializer
|
||||
when 'ActivityPub::CollectionPresenter'
|
||||
ActivityPub::CollectionSerializer
|
||||
when 'String'
|
||||
|
|
23
app/serializers/activitypub/hashtag_serializer.rb
Normal file
23
app/serializers/activitypub/hashtag_serializer.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ActivityPub::HashtagSerializer < ActivityPub::Serializer
|
||||
include RoutingHelper
|
||||
|
||||
attributes :type, :href, :name
|
||||
|
||||
def type
|
||||
'Hashtag'
|
||||
end
|
||||
|
||||
def name
|
||||
"##{object.name}"
|
||||
end
|
||||
|
||||
def href
|
||||
if object.class.name == 'FeaturedTag'
|
||||
short_account_tag_url(object.account, object.tag)
|
||||
else
|
||||
tag_url(object)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -95,6 +95,10 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer
|
|||
ActivityPub::TagManager.instance.cc(object)
|
||||
end
|
||||
|
||||
def sensitive
|
||||
object.account.sensitized? || object.sensitive
|
||||
end
|
||||
|
||||
def virtual_tags
|
||||
object.active_mentions.to_a.sort_by(&:id) + object.tags + object.emojis
|
||||
end
|
||||
|
|
|
@ -33,6 +33,7 @@ class InitialStateSerializer < ActiveModel::Serializer
|
|||
store[:display_media] = object.current_account.user.setting_display_media
|
||||
store[:expand_spoilers] = object.current_account.user.setting_expand_spoilers
|
||||
store[:reduce_motion] = object.current_account.user.setting_reduce_motion
|
||||
store[:disable_swiping] = object.current_account.user.setting_disable_swiping
|
||||
store[:advanced_layout] = object.current_account.user.setting_advanced_layout
|
||||
store[:use_blurhash] = object.current_account.user.setting_use_blurhash
|
||||
store[:use_pending_items] = object.current_account.user.setting_use_pending_items
|
||||
|
|
|
@ -7,7 +7,7 @@ class ManifestSerializer < ActiveModel::Serializer
|
|||
attributes :name, :short_name, :description,
|
||||
:icons, :theme_color, :background_color,
|
||||
:display, :start_url, :scope,
|
||||
:share_target
|
||||
:share_target, :shortcuts
|
||||
|
||||
def name
|
||||
object.site_title
|
||||
|
@ -64,4 +64,42 @@ class ManifestSerializer < ActiveModel::Serializer
|
|||
},
|
||||
}
|
||||
end
|
||||
|
||||
def shortcuts
|
||||
[
|
||||
{
|
||||
name: 'New toot',
|
||||
url: '/web/statuses/new',
|
||||
icons: [
|
||||
{
|
||||
src: '/shortcuts/new-status.png',
|
||||
type: 'image/png',
|
||||
sizes: '192x192',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Notifications',
|
||||
url: '/web/notifications',
|
||||
icons: [
|
||||
{
|
||||
src: '/shortcuts/notifications.png',
|
||||
type: 'image/png',
|
||||
sizes: '192x192',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Direct messages',
|
||||
url: '/web/timelines/direct',
|
||||
icons: [
|
||||
{
|
||||
src: '/shortcuts/direct.png',
|
||||
type: 'image/png',
|
||||
sizes: '192x192',
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,8 +8,11 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
|||
:followers_count, :following_count, :statuses_count, :last_status_at
|
||||
|
||||
has_one :moved_to_account, key: :moved, serializer: REST::AccountSerializer, if: :moved_and_not_nested?
|
||||
|
||||
has_many :emojis, serializer: REST::CustomEmojiSerializer
|
||||
|
||||
attribute :suspended, if: :suspended?
|
||||
|
||||
class FieldSerializer < ActiveModel::Serializer
|
||||
attributes :name, :value, :verified_at
|
||||
|
||||
|
@ -29,7 +32,7 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
|||
end
|
||||
|
||||
def note
|
||||
Formatter.instance.simplified_format(object)
|
||||
object.suspended? ? '' : Formatter.instance.simplified_format(object)
|
||||
end
|
||||
|
||||
def url
|
||||
|
@ -37,26 +40,60 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
|||
end
|
||||
|
||||
def avatar
|
||||
full_asset_url(object.avatar_original_url)
|
||||
full_asset_url(object.suspended? ? object.avatar.default_url : object.avatar_original_url)
|
||||
end
|
||||
|
||||
def avatar_static
|
||||
full_asset_url(object.avatar_static_url)
|
||||
full_asset_url(object.suspended? ? object.avatar.default_url : object.avatar_static_url)
|
||||
end
|
||||
|
||||
def header
|
||||
full_asset_url(object.header_original_url)
|
||||
full_asset_url(object.suspended? ? object.header.default_url : object.header_original_url)
|
||||
end
|
||||
|
||||
def header_static
|
||||
full_asset_url(object.header_static_url)
|
||||
end
|
||||
|
||||
def moved_and_not_nested?
|
||||
object.moved? && object.moved_to_account.moved_to_account_id.nil?
|
||||
full_asset_url(object.suspended? ? object.header.default_url : object.header_static_url)
|
||||
end
|
||||
|
||||
def last_status_at
|
||||
object.last_status_at&.to_date&.iso8601
|
||||
end
|
||||
|
||||
def display_name
|
||||
object.suspended? ? '' : object.display_name
|
||||
end
|
||||
|
||||
def locked
|
||||
object.suspended? ? false : object.locked
|
||||
end
|
||||
|
||||
def bot
|
||||
object.suspended? ? false : object.bot
|
||||
end
|
||||
|
||||
def discoverable
|
||||
object.suspended? ? false : object.discoverable
|
||||
end
|
||||
|
||||
def moved_to_account
|
||||
object.suspended? ? nil : object.moved_to_account
|
||||
end
|
||||
|
||||
def emojis
|
||||
object.suspended? ? [] : object.emojis
|
||||
end
|
||||
|
||||
def fields
|
||||
object.suspended? ? [] : object.fields
|
||||
end
|
||||
|
||||
def suspended
|
||||
object.suspended?
|
||||
end
|
||||
|
||||
delegate :suspended?, to: :object
|
||||
|
||||
def moved_and_not_nested?
|
||||
object.moved? && object.moved_to_account.moved_to_account_id.nil?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class REST::FeaturedTagSerializer < ActiveModel::Serializer
|
||||
attributes :id, :name, :statuses_count, :last_status_at
|
||||
include RoutingHelper
|
||||
|
||||
attributes :id, :name, :url, :statuses_count, :last_status_at
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
end
|
||||
|
||||
def url
|
||||
short_account_tag_url(object.account, object.tag)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class REST::ListSerializer < ActiveModel::Serializer
|
||||
attributes :id, :title
|
||||
attributes :id, :title, :replies_policy
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
|
|
10
app/serializers/rest/muted_account_serializer.rb
Normal file
10
app/serializers/rest/muted_account_serializer.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class REST::MutedAccountSerializer < REST::AccountSerializer
|
||||
attribute :mute_expires_at
|
||||
|
||||
def mute_expires_at
|
||||
mute = current_user.account.mute_relationships.find_by(target_account_id: object.id)
|
||||
mute && !mute.expired? ? mute.expires_at : nil
|
||||
end
|
||||
end
|
|
@ -11,6 +11,6 @@ class REST::NotificationSerializer < ActiveModel::Serializer
|
|||
end
|
||||
|
||||
def status_type?
|
||||
[:favourite, :reblog, :mention, :poll].include?(object.type)
|
||||
[:favourite, :reblog, :status, :mention, :poll].include?(object.type)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class REST::RelationshipSerializer < ActiveModel::Serializer
|
||||
attributes :id, :following, :showing_reblogs, :followed_by, :blocking, :blocked_by,
|
||||
:muting, :muting_notifications, :requested, :domain_blocking,
|
||||
:endorsed, :note
|
||||
attributes :id, :following, :showing_reblogs, :notifying, :followed_by,
|
||||
:blocking, :blocked_by, :muting, :muting_notifications, :requested,
|
||||
:domain_blocking, :endorsed, :note
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
|
@ -19,6 +19,12 @@ class REST::RelationshipSerializer < ActiveModel::Serializer
|
|||
false
|
||||
end
|
||||
|
||||
def notifying
|
||||
(instance_options[:relationships].following[object.id] || {})[:notify] ||
|
||||
(instance_options[:relationships].requested[object.id] || {})[:notify] ||
|
||||
false
|
||||
end
|
||||
|
||||
def followed_by
|
||||
instance_options[:relationships].followed_by[object.id] || false
|
||||
end
|
||||
|
|
|
@ -58,6 +58,14 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
|||
end
|
||||
end
|
||||
|
||||
def sensitive
|
||||
if current_user? && current_user.account_id == object.account_id
|
||||
object.sensitive
|
||||
else
|
||||
object.account.sensitized? || object.sensitive
|
||||
end
|
||||
end
|
||||
|
||||
def uri
|
||||
ActivityPub::TagManager.instance.uri_for(object)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue