From 5b4661c2f71f003b2301e5c29b0d4c87af987f1f Mon Sep 17 00:00:00 2001 From: KMY Date: Thu, 6 Apr 2023 10:06:56 +0900 Subject: [PATCH] Fix mention_urls error --- app/lib/activitypub/tag_manager.rb | 20 +++++++++++++++++++ app/services/search_service.rb | 2 +- ...405121625_add_searchability_to_accounts.rb | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/lib/activitypub/tag_manager.rb b/app/lib/activitypub/tag_manager.rb index 2d8e9b5008..4ff3567c8e 100644 --- a/app/lib/activitypub/tag_manager.rb +++ b/app/lib/activitypub/tag_manager.rb @@ -212,4 +212,24 @@ class ActivityPub::TagManager [] end end + + def mentions_uris(status) + if status.account.silenced? + # Only notify followers if the account is locally silenced + account_ids = status.active_mentions.pluck(:account_id) + uris = status.account.followers.where(id: account_ids).each_with_object([]) do |account, result| + result << uri_for(account) + result << account_followers_url(account) if account.group? + end + uris.concat(FollowRequest.where(target_account_id: status.account_id, account_id: account_ids).each_with_object([]) do |request, result| + result << uri_for(request.account) + result << account_followers_url(request.account) if request.account.group? + end) + else + status.active_mentions.each_with_object([]) do |mention, result| + result << uri_for(mention.account) + result << account_followers_url(mention.account) if mention.account.group? + end + end + end end diff --git a/app/services/search_service.rb b/app/services/search_service.rb index 2de78d8d2f..94037e8566 100644 --- a/app/services/search_service.rb +++ b/app/services/search_service.rb @@ -42,7 +42,7 @@ class SearchService < BaseService case @searchability when 'public' privacy_definition = privacy_definition.or(StatusesIndex.filter(term: { searchability: 'public' })) - privacy_definition = privacy_definition.or(StatusesIndex.filter(terms: { searchability: %w(unlisted) }).filter(terms: { account_id: following_account_ids })) unless following_account_ids.empty? + privacy_definition = privacy_definition.or(StatusesIndex.filter(term: { searchability: 'unlisted' }).filter(terms: { account_id: following_account_ids })) unless following_account_ids.empty? privacy_definition = privacy_definition.or(StatusesIndex.filter(term: { searchability: 'direct' }).filter(term: { account_id: @account.id })) when 'unlisted', 'private' privacy_definition = privacy_definition.or(StatusesIndex.filter(terms: { searchability: %w(public unlisted) }).filter(terms: { account_id: following_account_ids })) unless following_account_ids.empty? diff --git a/db/migrate/20230405121625_add_searchability_to_accounts.rb b/db/migrate/20230405121625_add_searchability_to_accounts.rb index 758d052993..9af68545e3 100644 --- a/db/migrate/20230405121625_add_searchability_to_accounts.rb +++ b/db/migrate/20230405121625_add_searchability_to_accounts.rb @@ -1,5 +1,5 @@ class AddSearchabilityToAccounts < ActiveRecord::Migration[6.1] def change - add_column :accounts, :searchability, :integer, null: false, default: 0 + add_column :accounts, :searchability, :integer, null: false, default: 3 end end