Blocking will prevent e-mail notifications from blocked user, blocks in UI

This commit is contained in:
Eugen Rochko
2016-10-03 18:49:52 +02:00
parent 7b9a4af311
commit 70e9dd0b5b
12 changed files with 134 additions and 32 deletions

View File

@ -8,7 +8,7 @@ class FavouriteService < BaseService
account.ping!(account_url(account, format: 'atom'), [Rails.configuration.x.hub_url])
if status.local?
NotificationMailer.favourite(status, account).deliver_later
NotificationMailer.favourite(status, account).deliver_later unless status.account.blocking?(account)
else
NotificationWorker.perform_async(favourite.stream_entry.id, status.account_id)
end

View File

@ -10,7 +10,7 @@ class FollowService < BaseService
follow = source_account.follow!(target_account)
if target_account.local?
NotificationMailer.follow(target_account, source_account).deliver_later
NotificationMailer.follow(target_account, source_account).deliver_later unless target_account.blocking?(source_account)
else
subscribe_service.call(target_account)
NotificationWorker.perform_async(follow.stream_entry.id, target_account.id)

View File

@ -69,7 +69,7 @@ class ProcessFeedService < BaseService
unless mentioned_account.nil?
mentioned_account.mentions.where(status: status).first_or_create(status: status)
NotificationMailer.mention(mentioned_account, status).deliver_later
NotificationMailer.mention(mentioned_account, status).deliver_later unless mentioned_account.blocking?(status.account)
end
else
# What to do about remote user?
@ -114,7 +114,7 @@ class ProcessFeedService < BaseService
if !status.reblog.nil?
status.save!
NotificationMailer.reblog(status.reblog, status.account).deliver_later if status.reblog.local?
NotificationMailer.reblog(status.reblog, status.account).deliver_later if status.reblog.local? && !status.reblog.account.blocking?(status.account)
end
end

View File

@ -58,7 +58,7 @@ class ProcessInteractionService < BaseService
def follow!(account, target_account)
account.follow!(target_account)
NotificationMailer.follow(target_account, account).deliver_later
NotificationMailer.follow(target_account, account).deliver_later unless target_account.blocking?(account)
end
def unfollow!(account, target_account)
@ -78,7 +78,7 @@ class ProcessInteractionService < BaseService
def favourite!(xml, from_account)
current_status = status(xml)
current_status.favourites.where(account: from_account).first_or_create!(account: from_account)
NotificationMailer.favourite(current_status, from_account).deliver_later
NotificationMailer.favourite(current_status, from_account).deliver_later unless current_status.account.blocking?(from_account)
end
def add_post!(body, account)

View File

@ -27,7 +27,7 @@ class ProcessMentionsService < BaseService
mentioned_account = mention.account
if mentioned_account.local?
NotificationMailer.mention(mentioned_account, status).deliver_later
NotificationMailer.mention(mentioned_account, status).deliver_later unless mentioned_account.blocking?(status.account)
else
NotificationWorker.perform_async(status.stream_entry.id, mentioned_account.id)
end

View File

@ -9,7 +9,7 @@ class ReblogService < BaseService
account.ping!(account_url(account, format: 'atom'), [Rails.configuration.x.hub_url])
if reblogged_status.local?
NotificationMailer.reblog(reblogged_status, account).deliver_later
NotificationMailer.reblog(reblogged_status, account).deliver_later unless reblogged_status.account.blocking?(account)
else
NotificationWorker.perform_async(reblog.stream_entry.id, reblogged_status.account_id)
end