Spawn FeedInsertWorker to deliver status into personal feed

This commit is contained in:
Eugen Rochko
2017-04-04 19:21:37 +02:00
parent 5f54981846
commit 6fd865c000
5 changed files with 39 additions and 25 deletions

View File

@ -33,9 +33,8 @@ class FanOutOnWriteService < BaseService
def deliver_to_followers(status)
Rails.logger.debug "Delivering status #{status.id} to followers"
status.account.followers.where(domain: nil).joins(:user).where('users.current_sign_in_at > ?', 14.days.ago).find_each do |follower|
next if FeedManager.instance.filter?(:home, status, follower)
FeedManager.instance.push(:home, follower, status)
status.account.followers.where(domain: nil).joins(:user).where('users.current_sign_in_at > ?', 14.days.ago).select(:id).find_each do |follower|
FeedInsertWorker.perform_async(status.id, follower.id)
end
end
@ -44,7 +43,7 @@ class FanOutOnWriteService < BaseService
status.mentions.includes(:account).each do |mention|
mentioned_account = mention.account
next if !mentioned_account.local? || !mentioned_account.following?(status.account) || FeedManager.instance.filter?(:home, status, mentioned_account)
next if !mentioned_account.local? || !mentioned_account.following?(status.account) || FeedManager.instance.filter?(:home, status, mention.account_id)
FeedManager.instance.push(:home, mentioned_account, status)
end
end
@ -54,9 +53,9 @@ class FanOutOnWriteService < BaseService
payload = FeedManager.instance.inline_render(nil, 'api/v1/statuses/show', status)
status.tags.find_each do |tag|
FeedManager.instance.broadcast("hashtag:#{tag.name}", event: 'update', payload: payload)
FeedManager.instance.broadcast("hashtag:#{tag.name}:local", event: 'update', payload: payload) if status.account.local?
status.tags.pluck(:name).each do |hashtag|
FeedManager.instance.broadcast("hashtag:#{hashtag}", event: 'update', payload: payload)
FeedManager.instance.broadcast("hashtag:#{hashtag}:local", event: 'update', payload: payload) if status.account.local?
end
end

View File

@ -17,7 +17,7 @@ class NotifyService < BaseService
private
def blocked_mention?
FeedManager.instance.filter?(:mentions, @notification.mention.status, @recipient)
FeedManager.instance.filter?(:mentions, @notification.mention.status, @recipient.id)
end
def blocked_favourite?

View File

@ -7,7 +7,7 @@ class PrecomputeFeedService < BaseService
def call(_, account)
redis.pipelined do
Status.as_home_timeline(account).limit(FeedManager::MAX_ITEMS / 4).each do |status|
next if status.direct_visibility? || FeedManager.instance.filter?(:home, status, account)
next if status.direct_visibility? || FeedManager.instance.filter?(:home, status, account.id)
redis.zadd(FeedManager.instance.key(:home, account.id), status.id, status.reblog? ? status.reblog_of_id : status.id)
end
end