1
0
Fork 0
forked from gitea/nas

#66 検索時のフォロー中アカウント一覧作成処理を改善

This commit is contained in:
KMY 2023-10-07 18:47:32 +09:00
parent 583f5fe906
commit 22d1f52597
7 changed files with 90 additions and 5 deletions

View file

@ -157,6 +157,9 @@ class Status < ApplicationRecord
after_create_commit :store_uri, if: :local?
after_create_commit :update_statistics, if: :local?
after_create_commit :set_searchable_follow_on_create
after_destroy_commit :set_searchable_follow_on_destroy
before_validation :prepare_contents, if: :local?
before_validation :set_reblog
before_validation :set_visibility
@ -670,6 +673,21 @@ class Status < ApplicationRecord
ActivityTracker.increment('activity:statuses:local')
end
def set_searchable_follow_on_create
return unless public_searchability? || public_unlisted_searchability? || private_searchability?
return if account.account_stat.nil? || account.account_stat.searchable_by_follower
account.account_stat.update(searchable_by_follower: true)
end
def set_searchable_follow_on_destroy
return unless public_searchability? || public_unlisted_searchability? || private_searchability?
return if account.account_stat.nil? || !account.account_stat.searchable_by_follower
return if account.statuses.exists?(searchability: %i(public public_unlisted unlisted private))
account.account_stat.update(searchable_by_follower: false)
end
def increment_counter_caches
return if direct_visibility?