From 9d55529318a285ced484b9216df9064914d6f790 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 21 Mar 2016 17:02:16 +0100 Subject: Fix text color in dashboard inputs, sanitize remote status content in UI, simplify FanOutOnWriteService, add /api/accounts/lookup method --- app/services/fan_out_on_write_service.rb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'app/services/fan_out_on_write_service.rb') diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb index 3d94f1049..45814cfb5 100644 --- a/app/services/fan_out_on_write_service.rb +++ b/app/services/fan_out_on_write_service.rb @@ -4,18 +4,25 @@ class FanOutOnWriteService < BaseService # Push a status into home and mentions feeds # @param [Status] status def call(status) - replied_to_user = status.reply? ? status.thread.account : nil + deliver_to_self(status) if status.account.local? + deliver_to_followers(status, status.reply? ? status.thread.account : nil) + deliver_to_mentioned(status) + end + + private - # Deliver to local self - push(:home, status.account.id, status) if status.account.local? + def deliver_to_self(status) + push(:home, status.account.id, status) + end - # Deliver to local followers + def deliver_to_followers(status, replied_to_user) status.account.followers.each do |follower| next if (status.reply? && !(follower.id = replied_to_user.id || follower.following?(replied_to_user))) || !follower.local? push(:home, follower.id, status) end + end - # Deliver to local mentioned + def deliver_to_mentioned(status) status.mentioned_accounts.each do |mention| mentioned_account = mention.account next unless mentioned_account.local? @@ -23,8 +30,6 @@ class FanOutOnWriteService < BaseService end end - private - def push(type, receiver_id, status) redis.zadd(key(type, receiver_id), status.created_at.to_i, status.id) trim(type, receiver_id) -- cgit