diff options
author | pluralcafe-docker <git@plural.cafe> | 2018-10-13 01:09:02 +0000 |
---|---|---|
committer | pluralcafe-docker <git@plural.cafe> | 2018-10-13 01:09:02 +0000 |
commit | 7c96ee7815c216d6ac3b748d7dd6959376d3914e (patch) | |
tree | fd36bade02afa1536198e7f3beafb208973b68c5 /app/services/notify_service.rb | |
parent | f9275cb762a311cbf298b3929552a153703c0726 (diff) | |
parent | 70d346ea951ebfa002225759310d72882a435a5c (diff) |
Merge branch 'glitch'
Diffstat (limited to 'app/services/notify_service.rb')
-rw-r--r-- | app/services/notify_service.rb | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/app/services/notify_service.rb b/app/services/notify_service.rb index 7d0dcc7ad..63bf8f17a 100644 --- a/app/services/notify_service.rb +++ b/app/services/notify_service.rb @@ -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 |