mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 08:56:10 +00:00
push_notifications: Shrink scope of try/except block.
There's no reason this needed to indent the entire function.
This commit is contained in:
@@ -497,14 +497,19 @@ def handle_push_notification(user_profile_id, missed_message):
|
||||
missed_message is the event received by the
|
||||
zerver.worker.queue_processors.PushNotificationWorker.consume function.
|
||||
"""
|
||||
try:
|
||||
user_profile = get_user_profile_by_id(user_profile_id)
|
||||
if not (receives_offline_notifications(user_profile) or
|
||||
receives_online_notifications(user_profile)):
|
||||
return
|
||||
|
||||
try:
|
||||
umessage = UserMessage.objects.get(user_profile=user_profile,
|
||||
message__id=missed_message['message_id'])
|
||||
except UserMessage.DoesNotExist:
|
||||
logging.error("Could not find UserMessage with message_id %s and user_id %s" % (
|
||||
missed_message['message_id'], user_profile_id))
|
||||
return
|
||||
|
||||
message = umessage.message
|
||||
message.trigger = missed_message['trigger']
|
||||
message.stream_name = missed_message.get('stream_name', None)
|
||||
@@ -529,7 +534,6 @@ def handle_push_notification(user_profile_id, missed_message):
|
||||
event['user_profile_id']))
|
||||
retry_event('missedmessage_mobile_notifications', missed_message,
|
||||
failure_processor)
|
||||
|
||||
return
|
||||
|
||||
android_devices = list(PushDeviceToken.objects.filter(user=user_profile,
|
||||
@@ -544,7 +548,3 @@ def handle_push_notification(user_profile_id, missed_message):
|
||||
|
||||
if android_devices:
|
||||
send_android_push_notification(android_devices, gcm_payload)
|
||||
|
||||
except UserMessage.DoesNotExist:
|
||||
logging.error("Could not find UserMessage with message_id %s and user_id %s" % (
|
||||
missed_message['message_id'], user_profile_id))
|
||||
|
||||
Reference in New Issue
Block a user