Chore: Fix failing sidekiq events for contact create (#966)

This commit is contained in:
Sojan Jose
2020-06-16 19:39:57 +05:30
committed by GitHub
parent b0bbd757b5
commit 04f6460afb
7 changed files with 21 additions and 15 deletions

View File

@@ -38,8 +38,8 @@ class Contact < ApplicationRecord
has_many :messages, dependent: :destroy
before_validation :downcase_email
after_create :dispatch_create_event
after_update :dispatch_update_event
after_create_commit :dispatch_create_event
after_update_commit :dispatch_update_event
def get_source_id(inbox_id)
contact_inboxes.find_by!(inbox_id: inbox_id).source_id

View File

@@ -41,8 +41,12 @@ class Notification::PushNotificationService
app_account_conversation_url(account_id: conversation.account_id, id: conversation.display_id)
end
def send_browser_push?(subscription)
ENV['VAPID_PUBLIC_KEY'] && subscription.browser_push?
end
def send_browser_push(subscription)
return unless subscription.browser_push?
return unless send_browser_push?(subscription)
Webpush.payload_send(
message: JSON.generate(push_message),
@@ -63,6 +67,7 @@ class Notification::PushNotificationService
end
def send_fcm_push(subscription)
return unless ENV['FCM_SERVER_KEY']
return unless subscription.fcm?
fcm = FCM.new(ENV['FCM_SERVER_KEY'])