Fix fan-out-on-write service
This commit is contained in:
parent
2d5a103176
commit
c1b9b8dbc5
1 changed files with 19 additions and 9 deletions
|
@ -18,14 +18,20 @@ class FanOutOnWriteService < BaseService
|
||||||
deliver_to_lists(status)
|
deliver_to_lists(status)
|
||||||
end
|
end
|
||||||
|
|
||||||
if status.account.group? && status.reblog?
|
if status.account.group?
|
||||||
render_anonymous_reblog_payload(status)
|
if status.reblog?
|
||||||
|
render_anonymous_reblog_payload(status)
|
||||||
|
else
|
||||||
|
render_anonymous_payload(status)
|
||||||
|
end
|
||||||
|
|
||||||
deliver_to_group(status)
|
deliver_to_group(status)
|
||||||
end
|
end
|
||||||
|
|
||||||
return if status.account.silenced? || !status.public_visibility?
|
return if status.account.silenced? || !status.public_visibility?
|
||||||
|
|
||||||
|
render_anonymous_payload(status)
|
||||||
|
|
||||||
if !status.reblog? && (!status.reply? || status.in_reply_to_account_id == status.account_id)
|
if !status.reblog? && (!status.reply? || status.in_reply_to_account_id == status.account_id)
|
||||||
deliver_to_public(status)
|
deliver_to_public(status)
|
||||||
deliver_to_media(status) if status.media_attachments.any?
|
deliver_to_media(status) if status.media_attachments.any?
|
||||||
|
@ -37,8 +43,6 @@ class FanOutOnWriteService < BaseService
|
||||||
|
|
||||||
return if status.reblog?
|
return if status.reblog?
|
||||||
|
|
||||||
render_anonymous_payload(status)
|
|
||||||
|
|
||||||
deliver_to_hashtags(status)
|
deliver_to_hashtags(status)
|
||||||
deliver_to_hashtag_followers(status)
|
deliver_to_hashtag_followers(status)
|
||||||
deliver_to_keyword_subscribers(status)
|
deliver_to_keyword_subscribers(status)
|
||||||
|
@ -158,11 +162,15 @@ class FanOutOnWriteService < BaseService
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_anonymous_payload(status)
|
def render_anonymous_payload(status)
|
||||||
|
return @payload if defined?(@payload)
|
||||||
|
|
||||||
@payload = InlineRenderer.render(status, nil, :status)
|
@payload = InlineRenderer.render(status, nil, :status)
|
||||||
@payload = Oj.dump(event: :update, payload: @payload)
|
@payload = Oj.dump(event: :update, payload: @payload)
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_anonymous_reblog_payload(status)
|
def render_anonymous_reblog_payload(status)
|
||||||
|
return @reblog_payload if defined?(@reblog_payload)
|
||||||
|
|
||||||
@reblog_payload = InlineRenderer.render(status.reblog, nil, :status)
|
@reblog_payload = InlineRenderer.render(status.reblog, nil, :status)
|
||||||
@reblog_payload = Oj.dump(event: :update, payload: @reblog_payload)
|
@reblog_payload = Oj.dump(event: :update, payload: @reblog_payload)
|
||||||
end
|
end
|
||||||
|
@ -195,19 +203,21 @@ class FanOutOnWriteService < BaseService
|
||||||
end
|
end
|
||||||
|
|
||||||
def deliver_to_group(status)
|
def deliver_to_group(status)
|
||||||
Rails.logger.debug "Delivering status #{status.reblog.id} to group timeline"
|
Rails.logger.debug "Delivering status #{status.id} to group timeline"
|
||||||
|
|
||||||
Redis.current.publish("timeline:group:#{status.account.id}", @reblog_payload)
|
payload = status.reblog? ? @reblog_payload : @payload
|
||||||
|
|
||||||
|
Redis.current.publish("timeline:group:#{status.account.id}", payload)
|
||||||
|
|
||||||
status.tags.pluck(:name).each do |hashtag|
|
status.tags.pluck(:name).each do |hashtag|
|
||||||
Redis.current.publish("timeline:group:#{status.account.id}:#{hashtag.mb_chars.downcase}", @reblog_payload)
|
Redis.current.publish("timeline:group:#{status.account.id}:#{hashtag.mb_chars.downcase}", payload)
|
||||||
end
|
end
|
||||||
|
|
||||||
if status.media_attachments.any?
|
if status.media_attachments.any?
|
||||||
Redis.current.publish("timeline:group:media:#{status.account.id}", @reblog_payload)
|
Redis.current.publish("timeline:group:media:#{status.account.id}", payload)
|
||||||
|
|
||||||
status.tags.pluck(:name).each do |hashtag|
|
status.tags.pluck(:name).each do |hashtag|
|
||||||
Redis.current.publish("timeline:group:media:#{status.account.id}:#{hashtag.mb_chars.downcase}", @reblog_payload)
|
Redis.current.publish("timeline:group:media:#{status.account.id}:#{hashtag.mb_chars.downcase}", payload)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue