From 62bafa20a112ccdddaedb25723fc819dbbcd8e9a Mon Sep 17 00:00:00 2001 From: ThibG Date: Mon, 1 Apr 2019 20:06:13 +0200 Subject: Hide blocking accounts from blocked users (#10442) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Revert "Add indication that you have been blocked in web UI (#10420)" This reverts commit bd02ec6daa974dcd3231e73826a56e08dbeedadc. * Revert "Add `blocked_by` relationship to the REST API (#10373)" This reverts commit 9745de883b198375ba23f7fde879f6d75ce2df0f. * Hide blocking accounts from search results * Filter blocking accouts from account followers * Filter blocking accouts from account's following accounts * Filter blocking accounts from “reblogged by” and “favourited by” lists * Remove blocking account from URL search * Return 410 on trying to fetch user data from a user who blocked us * Return 410 in /api/v1/account/statuses for suspended or blocking accounts * Fix status filtering when performing URL search * Restore some React improvements Restore some cleanup from bd02ec6daa974dcd3231e73826a56e08dbeedadc * Refactor by adding `without_blocking` scope --- app/services/account_search_service.rb | 10 +++++++++- app/services/search_service.rb | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'app/services') diff --git a/app/services/account_search_service.rb b/app/services/account_search_service.rb index 7bdffbbd2..c47b1c094 100644 --- a/app/services/account_search_service.rb +++ b/app/services/account_search_service.rb @@ -10,7 +10,15 @@ class AccountSearchService < BaseService @options = options @account = account - search_service_results + results = search_service_results + + unless account.nil? + account_ids = results.map(&:id) + blocked_by_map = Account.blocked_by_map(account_ids, account.id) + results.reject! { |item| blocked_by_map[item.id] } + end + + results end private diff --git a/app/services/search_service.rb b/app/services/search_service.rb index e0da61dac..a8442654c 100644 --- a/app/services/search_service.rb +++ b/app/services/search_service.rb @@ -12,6 +12,8 @@ class SearchService < BaseService default_results.tap do |results| if url_query? results.merge!(url_resource_results) unless url_resource.nil? + results[:accounts].reject! { |item| item.blocking?(@account) } + results[:statuses].reject! { |status| StatusFilter.new(status, @account).filtered? } elsif @query.present? results[:accounts] = perform_accounts_search! if account_searchable? results[:statuses] = perform_statuses_search! if full_text_searchable? -- cgit