Merge branch 'master' into glitch-soc/merge-upstream
This commit is contained in:
@ -2,16 +2,43 @@
|
||||
|
||||
class AfterBlockService < BaseService
|
||||
def call(account, target_account)
|
||||
FeedManager.instance.clear_from_timeline(account, target_account)
|
||||
clear_home_feed(account, target_account)
|
||||
clear_notifications(account, target_account)
|
||||
clear_conversations(account, target_account)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def clear_home_feed(account, target_account)
|
||||
FeedManager.instance.clear_from_timeline(account, target_account)
|
||||
end
|
||||
|
||||
def clear_conversations(account, target_account)
|
||||
AccountConversation.where(account: account)
|
||||
.where('? = ANY(participant_account_ids)', target_account.id)
|
||||
.in_batches
|
||||
.destroy_all
|
||||
end
|
||||
|
||||
def clear_notifications(account, target_account)
|
||||
Notification.where(account: account).joins(:follow).where(activity_type: 'Follow', follows: { account_id: target_account.id }).delete_all
|
||||
Notification.where(account: account).joins(mention: :status).where(activity_type: 'Mention', statuses: { account_id: target_account.id }).delete_all
|
||||
Notification.where(account: account).joins(:favourite).where(activity_type: 'Favourite', favourites: { account_id: target_account.id }).delete_all
|
||||
Notification.where(account: account).joins(:status).where(activity_type: 'Status', statuses: { account_id: target_account.id }).delete_all
|
||||
Notification.where(account: account)
|
||||
.joins(:follow)
|
||||
.where(activity_type: 'Follow', follows: { account_id: target_account.id })
|
||||
.delete_all
|
||||
|
||||
Notification.where(account: account)
|
||||
.joins(mention: :status)
|
||||
.where(activity_type: 'Mention', statuses: { account_id: target_account.id })
|
||||
.delete_all
|
||||
|
||||
Notification.where(account: account)
|
||||
.joins(:favourite)
|
||||
.where(activity_type: 'Favourite', favourites: { account_id: target_account.id })
|
||||
.delete_all
|
||||
|
||||
Notification.where(account: account)
|
||||
.joins(:status)
|
||||
.where(activity_type: 'Status', statuses: { account_id: target_account.id })
|
||||
.delete_all
|
||||
end
|
||||
end
|
||||
|
@ -13,6 +13,7 @@ class FanOutOnWriteService < BaseService
|
||||
if status.direct_visibility?
|
||||
deliver_to_mentioned_followers(status)
|
||||
deliver_to_direct_timelines(status)
|
||||
deliver_to_own_conversation(status)
|
||||
else
|
||||
deliver_to_followers(status)
|
||||
deliver_to_lists(status)
|
||||
@ -99,6 +100,11 @@ class FanOutOnWriteService < BaseService
|
||||
status.mentions.includes(:account).each do |mention|
|
||||
Redis.current.publish("timeline:direct:#{mention.account.id}", @payload) if mention.account.local?
|
||||
end
|
||||
|
||||
Redis.current.publish("timeline:direct:#{status.account.id}", @payload) if status.account.local?
|
||||
end
|
||||
|
||||
def deliver_to_own_conversation(status)
|
||||
AccountConversation.add_status(status.account, status)
|
||||
end
|
||||
end
|
||||
|
@ -5,11 +5,13 @@ class MuteService < BaseService
|
||||
return if account.id == target_account.id
|
||||
|
||||
mute = account.mute!(target_account, notifications: notifications)
|
||||
|
||||
if mute.hide_notifications?
|
||||
BlockWorker.perform_async(account.id, target_account.id)
|
||||
else
|
||||
FeedManager.instance.clear_from_timeline(account, target_account)
|
||||
MuteWorker.perform_async(account.id, target_account.id)
|
||||
end
|
||||
|
||||
mute
|
||||
end
|
||||
end
|
||||
|
@ -8,9 +8,10 @@ class NotifyService < BaseService
|
||||
|
||||
return if recipient.user.nil? || blocked?
|
||||
|
||||
create_notification
|
||||
push_notification if @notification.browserable?
|
||||
send_email if email_enabled?
|
||||
create_notification!
|
||||
push_notification! if @notification.browserable?
|
||||
push_to_conversation! if direct_message?
|
||||
send_email! if email_enabled?
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
return
|
||||
end
|
||||
@ -100,18 +101,23 @@ class NotifyService < BaseService
|
||||
end
|
||||
end
|
||||
|
||||
def create_notification
|
||||
def create_notification!
|
||||
@notification.save!
|
||||
end
|
||||
|
||||
def push_notification
|
||||
def push_notification!
|
||||
return if @notification.activity.nil?
|
||||
|
||||
Redis.current.publish("timeline:#{@recipient.id}", Oj.dump(event: :notification, payload: InlineRenderer.render(@notification, @recipient, :notification)))
|
||||
send_push_notifications
|
||||
send_push_notifications!
|
||||
end
|
||||
|
||||
def send_push_notifications
|
||||
def push_to_conversation!
|
||||
return if @notification.activity.nil?
|
||||
AccountConversation.add_status(@recipient, @notification.target_status)
|
||||
end
|
||||
|
||||
def send_push_notifications!
|
||||
subscriptions_ids = ::Web::PushSubscription.where(user_id: @recipient.user.id)
|
||||
.select { |subscription| subscription.pushable?(@notification) }
|
||||
.map(&:id)
|
||||
@ -121,7 +127,7 @@ class NotifyService < BaseService
|
||||
end
|
||||
end
|
||||
|
||||
def send_email
|
||||
def send_email!
|
||||
return if @notification.activity.nil?
|
||||
NotificationMailer.public_send(@notification.type, @recipient, @notification).deliver_later(wait: 2.minutes)
|
||||
end
|
||||
|
Reference in New Issue
Block a user