chore: Add a check to verify if the user exists before broadcasting the notification_deleted event. (#8678)

When a user is deleted, all associated notifications are also deleted from the database. As a result, the user record becomes empty. handling this case in code to prevent sentry errors.
This commit is contained in:
Muhsin Keloth
2024-01-12 06:24:03 +05:30
committed by GitHub
parent 810f950e16
commit 63b3686746

View File

@@ -8,6 +8,8 @@ class ActionCableListener < BaseListener
end
def notification_deleted(event)
return if event.data[:notification].user.blank?
notification, account, unread_count, count = extract_notification_and_account(event)
tokens = [event.data[:notification].user.pubsub_token]
broadcast(account, tokens, NOTIFICATION_DELETED, { notification: notification.push_event_data, unread_count: unread_count, count: count })