Merge commit '01fcf84604
' into kb_migration
This commit is contained in:
commit
e3cc989954
10 changed files with 73 additions and 54 deletions
|
@ -233,7 +233,7 @@ class ActivityPub::TagManager
|
||||||
end
|
end
|
||||||
|
|
||||||
def account_searchable_by(account)
|
def account_searchable_by(account)
|
||||||
case account.searchability
|
case account.compute_searchability_activitypub
|
||||||
when 'public'
|
when 'public'
|
||||||
[COLLECTIONS[:public]]
|
[COLLECTIONS[:public]]
|
||||||
when 'private', 'direct'
|
when 'private', 'direct'
|
||||||
|
|
|
@ -530,6 +530,10 @@ class Account < ApplicationRecord
|
||||||
save!
|
save!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def compute_searchability_activitypub
|
||||||
|
local? ? 'public' : searchability
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def prepare_contents
|
def prepare_contents
|
||||||
|
|
|
@ -11,7 +11,7 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
||||||
|
|
||||||
has_one :moved_to_account, key: :moved, serializer: REST::AccountSerializer, if: :moved_and_not_nested?
|
has_one :moved_to_account, key: :moved, serializer: REST::AccountSerializer, if: :moved_and_not_nested?
|
||||||
|
|
||||||
has_many :emojis, serializer: REST::CustomEmojiSerializer
|
has_many :emojis, serializer: REST::CustomEmojiSlimSerializer
|
||||||
|
|
||||||
attribute :suspended, if: :suspended?
|
attribute :suspended, if: :suspended?
|
||||||
attribute :silenced, key: :limited, if: :silenced?
|
attribute :silenced, key: :limited, if: :silenced?
|
||||||
|
|
|
@ -1,57 +1,11 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class REST::CustomEmojiSerializer < ActiveModel::Serializer
|
class REST::CustomEmojiSerializer < REST::CustomEmojiSlimSerializer
|
||||||
include RoutingHelper
|
include RoutingHelper
|
||||||
|
|
||||||
attributes :shortcode, :url, :static_url, :visible_in_picker
|
|
||||||
|
|
||||||
attribute :category, if: :category_loaded?
|
|
||||||
attribute :width, if: :width?
|
|
||||||
attribute :height, if: :height?
|
|
||||||
attribute :aliases, if: :aliases?
|
attribute :aliases, if: :aliases?
|
||||||
attribute :sensitive, if: :sensitive?
|
|
||||||
|
|
||||||
def url
|
|
||||||
full_asset_url(object.image.url)
|
|
||||||
end
|
|
||||||
|
|
||||||
def static_url
|
|
||||||
full_asset_url(object.image.url(:static))
|
|
||||||
end
|
|
||||||
|
|
||||||
def category
|
|
||||||
object.category.name
|
|
||||||
end
|
|
||||||
|
|
||||||
def category_loaded?
|
|
||||||
object.association(:category).loaded? && object.category.present?
|
|
||||||
end
|
|
||||||
|
|
||||||
def width?
|
|
||||||
object.respond_to?(:image_width) || object.respond_to?(:width)
|
|
||||||
end
|
|
||||||
|
|
||||||
def height?
|
|
||||||
object.respond_to?(:image_height) || object.respond_to?(:height)
|
|
||||||
end
|
|
||||||
|
|
||||||
def width
|
|
||||||
object.respond_to?(:image_width) ? object.image_width : object.width
|
|
||||||
end
|
|
||||||
|
|
||||||
def height
|
|
||||||
object.respond_to?(:image_height) ? object.image_height : object.height
|
|
||||||
end
|
|
||||||
|
|
||||||
def aliases?
|
def aliases?
|
||||||
object.respond_to?(:aliases) && object.aliases.present?
|
object.respond_to?(:aliases) && object.aliases.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def sensitive?
|
|
||||||
object.respond_to?(:is_sensitive)
|
|
||||||
end
|
|
||||||
|
|
||||||
def sensitive
|
|
||||||
object.is_sensitive
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
52
app/serializers/rest/custom_emoji_slim_serializer.rb
Normal file
52
app/serializers/rest/custom_emoji_slim_serializer.rb
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class REST::CustomEmojiSlimSerializer < ActiveModel::Serializer
|
||||||
|
include RoutingHelper
|
||||||
|
|
||||||
|
attributes :shortcode, :url, :static_url, :visible_in_picker
|
||||||
|
|
||||||
|
attribute :category, if: :category_loaded?
|
||||||
|
attribute :width, if: :width?
|
||||||
|
attribute :height, if: :height?
|
||||||
|
attribute :sensitive, if: :sensitive?
|
||||||
|
|
||||||
|
def url
|
||||||
|
full_asset_url(object.image.url)
|
||||||
|
end
|
||||||
|
|
||||||
|
def static_url
|
||||||
|
full_asset_url(object.image.url(:static))
|
||||||
|
end
|
||||||
|
|
||||||
|
def category
|
||||||
|
object.category.name
|
||||||
|
end
|
||||||
|
|
||||||
|
def category_loaded?
|
||||||
|
object.association(:category).loaded? && object.category.present?
|
||||||
|
end
|
||||||
|
|
||||||
|
def width?
|
||||||
|
object.respond_to?(:image_width) || object.respond_to?(:width)
|
||||||
|
end
|
||||||
|
|
||||||
|
def height?
|
||||||
|
object.respond_to?(:image_height) || object.respond_to?(:height)
|
||||||
|
end
|
||||||
|
|
||||||
|
def width
|
||||||
|
object.respond_to?(:image_width) ? object.image_width : object.width
|
||||||
|
end
|
||||||
|
|
||||||
|
def height
|
||||||
|
object.respond_to?(:image_height) ? object.image_height : object.height
|
||||||
|
end
|
||||||
|
|
||||||
|
def sensitive?
|
||||||
|
object.respond_to?(:is_sensitive)
|
||||||
|
end
|
||||||
|
|
||||||
|
def sensitive
|
||||||
|
object.is_sensitive
|
||||||
|
end
|
||||||
|
end
|
|
@ -5,17 +5,22 @@ class REST::NotifyEmojiReactionSerializer < ActiveModel::Serializer
|
||||||
|
|
||||||
attributes :name
|
attributes :name
|
||||||
|
|
||||||
attribute :count, if: :count?
|
attribute :count
|
||||||
attribute :url, if: :custom_emoji?
|
attribute :url, if: :custom_emoji?
|
||||||
attribute :static_url, if: :custom_emoji?
|
attribute :static_url, if: :custom_emoji?
|
||||||
attribute :domain, if: :custom_emoji?
|
attribute :domain, if: :custom_emoji?
|
||||||
attribute :width, if: :width?
|
attribute :width, if: :width?
|
||||||
attribute :height, if: :height?
|
attribute :height, if: :height?
|
||||||
|
attribute :me
|
||||||
|
|
||||||
def count?
|
def count?
|
||||||
object.respond_to?(:count)
|
object.respond_to?(:count)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def count
|
||||||
|
count? ? object.count : 1
|
||||||
|
end
|
||||||
|
|
||||||
def custom_emoji?
|
def custom_emoji?
|
||||||
object.respond_to?(:custom_emoji) && object.custom_emoji.present?
|
object.respond_to?(:custom_emoji) && object.custom_emoji.present?
|
||||||
end
|
end
|
||||||
|
@ -51,4 +56,8 @@ class REST::NotifyEmojiReactionSerializer < ActiveModel::Serializer
|
||||||
def height
|
def height
|
||||||
object.custom_emoji.respond_to?(:image_height) ? object.custom_emoji.image_height : object.custom_emoji.height
|
object.custom_emoji.respond_to?(:image_height) ? object.custom_emoji.image_height : object.custom_emoji.height
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def me
|
||||||
|
false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ class REST::PollSerializer < ActiveModel::Serializer
|
||||||
:multiple, :votes_count, :voters_count
|
:multiple, :votes_count, :voters_count
|
||||||
|
|
||||||
has_many :loaded_options, key: :options
|
has_many :loaded_options, key: :options
|
||||||
has_many :emojis, serializer: REST::CustomEmojiSerializer
|
has_many :emojis, serializer: REST::CustomEmojiSlimSerializer
|
||||||
|
|
||||||
attribute :voted, if: :current_user?
|
attribute :voted, if: :current_user?
|
||||||
attribute :own_votes, if: :current_user?
|
attribute :own_votes, if: :current_user?
|
||||||
|
|
|
@ -8,7 +8,7 @@ class REST::StatusEditSerializer < ActiveModel::Serializer
|
||||||
attributes :content, :spoiler_text, :markdown, :sensitive, :created_at
|
attributes :content, :spoiler_text, :markdown, :sensitive, :created_at
|
||||||
|
|
||||||
has_many :ordered_media_attachments, key: :media_attachments, serializer: REST::MediaAttachmentSerializer
|
has_many :ordered_media_attachments, key: :media_attachments, serializer: REST::MediaAttachmentSerializer
|
||||||
has_many :emojis, serializer: REST::CustomEmojiSerializer
|
has_many :emojis, serializer: REST::CustomEmojiSlimSerializer
|
||||||
|
|
||||||
attribute :poll, if: -> { object.poll_options.present? }
|
attribute :poll, if: -> { object.poll_options.present? }
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
||||||
has_many :ordered_media_attachments, key: :media_attachments, serializer: REST::MediaAttachmentSerializer
|
has_many :ordered_media_attachments, key: :media_attachments, serializer: REST::MediaAttachmentSerializer
|
||||||
has_many :ordered_mentions, key: :mentions
|
has_many :ordered_mentions, key: :mentions
|
||||||
has_many :tags
|
has_many :tags
|
||||||
has_many :emojis, serializer: REST::CustomEmojiSerializer
|
has_many :emojis, serializer: REST::CustomEmojiSlimSerializer
|
||||||
|
|
||||||
has_one :preview_card, key: :card, serializer: REST::PreviewCardSerializer
|
has_one :preview_card, key: :card, serializer: REST::PreviewCardSerializer
|
||||||
has_one :preloadable_poll, key: :poll, serializer: REST::PollSerializer
|
has_one :preloadable_poll, key: :poll, serializer: REST::PollSerializer
|
||||||
|
|
|
@ -11,7 +11,7 @@ class DeliveryEmojiReactionWorker
|
||||||
|
|
||||||
if status.present?
|
if status.present?
|
||||||
scope_status(status).includes(:user).find_each do |account|
|
scope_status(status).includes(:user).find_each do |account|
|
||||||
redis.publish("timeline:#{account.id}", payload_json) if !account.user&.setting_stop_emoji_reaction_streaming && redis.exists?("subscribed:timeline:#{account.id}")
|
redis.publish("timeline:#{account.id}", payload_json) if (!account.respond_to?(:user) || !account.user&.setting_stop_emoji_reaction_streaming) && redis.exists?("subscribed:timeline:#{account.id}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue