From 3377d00a6519faa2c358c3e2e2a3f5211aefe07a Mon Sep 17 00:00:00 2001 From: Robert George Date: Sun, 14 May 2023 13:31:47 -0700 Subject: [PATCH] Autoflag as spam is status contains url from blocked email domains --- app/services/fetch_link_card_service.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/services/fetch_link_card_service.rb b/app/services/fetch_link_card_service.rb index 9c56c862ec..3005224cec 100644 --- a/app/services/fetch_link_card_service.rb +++ b/app/services/fetch_link_card_service.rb @@ -78,6 +78,15 @@ class FetchLinkCardService < BaseService links.filter_map { |a| Addressable::URI.parse(a['href']) unless skip_link?(a) }.filter_map(&:normalize) end + url_hosts = urls.map(&:host) + unless EmailDomainBlock.where(domain: url_hosts).empty? + @report = ReportService.new.call( + Account.representative, + @status.account, + comment: 'Automatically flagged for malicious or spam link', category: :spam, forward: false, status_ids: [@status.id] + ) + end + urls.reject { |uri| bad_url?(uri) }.first end