def consume(self, event: Dict[str, Any]) -> None: try: if event.get("type", "add") == "remove": message_ids = event.get("message_ids") if message_ids is None: # TODO/compatibility: Previously, we sent only one `message_id` in # a payload for notification remove events. This was later changed # to send a list of `message_ids` (with that field name), but we need # compatibility code for events present in the queue during upgrade. # Remove this when one can no longer upgrade from 1.9.2 (or earlier) # to any version after 2.0.0 message_ids = [event["message_id"]] handle_remove_push_notification(event["user_profile_id"], message_ids) else: handle_push_notification(event["user_profile_id"], event) except PushNotificationBouncerRetryLaterError: def failure_processor(event: Dict[str, Any]) -> None: logger.warning( "Maximum retries exceeded for trigger:%s event:push_notification", event["user_profile_id"], ) retry_event(self.queue_name, event, failure_processor)
def consume(self, data: Mapping[str, Any]) -> None: if data.get("type", "add") == "remove": message_ids = data.get('message_ids') if message_ids is None: # legacy task across an upgrade message_ids = [data['message_id']] handle_remove_push_notification(data['user_profile_id'], message_ids) else: handle_push_notification(data['user_profile_id'], data)
def consume(self, event: Dict[str, Any]) -> None: try: if event.get("type", "add") == "remove": message_ids = event.get('message_ids') if message_ids is None: # legacy task across an upgrade message_ids = [event['message_id']] handle_remove_push_notification(event['user_profile_id'], message_ids) else: handle_push_notification(event['user_profile_id'], event) except PushNotificationBouncerRetryLaterError: def failure_processor(event: Dict[str, Any]) -> None: logger.warning( "Maximum retries exceeded for trigger:%s event:push_notification", event['user_profile_id']) retry_event(self.queue_name, event, failure_processor)
def consume(self, data: Mapping[str, Any]) -> None: if data.get("type", "add") == "remove": handle_remove_push_notification(data['user_profile_id'], data['message_id']) else: handle_push_notification(data['user_profile_id'], data)