Three quick fixes #10

Merged
nightpool merged 1 commits from quick_fixes into cybrespace 2019-06-15 19:08:40 +02:00
2 changed files with 14 additions and 1 deletions

View File

@ -90,7 +90,7 @@ class ActivityPub::Activity
crawl_links(status) crawl_links(status)
notify_about_reblog(status) if reblog_of_local_account?(status) notify_about_reblog(status) if reblog_of_local_account?(status)
notify_about_mentions(status) notify_about_mentions(status) unless spammy_mentions?(status)
# Only continue if the status is supposed to have arrived in real-time. # Only continue if the status is supposed to have arrived in real-time.
# Note that if @options[:override_timestamps] isn't set, the status # Note that if @options[:override_timestamps] isn't set, the status
@ -105,6 +105,11 @@ class ActivityPub::Activity
status.reblog? && status.reblog.account.local? status.reblog? && status.reblog.account.local?
end end
def spammy_mentions?(status)
status.has_non_mention_links? &&
@account.followers.local.count == 0
end
def notify_about_reblog(status) def notify_about_reblog(status)
NotifyService.new.call(status.reblog.account, status) NotifyService.new.call(status.reblog.account, status)
end end

View File

@ -431,6 +431,14 @@ class Status < ApplicationRecord
end end
end end
def has_non_mention_links?
if local?
text.match? %r{https?://\w}
else
Nokogiri::HTML.fragment(text).css('a:not(.mention)').present?
end
end
private private
def update_status_stat!(attrs) def update_status_stat!(attrs)