Merge commit '9ffe6817e0' into kb_migration

This commit is contained in:
KMY 2023-05-25 09:03:06 +09:00
commit db5c358f4f
54 changed files with 155 additions and 79 deletions

View file

@ -480,6 +480,8 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
nil
elsif audience_searchable_by.any? { |uri| ActivityPub::TagManager.instance.public_collection?(uri) }
:public
elsif audience_searchable_by.include?('as:Limited')
:limited
elsif audience_searchable_by.include?(@account.followers_url)
:private
else
@ -502,17 +504,17 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
searchability = searchability_bio[0]
return nil if searchability.nil?
searchability = :public if searchability == 'public'
searchability = :unlisted if searchability == 'followers'
searchability = :direct if searchability == 'private'
searchability = :private if searchability == 'reactors'
searchability = :public if searchability == 'public'
searchability = :private if searchability == 'followers'
searchability = :limited if searchability == 'private'
searchability = :direct if searchability == 'reactors'
end
visibility = visibility_from_audience_with_silence
if searchability == visibility
if searchability == visibility || searchability == :limited || searchability == :direct
searchability
elsif [:public, :unlisted, :private].include?(searchability) && [:public, :unlisted, :private].include?(visibility)
elsif [:public, :unlisted, :private].include?(searchability) && [:public, :public_unlisted, :unlisted, :login, :private].include?(visibility)
:private
else
:direct
@ -524,6 +526,8 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
:public
elsif audience_cc.any? { |cc| ActivityPub::TagManager.instance.public_collection?(cc) }
:unlisted
elsif audience_cc.include?('as:LoginOnly')
:login
elsif audience_to.include?(@account.followers_url)
:private
else

View file

@ -77,6 +77,8 @@ class ActivityPub::Parser::StatusParser
:public
elsif audience_cc.any? { |cc| ActivityPub::TagManager.instance.public_collection?(cc) }
:unlisted
elsif audience_cc.include?('as:LoginOnly')
:login
elsif audience_to.include?(@magic_values[:followers_collection])
:private
else

View file

@ -90,7 +90,7 @@ class ActivityPub::TagManager
case status.visibility
when 'public'
[COLLECTIONS[:public]]
when 'unlisted', 'public_unlisted', 'private'
when 'unlisted', 'public_unlisted', 'login', 'private'
[account_followers_url(status.account)]
when 'direct', 'limited'
if status.account.silenced?
@ -128,6 +128,8 @@ class ActivityPub::TagManager
cc << account_followers_url(status.account)
when 'unlisted', 'public_unlisted'
cc << COLLECTIONS[:public]
when 'login'
cc << 'as:LoginOnly'
end
cc + cc_private_visibility(status)
@ -221,6 +223,8 @@ class ActivityPub::TagManager
[account_followers_url(status.account)]
when 'direct'
status.conversation_id.present? ? [uri_for(status.conversation)] : []
when 'limited'
['as:Limited']
else
[]
end
@ -234,6 +238,8 @@ class ActivityPub::TagManager
[COLLECTIONS[:public]]
when 'private', 'direct'
[account_followers_url(account)]
when 'limited'
['as:Limited']
else
[]
end

View file

@ -109,7 +109,7 @@ class FeedManager
def merge_into_home(from_account, into_account)
timeline_key = key(:home, into_account.id)
aggregate = into_account.user&.aggregates_reblogs?
query = from_account.statuses.where(visibility: [:public, :unlisted, :public_unlisted, :private]).includes(:preloadable_poll, :media_attachments, reblog: :account).limit(FeedManager::MAX_ITEMS / 4)
query = from_account.statuses.where(visibility: [:public, :unlisted, :public_unlisted, :login, :private]).includes(:preloadable_poll, :media_attachments, reblog: :account).limit(FeedManager::MAX_ITEMS / 4)
if redis.zcard(timeline_key) >= FeedManager::MAX_ITEMS / 4
oldest_home_score = redis.zrange(timeline_key, 0, 0, with_scores: true).first.last.to_i
@ -135,7 +135,7 @@ class FeedManager
def merge_into_list(from_account, list)
timeline_key = key(:list, list.id)
aggregate = list.account.user&.aggregates_reblogs?
query = from_account.statuses.where(visibility: [:public, :unlisted, :public_unlisted, :private]).includes(:preloadable_poll, :media_attachments, reblog: :account).limit(FeedManager::MAX_ITEMS / 4)
query = from_account.statuses.where(visibility: [:public, :unlisted, :public_unlisted, :login, :private]).includes(:preloadable_poll, :media_attachments, reblog: :account).limit(FeedManager::MAX_ITEMS / 4)
if redis.zcard(timeline_key) >= FeedManager::MAX_ITEMS / 4
oldest_home_score = redis.zrange(timeline_key, 0, 0, with_scores: true).first.last.to_i
@ -253,7 +253,7 @@ class FeedManager
next if last_status_score < oldest_home_score
end
statuses = target_account.statuses.where(visibility: [:public, :unlisted, :public_unlisted, :private]).includes(:preloadable_poll, :media_attachments, :account, reblog: :account).limit(limit)
statuses = target_account.statuses.where(visibility: [:public, :unlisted, :public_unlisted, :login, :private]).includes(:preloadable_poll, :media_attachments, :account, reblog: :account).limit(limit)
crutches = build_crutches(account.id, statuses)
statuses.each do |status|