From c5e03a2e0d7eac132a5d62d1d7d523a6969697cc Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 9 Nov 2016 19:16:27 +0100 Subject: [PATCH] Status removal is broadcast to public/hashtag timelines too --- app/channels/application_cable/channel.rb | 7 +++++-- app/services/remove_status_service.rb | 12 ++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb index d27b058fb0..43adadbd90 100644 --- a/app/channels/application_cable/channel.rb +++ b/app/channels/application_cable/channel.rb @@ -4,14 +4,17 @@ module ApplicationCable def hydrate_status(encoded_message) message = ActiveSupport::JSON.decode(encoded_message) - status = Status.find_by(id: message['id']) + + return [nil, message] if message['type'] == 'delete' + + status = Status.find_by(id: message['id']) message['message'] = FeedManager.instance.inline_render(current_user.account, status) [status, message] end def filter?(status) - status.nil? || current_user.account.blocking?(status.account) || (status.reblog? && current_user.account.blocking?(status.reblog.account)) + !status.nil? && (current_user.account.blocking?(status.account) || (status.reblog? && current_user.account.blocking?(status.reblog.account))) end end end diff --git a/app/services/remove_status_service.rb b/app/services/remove_status_service.rb index 0b78b131a0..66fa1be18f 100644 --- a/app/services/remove_status_service.rb +++ b/app/services/remove_status_service.rb @@ -4,6 +4,8 @@ class RemoveStatusService < BaseService remove_from_followers(status) remove_from_mentioned(status) remove_reblogs(status) + remove_from_hashtags(status) + remove_from_public(status) status.destroy! end @@ -49,6 +51,16 @@ class RemoveStatusService < BaseService FeedManager.instance.broadcast(receiver.id, type: 'delete', id: status.id) end + def remove_from_hashtags(status) + status.tags.each do |tag| + FeedManager.instance.broadcast("hashtag:#{tag.name}", type: 'delete', id: status.id) + end + end + + def remove_from_public(status) + FeedManager.instance.broadcast(:public, type: 'delete', id: status.id) + end + def redis $redis end