Compare commits

...
Sign in to create a new pull request.

3 commits

Author SHA1 Message Date
34ff641f0b don't send spammy mentions 2019-10-12 16:09:51 -07:00
13fc93fa63 show warning message for locked account 2019-10-12 16:09:17 -07:00
84bf5ca175 Use git commit hash as part of the cache key
avoids issues with model caching being incompatible across versions
2019-10-12 16:09:11 -07:00
5 changed files with 26 additions and 2 deletions

View file

@ -298,6 +298,12 @@
min-height: 1px;
}
h2 {
font-size: 1rem;
align-items: center;
display: flex;
}
.nav-left {
display: flex;
align-items: stretch;

View file

@ -90,7 +90,7 @@ class ActivityPub::Activity
crawl_links(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.
# Note that if @options[:override_timestamps] isn't set, the status
@ -105,6 +105,11 @@ class ActivityPub::Activity
status.reblog? && status.reblog.account.local?
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, status)
end

View file

@ -398,6 +398,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)

View file

@ -21,6 +21,11 @@
= render 'header', account: @account, with_bio: true
- if @account.user&.disabled?
.header
.nav-center
%h2 This user's account has been locked by a moderator.
.grid
.column-0
.h-feed

View file

@ -22,7 +22,7 @@ setup_redis_env_url
setup_redis_env_url(:cache, false)
namespace = ENV.fetch('REDIS_NAMESPACE') { nil }
cache_namespace = namespace ? namespace + '_cache' : 'cache'
cache_namespace = [namespace, 'cache', `git rev-parse --short HEAD`.strip].compact.join('_')
REDIS_CACHE_PARAMS = {
expires_in: 10.minutes,