Fix streaming emoji reaction self only
This commit is contained in:
parent
3053f30683
commit
dfe1332be6
5 changed files with 66 additions and 3 deletions
|
@ -11,7 +11,7 @@ class ActivityPub::EmojiReactionSerializer < ActivityPub::Serializer
|
|||
end
|
||||
|
||||
def type
|
||||
'Like'
|
||||
'EmojiReact'
|
||||
end
|
||||
|
||||
def actor
|
||||
|
|
38
app/services/concerns/account_limitable.rb
Normal file
38
app/services/concerns/account_limitable.rb
Normal file
|
@ -0,0 +1,38 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module AccountLimitable
|
||||
def scope_status(status)
|
||||
case status.visibility.to_sym
|
||||
when :public, :unlisted
|
||||
#scope_local.merge(scope_list_following_account(status.account))
|
||||
scope_local
|
||||
when :private
|
||||
scope_account_local_followers(status.account)
|
||||
when :limited
|
||||
scope_status_mentioned(status)
|
||||
else
|
||||
scope_status_mentioned(status)
|
||||
end
|
||||
end
|
||||
|
||||
def scope_local
|
||||
Account.local.select(:id)
|
||||
end
|
||||
|
||||
def scope_account_local_followers(account)
|
||||
account.followers_for_local_distribution.select(:id).reorder(nil)
|
||||
end
|
||||
|
||||
def scope_status_mentioned(status)
|
||||
status.active_mentions.where.joins(:account).merge(Account.local).select('account_id AS id').reorder(nil)
|
||||
end
|
||||
|
||||
# TODO: not work
|
||||
def scope_list_following_account(account)
|
||||
account.lists_for_local_distribution.select(:id).reorder(nil)
|
||||
end
|
||||
|
||||
def scope_tag_following_account(status)
|
||||
TagFollow.where(tag_id: @status.tags.map(&:id)).select('account_id AS id').reorder(nil)
|
||||
end
|
||||
end
|
|
@ -57,7 +57,7 @@ class EmojiReactService < BaseService
|
|||
emoji_group = emoji_reaction.status.emoji_reactions_grouped_by_name
|
||||
.find { |reaction_group| reaction_group['name'] == emoji_reaction.name && (!reaction_group.key?(:domain) || reaction_group['domain'] == emoji_reaction.domain) }
|
||||
emoji_group['status_id'] = emoji_reaction.status_id.to_s
|
||||
redis.publish("timeline:#{emoji_reaction.status.account_id}", render_emoji_reaction(emoji_group))
|
||||
FeedAnyJsonWorker.perform_async(render_emoji_reaction(emoji_group), emoji_reaction.status_id, emoji_reaction.account_id)
|
||||
end
|
||||
|
||||
def bump_potential_friendship(account, status)
|
||||
|
|
|
@ -44,7 +44,7 @@ class UnEmojiReactService < BaseService
|
|||
emoji_group = { 'name' => emoji_reaction.name, 'count' => 0, 'account_ids' => [], 'status_id' => emoji_reaction.status_id.to_s }
|
||||
emoji_group['domain'] = emoji_reaction.custom_emoji.domain if emoji_reaction.custom_emoji
|
||||
end
|
||||
redis.publish("timeline:#{emoji_reaction.status.account_id}", render_emoji_reaction(emoji_reaction, emoji_group))
|
||||
FeedAnyJsonWorker.perform_async(render_emoji_reaction(emoji_group), emoji_reaction.status_id, emoji_reaction.account_id)
|
||||
end
|
||||
|
||||
def build_json(emoji_reaction)
|
||||
|
|
25
app/workers/feed_any_json_worker.rb
Normal file
25
app/workers/feed_any_json_worker.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class FeedAnyJsonWorker
|
||||
include Sidekiq::Worker
|
||||
include Redisable
|
||||
include Lockable
|
||||
include AccountLimitable
|
||||
|
||||
def perform(payload_json, status_id, my_account_id = nil)
|
||||
redis.publish("timeline:#{my_account_id}", payload_json) if my_account_id.present?
|
||||
|
||||
status = Status.find(status_id.to_i)
|
||||
|
||||
if status.present?
|
||||
scope_status(status).find_each do |account_id|
|
||||
p account_id if redis.exists?("subscribed:timeline:#{account_id}")
|
||||
redis.publish("timeline:#{account_id}", payload_json) if redis.exists?("subscribed:timeline:#{account_id}")
|
||||
end
|
||||
end
|
||||
|
||||
true
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
true
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue