Fix empty home feed before first follow has finished processing (#16152)
Change queue of merge worker from pull to defaultmain
parent
8c44b723bb
commit
fab65848d2
|
@ -184,6 +184,14 @@ module AccountInteractions
|
||||||
active_relationships.where(target_account: other_account).exists?
|
active_relationships.where(target_account: other_account).exists?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def following_anyone?
|
||||||
|
active_relationships.exists?
|
||||||
|
end
|
||||||
|
|
||||||
|
def not_following_anyone?
|
||||||
|
!following_anyone?
|
||||||
|
end
|
||||||
|
|
||||||
def blocking?(other_account)
|
def blocking?(other_account)
|
||||||
block_relationships.where(target_account: other_account).exists?
|
block_relationships.where(target_account: other_account).exists?
|
||||||
end
|
end
|
||||||
|
|
|
@ -458,9 +458,7 @@ class User < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def regenerate_feed!
|
def regenerate_feed!
|
||||||
return unless Redis.current.setnx("account:#{account_id}:regeneration", true)
|
RegenerationWorker.perform_async(account_id) if Redis.current.set("account:#{account_id}:regeneration", true, nx: true, ex: 1.day.seconds)
|
||||||
Redis.current.expire("account:#{account_id}:regeneration", 1.day.seconds)
|
|
||||||
RegenerationWorker.perform_async(account_id)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def needs_feed_update?
|
def needs_feed_update?
|
||||||
|
|
|
@ -30,6 +30,11 @@ class FollowService < BaseService
|
||||||
|
|
||||||
ActivityTracker.increment('activity:interactions')
|
ActivityTracker.increment('activity:interactions')
|
||||||
|
|
||||||
|
# When an account follows someone for the first time, avoid showing
|
||||||
|
# an empty home feed while the follow request is being processed
|
||||||
|
# and the feeds are being merged
|
||||||
|
mark_home_feed_as_partial! if @source_account.not_following_anyone?
|
||||||
|
|
||||||
if (@target_account.locked? && !@options[:bypass_locked]) || @source_account.silenced? || @target_account.activitypub?
|
if (@target_account.locked? && !@options[:bypass_locked]) || @source_account.silenced? || @target_account.activitypub?
|
||||||
request_follow!
|
request_follow!
|
||||||
elsif @target_account.local?
|
elsif @target_account.local?
|
||||||
|
@ -39,6 +44,10 @@ class FollowService < BaseService
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def mark_home_feed_as_partial!
|
||||||
|
redis.set("account:#{@source_account.id}:regeneration", true, nx: true, ex: 1.day.seconds)
|
||||||
|
end
|
||||||
|
|
||||||
def following_not_possible?
|
def following_not_possible?
|
||||||
@target_account.nil? || @target_account.id == @source_account.id || @target_account.suspended?
|
@target_account.nil? || @target_account.id == @source_account.id || @target_account.suspended?
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
class MergeWorker
|
class MergeWorker
|
||||||
include Sidekiq::Worker
|
include Sidekiq::Worker
|
||||||
|
|
||||||
sidekiq_options queue: 'pull'
|
|
||||||
|
|
||||||
def perform(from_account_id, into_account_id)
|
def perform(from_account_id, into_account_id)
|
||||||
FeedManager.instance.merge_into_home(Account.find(from_account_id), Account.find(into_account_id))
|
FeedManager.instance.merge_into_home(Account.find(from_account_id), Account.find(into_account_id))
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
true
|
true
|
||||||
|
ensure
|
||||||
|
Redis.current.del("account:#{into_account_id}:regeneration")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue