forked from cybrespace/mastodon
don't send spammy mentions
This commit is contained in:
parent
4f9f95d38f
commit
5792d4daf5
|
@ -98,7 +98,7 @@ class ActivityPub::Activity
|
|||
crawl_links(status)
|
||||
|
||||
notify_about_reblog(status) if reblog_of_local_account?(status) && !reblog_by_following_group_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.
|
||||
# Note that if @options[:override_timestamps] isn't set, the status
|
||||
|
@ -117,6 +117,11 @@ class ActivityPub::Activity
|
|||
status.reblog? && status.account.group? && status.reblog.account.following?(status.account)
|
||||
end
|
||||
|
||||
def spammy_mentions?(status)
|
||||
status.has_non_mention_links? &&
|
||||
@account.followers.local.count == 0
|
||||
end
|
||||
|
||||
def notify_about_reblog(status)
|
||||
NotifyService.new.call(status.reblog.account, :reblog, status)
|
||||
end
|
||||
|
|
|
@ -351,6 +351,14 @@ class Status < ApplicationRecord
|
|||
super || build_status_stat
|
||||
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
|
||||
|
||||
def update_status_stat!(attrs)
|
||||
|
|
Loading…
Reference in New Issue