def enviar_notificacao(notificacao): onesignal_client = onesignal_sdk.Client( user_auth_key=settings.ONESIGNAL_AUTH_ID, app={ 'app_auth_key': settings.ONESIGNAL_API_KEY, 'app_id': settings.ONESIGNAL_APP_ID }) # create a notification nova_notificacao = onesignal_sdk.Notification( contents={ 'en': notificacao['mensagem'], 'pt-br': notificacao['mensagem'] }) nova_notificacao.set_parameter('headings', { 'en': notificacao['titulo'], 'pt-br': notificacao['titulo'] }) nova_notificacao.set_parameter('url', settings.APP_URL + notificacao['url']) nova_notificacao.set_target_devices([notificacao['user_id']]) # send notification, it will return a response onesignal_response = onesignal_client.send_notification(nova_notificacao) print(onesignal_response.status_code) print(onesignal_response.json())
def send_community_new_post_push_notification(community_notifications_subscription): community_name = community_notifications_subscription.community.name target_user = community_notifications_subscription.subscriber if target_user.has_community_new_post_notifications_enabled(): target_user_language_code = get_notification_language_code_for_target_user(target_user) with translation.override(target_user_language_code): one_signal_notification = onesignal_sdk.Notification( post_body={"contents": {"en": _('A new post was posted in c/%(community_name)s.') % { 'community_name': community_name, }}}) Notification = get_notification_model() notification_data = { 'type': Notification.COMMUNITY_NEW_POST, } notification_group = NOTIFICATION_GROUP_HIGH_PRIORITY one_signal_notification.set_parameter('data', notification_data) one_signal_notification.set_parameter('!thread_id', notification_group) one_signal_notification.set_parameter('android_group', notification_group) _send_notification_to_user(notification=one_signal_notification, user=target_user)
def send_follow_request_push_notification(follow_request): follow_requester = follow_request.creator follow_request_target_user = follow_request.target_user if follow_request_target_user.has_follow_request_notifications_enabled(): target_user_language_code = get_notification_language_code_for_target_user(follow_request_target_user) with translation.override(target_user_language_code): one_signal_notification = onesignal_sdk.Notification( post_body={"contents": {"en": _( '%(follow_requester_name)s · @%(follow_requester_username)s wants to follow you.') % { 'follow_requester_username': follow_requester.username, 'follow_requester_name': follow_requester.profile.name, }}}) Notification = get_notification_model() notification_data = { 'type': Notification.FOLLOW_REQUEST, } notification_group = NOTIFICATION_GROUP_MEDIUM_PRIORITY one_signal_notification.set_parameter('data', notification_data) one_signal_notification.set_parameter('!thread_id', notification_group) one_signal_notification.set_parameter('android_group', notification_group) _send_notification_to_user(user=follow_request_target_user, notification=one_signal_notification)
def send_match_notification_to_users(user_target, notify_users): header = _('New Match!') msg = _('Congrats! You have a match with user ' f'{user_target.name}!') new_notification = onesignal_sdk.Notification({"en": msg}) new_notification.set_parameter("headings", {"en": header}) new_notification.set_parameter("include_player_ids", notify_users) onesignal_client.send_notification(new_notification)
def send_notification(text): onesignal_client = onesignal.Client(app_auth_key="N2E4NTNkNzAtYjhjYi00ZTI0LWIzZWUtYTM1YmIyMmQxNzE4", app_id="1784a5bd-7107-4bda-b628-a19c2034159e") new_notification = onesignal.Notification(post_body={"contents": {"en": text}}) new_notification.post_body["included_segments"] = ["Active Users"] new_notification.post_body["headings"] = {"en": "Din Dong!"} onesignal_client.send_notification(new_notification)
def parent_new_lesson_notification(parent, child, lesson): """ Used to send parents notifications about children assigned lessons. :param parent: :param child: :param lesson: :return: """ onesignal_client = onesignal_sdk.Client(user_auth_key=settings.PARENT_ONESIGNAL_AUTH_KEY, app={"app_auth_key": settings.PARENT_ONESIGNAL_REST_KEY, "app_id": settings.PARENT_ONESIGNAL_APP_ID}) # create a notification new_notification = onesignal_sdk.Notification() new_notification.set_parameter("contents", { "en": "{} {} has been assigned lesson: {}.".format(child.first_name, child.last_name, lesson.lesson_name)}) new_notification.set_parameter("headings", {"en": "MOTUS: New assigned lesson!"}) new_notification.set_parameter("template_id", settings.PARENT_ONESIGNAL_NEW_LESSON_TEMPLATE_ID) # set filters new_notification.set_filters([{"field": "tag", "key": "id", "relation": "=", "value": str(parent.profile.user_id)}]) # send notification, it will return a response onesignal_response = onesignal_client.send_notification(new_notification) print(onesignal_response.status_code) print(onesignal_response.json())
def inform_admins(new_user): pass admins = ["*****@*****.**", "*****@*****.**"] try: onesignal_client = configure_onesignal() message = u"{} hat sich soeben neu angemeldet!".format( new_user.user_email) # create a notification push_notification = onesignal_sdk.Notification( contents={"en": message}) push_notification.set_parameter("headings", {"en": "Neuer User"}) target_devices_array = [] for admin_mail in admins: admin_push_id = User.select().where( User.user_email == admin_mail).get().player_id print admin_push_id target_devices_array.append(admin_push_id) #target_devices_array.append(user.player_id) #print target_devices_array push_notification.set_target_devices(target_devices_array) # send notification, it will return a response onesignal_response = onesignal_client.send_notification( push_notification) #print(onesignal_response.status_code) print(onesignal_response.json()) except: return False
def send_post_reaction_push_notification(post_reaction): post_creator = post_reaction.post.creator post_id = post_reaction.post_id notification_group = 'post_%s' % post_id if post_creator.has_reaction_notifications_enabled_for_post_with_id(post_id=post_reaction.post_id): post_reactor = post_reaction.reactor one_signal_notification = onesignal_sdk.Notification(post_body={ "contents": {"en": _('@%(post_reactor_username)s reacted to your post.') % { 'post_reactor_username': post_reactor.username }} }) NotificationPostReactionSerializer = _get_push_notifications_serializers().NotificationPostReactionSerializer Notification = get_notification_model() notification_data = { 'type': Notification.POST_REACTION, 'payload': NotificationPostReactionSerializer(post_reaction).data } one_signal_notification.set_parameter('data', notification_data) one_signal_notification.set_parameter('!thread_id', notification_group) one_signal_notification.set_parameter('android_group', notification_group) _send_notification_to_user(notification=one_signal_notification, user=post_creator)
def send_community_invite_push_notification(community_invite): invited_user = community_invite.invited_user if invited_user.has_community_invite_notifications_enabled(): invite_creator = community_invite.creator community = community_invite.community one_signal_notification = onesignal_sdk.Notification( post_body={"en": _('@%(invite_creator)s has invited you to join /c/%(community_name)s.') % { 'invite_creator': invite_creator.username, 'community_name': community.name, }}) NotificationCommunityInviteSerializer = _get_push_notifications_serializers().NotificationCommunityInviteSerializer Notification = get_notification_model() notification_data = { 'type': Notification.COMMUNITY_INVITE, 'payload': NotificationCommunityInviteSerializer(community_invite).data } one_signal_notification.set_parameter('data', notification_data) _send_notification_to_user(notification=one_signal_notification, user=invited_user)
def send_follow_push_notification(followed_user, following_user): if followed_user.has_follow_notifications_enabled(): one_signal_notification = onesignal_sdk.Notification( post_body={ "contents": { "en": _('@%(following_user_username)s started following you') % { 'following_user_username': following_user.username } } }) FollowNotificationSerializer = _get_push_notifications_serializers( ).FollowNotificationSerializer Notification = get_notification_model() notification_data = { 'type': Notification.FOLLOW, 'payload': FollowNotificationSerializer({ 'following_user': following_user }).data } one_signal_notification.set_parameter('data', notification_data) _send_notification_to_user(notification=one_signal_notification, user=followed_user)
def send_post_comment_push_notification_with_message(post_comment, message, target_user): Notification = get_notification_model() NotificationPostCommentSerializer = _get_push_notifications_serializers( ).NotificationPostCommentSerializer post = post_comment.post notification_payload = NotificationPostCommentSerializer(post_comment).data notification_group = 'post_%s' % post.id one_signal_notification = onesignal_sdk.Notification( post_body={"contents": message}) notification_data = { 'type': Notification.POST_COMMENT, 'payload': notification_payload } one_signal_notification.set_parameter('data', notification_data) one_signal_notification.set_parameter('!thread_id', notification_group) one_signal_notification.set_parameter('android_group', notification_group) _send_notification_to_user(notification=one_signal_notification, user=target_user)
def send_connection_request_push_notification(connection_requester, connection_requested_for): if connection_requested_for.has_connection_request_notifications_enabled(): one_signal_notification = onesignal_sdk.Notification( post_body={ "en": _('@%(connection_requester_username)s wants to connect with you.' ) % { 'connection_requester_username': connection_requester.username } }) ConnectionRequestNotificationSerializer = _get_push_notifications_serializers( ).ConnectionRequestNotificationSerializer Notification = get_notification_model() notification_data = { 'type': Notification.CONNECTION_REQUEST, 'payload': ConnectionRequestNotificationSerializer({ 'connection_requester': connection_requester }).data } one_signal_notification.set_parameter('data', notification_data) _send_notification_to_user( user=connection_requested_for, notification=one_signal_notification, )
def main(): items = getLimiteds() for x in items: known = False for y in knownItems: if x["Name"] == y["Name"]: known = True break if not known: knownItems.append(x) print(x["Name"]) global currentNotify currentNotify = x new_notification = onesignal_sdk.Notification( contents={"en": x["Name"]}) new_notification.set_parameter( "headings", {"en": "New " + x["LimitedAltText"]}) new_notification.set_included_segments(["Active Users"]) onesignal_response = onesignal_client.send_notification( new_notification) # ToastNotifier().show_toast(x["Name"], "New Limited!", icon_path=None, duration=5, threaded=True, # callback_on_click=click) return
def parent_appointment_notification(parent, professional, appointment, booked): """ Used to send parents notifications about children assigned lessons. :param parent: :param child: :param lesson: :return: """ onesignal_client = onesignal_sdk.Client(user_auth_key=settings.PARENT_ONESIGNAL_AUTH_KEY, app={"app_auth_key": settings.PARENT_ONESIGNAL_REST_KEY, "app_id": settings.PARENT_ONESIGNAL_APP_ID}) # create a notification new_notification = onesignal_sdk.Notification() new_notification.set_parameter("contents", { "en": "Appointment with {} on {} from {} to {}, has been {}.".format(professional.profile.full_name, appointment.date.strftime('%m/%d/%Y'), appointment.start_time, appointment.end_time, booked)}) new_notification.set_parameter("headings", {"en": "MOTUS: Appointment {}".format(booked)}) new_notification.set_parameter("template_id", settings.PARENT_ONESIGNAL_APPOINTMENT_TEMPLATE_ID) # set filters new_notification.set_filters([{"field": "tag", "key": "id", "relation": "=", "value": str(parent.profile.user_id)}]) # send notification, it will return a response onesignal_response = onesignal_client.send_notification(new_notification) print(onesignal_response.status_code) print(onesignal_response.json())
def send_post_user_mention_push_notification(post_user_mention): mentioned_user = post_user_mention.user if not mentioned_user.has_post_mention_notifications_enabled(): return notification_group = NOTIFICATION_GROUP_MEDIUM_PRIORITY mentioner = post_user_mention.post.creator target_user_language_code = get_notification_language_code_for_target_user(mentioned_user) with translation.override(target_user_language_code): one_signal_notification = onesignal_sdk.Notification(post_body={ "contents": { "en": _( '%(mentioner_name)s · @%(mentioner_username)s mentioned you in a post.') % { 'mentioner_name': mentioner.profile.name, 'mentioner_username': mentioner.username, }} }) Notification = get_notification_model() notification_data = { 'type': Notification.POST_USER_MENTION, } one_signal_notification.set_parameter('data', notification_data) one_signal_notification.set_parameter('!thread_id', notification_group) one_signal_notification.set_parameter('android_group', notification_group) _send_notification_to_user(notification=one_signal_notification, user=mentioned_user)
def professional_resource_notification(data): """ Used to send professional notifications about new resources :param data: List of professional user IDs :return: """ filter_list = list() for i, item in enumerate(data): if i < len(data) - 1: filter_list.append({"field": "tag", "key": "id", "relation": "=", "value": str(item)}) filter_list.append({"operator": "OR"}) else: filter_list.append({"field": "tag", "key": "id", "relation": "=", "value": str(item)}) onesignal_client = onesignal_sdk.Client(user_auth_key=settings.PROFESSIONAL_ONESIGNAL_AUTH_KEY, app={"app_auth_key": settings.PROFESSIONAL_ONESIGNAL_REST_KEY, "app_id": settings.PROFESSIONAL_ONESIGNAL_APP_ID}) # create a notification new_notification = onesignal_sdk.Notification() new_notification.set_parameter("template_id", settings.PROFESSIONAL_ONESIGNAL_RESOURCES_TEMPLATE_ID) # set filters new_notification.set_filters(filter_list) # send notification, it will return a response onesignal_response = onesignal_client.send_notification(new_notification) print(onesignal_response.status_code) print(onesignal_response.json())
def send_follow_push_notification(followed_user, following_user): if followed_user.has_follow_notifications_enabled(): target_user_language_code = get_notification_language_code_for_target_user( followed_user) with translation.override(target_user_language_code): one_signal_notification = onesignal_sdk.Notification( post_body={ "contents": { "en": _('%(following_user_name)s · @%(following_user_username)s started following you' ) % { 'following_user_name': following_user.profile.name, 'following_user_username': following_user.username, } } }) Notification = get_notification_model() notification_data = { 'type': Notification.FOLLOW, } one_signal_notification.set_parameter('data', notification_data) _send_notification_to_user(notification=one_signal_notification, user=followed_user)
def send_community_invite_push_notification(community_invite): invited_user = community_invite.invited_user if invited_user.has_community_invite_notifications_enabled(): invite_creator = community_invite.creator community = community_invite.community target_user_language_code = get_notification_language_code_for_target_user(invited_user) with translation.override(target_user_language_code): one_signal_notification = onesignal_sdk.Notification( post_body={"contents": {"en": _( '%(invite_creator_name)s · @%(invite_creator_username)s has invited you to join c/%(community_name)s.') % { 'invite_creator_username': invite_creator.username, 'invite_creator_name': invite_creator.profile.name, 'community_name': community.name, }}}) Notification = get_notification_model() notification_data = { 'type': Notification.COMMUNITY_INVITE, } notification_group = NOTIFICATION_GROUP_MEDIUM_PRIORITY one_signal_notification.set_parameter('data', notification_data) one_signal_notification.set_parameter('!thread_id', notification_group) one_signal_notification.set_parameter('android_group', notification_group) _send_notification_to_user(notification=one_signal_notification, user=invited_user)
def send_connection_request_push_notification(connection_requester, connection_requested_for): if connection_requested_for.has_connection_request_notifications_enabled(): target_user_language_code = get_notification_language_code_for_target_user( connection_requested_for) with translation.override(target_user_language_code): one_signal_notification = onesignal_sdk.Notification( post_body={ "contents": { "en": _('%(connection_requester_name)s · @%(connection_requester_username)s wants to connect with you.' ) % { 'connection_requester_username': connection_requester.username, 'connection_requester_name': connection_requester.profile.name, } } }) Notification = get_notification_model() notification_data = { 'type': Notification.CONNECTION_REQUEST, } one_signal_notification.set_parameter('data', notification_data) _send_notification_to_user(user=connection_requested_for, notification=one_signal_notification)
def send_post_comment_reaction_push_notification(post_comment_reaction): post_comment_commenter = post_comment_reaction.post_comment.commenter post_comment_id = post_comment_reaction.post_comment_id notification_group = 'post_comment_%s' % post_comment_id post_comment_reactor = post_comment_reaction.reactor target_user_language_code = get_notification_language_code_for_target_user( post_comment_commenter) with translation.override(target_user_language_code): one_signal_notification = onesignal_sdk.Notification( post_body={ "contents": { "en": _('%(post_comment_reactor_name)s · @%(post_comment_reactor_username)s reacted to your comment.' ) % { 'post_comment_reactor_name': post_comment_reactor.profile.name, 'post_comment_reactor_username': post_comment_reactor.username, } } }) Notification = get_notification_model() notification_data = { 'type': Notification.POST_COMMENT_REACTION, } one_signal_notification.set_parameter('data', notification_data) one_signal_notification.set_parameter('!thread_id', notification_group) one_signal_notification.set_parameter('android_group', notification_group) _send_notification_to_user(notification=one_signal_notification, user=post_comment_commenter)
def professional_appointment_notification(professional, parent, appointment): """ Send professional appoint request push notifications. :param professional: :param parent: :param appointment: :return: """ onesignal_client = onesignal_sdk.Client(user_auth_key=settings.PROFESSIONAL_ONESIGNAL_AUTH_KEY, app={"app_auth_key": settings.PROFESSIONAL_ONESIGNAL_REST_KEY, "app_id": settings.PROFESSIONAL_ONESIGNAL_APP_ID}) # create a notification new_notification = onesignal_sdk.Notification() new_notification.set_parameter("contents", { "en": "Appointment request from {} on {} from {}-{}.".format(parent.profile.full_name, appointment.date.strftime('%m/%d/%Y'), appointment.start_time, appointment.end_time)}) new_notification.set_parameter("headings", {"en": "MOTUS: Appointment request"}) new_notification.set_parameter("template_id", settings.PROFESSIONAL_ONESIGNAL_APPOINTMENT_TEMPLATE_ID) # set filters new_notification.set_filters( [{"field": "tag", "key": "id", "relation": "=", "value": str(professional.profile.user_id)}]) # send notification, it will return a response onesignal_response = onesignal_client.send_notification(new_notification) print(onesignal_response.status_code) print(onesignal_response.json())
def send_community_invite_push_notification(community_invite): invited_user = community_invite.invited_user if invited_user.has_community_invite_notifications_enabled(): invite_creator = community_invite.creator community = community_invite.community target_user_language_code = get_notification_language_code_for_target_user( invited_user) with translation.override(target_user_language_code): one_signal_notification = onesignal_sdk.Notification( post_body={ "en": _('%(invite_creator_name)s · @%(invite_creator_username)s has invited you to join /c/%(community_name)s.' ) % { 'invite_creator_username': invite_creator.username, 'invite_creator_name': invite_creator.profile.name, 'community_name': community.name, } }) Notification = get_notification_model() notification_data = { 'type': Notification.COMMUNITY_INVITE, } one_signal_notification.set_parameter('data', notification_data) _send_notification_to_user(notification=one_signal_notification, user=invited_user)
def professional_new_lesson_notification(data, lesson): """ :param data: :param lesson: :return: """ filter_list = list() for i, item in enumerate(data): if i < len(data) - 1: filter_list.append({"field": "tag", "key": "id", "relation": "=", "value": str(item)}) filter_list.append({"operator": "OR"}) else: filter_list.append({"field": "tag", "key": "id", "relation": "=", "value": str(item)}) onesignal_client = onesignal_sdk.Client(user_auth_key=settings.PROFESSIONAL_ONESIGNAL_AUTH_KEY, app={"app_auth_key": settings.PROFESSIONAL_ONESIGNAL_REST_KEY, "app_id": settings.PROFESSIONAL_ONESIGNAL_APP_ID}) # create a notification new_notification = onesignal_sdk.Notification() new_notification.set_parameter("contents", { "en": "New lesson: '{}' can now be assigned.".format(lesson.lesson_name)}) new_notification.set_parameter("headings", {"en": "MOTUS: New lessons added!"}) new_notification.set_parameter("template_id", settings.PROFESSIONAL_ONESIGNAL_NEW_LESSON_TEMPLATE_ID) # set filters new_notification.set_filters(filter_list) # send notification, it will return a response onesignal_response = onesignal_client.send_notification(new_notification) print(onesignal_response.status_code) print(onesignal_response.json())
def send_sighting_onesignal_notification(data, notify_record, add_seen): filter_list = list() for i, item in enumerate(data): if i < len(data) - 1: filter_list.append({ "field": "tag", "key": "id", "relation": "=", "value": str(item) }) filter_list.append({"operator": "OR"}) else: filter_list.append({ "field": "tag", "key": "id", "relation": "=", "value": str(item) }) onesignal_client = onesignal_sdk.Client( user_auth_key=settings.ONESIGNAL_AUTH_KEY, app={ "app_auth_key": settings.ONESIGNAL_REST_KEY, "app_id": settings.ONESIGNAL_APP_ID }) # create a notification new_notification = onesignal_sdk.Notification() new_notification.set_parameter( "contents", { "en": "Potentially seen at {}. {}".format(add_seen.address, add_seen.description) }) new_notification.set_parameter("headings", { "en": "POTENTIAL SIGHTING: {}".format(notify_record.vulnerable.full_name) }) new_notification.set_parameter("template_id", settings.ONESIGNAL_SIGHTING_TEMPLATE_ID) print("{}/media/{}".format(settings.DOMAIN, notify_record.vulnerable.picture)) new_notification.set_parameter( "ios_attachments", { "id": "{}/media/{}".format(settings.DOMAIN, notify_record.vulnerable.picture) }) new_notification.set_parameter( "big_picture", "{}/media/{}".format(settings.DOMAIN, notify_record.vulnerable.picture)) # set filters new_notification.set_filters(filter_list) # send notification, it will return a response onesignal_response = onesignal_client.send_notification(new_notification) print(onesignal_response.status_code) print(onesignal_response.json())
def send_post_reaction_push_notification(post_reaction): post_creator = post_reaction.post.creator notification_group = NOTIFICATION_GROUP_LOW_PRIORITY if post_creator.has_reaction_notifications_enabled_for_post_with_id(post_id=post_reaction.post_id): post_reactor = post_reaction.reactor target_user_language_code = get_notification_language_code_for_target_user(post_creator) with translation.override(target_user_language_code): one_signal_notification = onesignal_sdk.Notification(post_body={ "contents": {"en": _('%(post_reactor_name)s · @%(post_reactor_username)s reacted to your post.') % { 'post_reactor_username': post_reactor.username, 'post_reactor_name': post_reactor.profile.name, }} }) Notification = get_notification_model() notification_data = { 'type': Notification.POST_REACTION, } one_signal_notification.set_parameter('data', notification_data) one_signal_notification.set_parameter('!thread_id', notification_group) one_signal_notification.set_parameter('android_group', notification_group) _send_notification_to_user(notification=one_signal_notification, user=post_creator)
def test_send_notification_has_post_body_params(self, fake_request): client = onesignal.Client(user_auth_key=self.USER_AUTH_KEY, app_id=self.APP_ID, app_auth_key=self.APP_AUTH_KEY) post_body = {"contents": {"en": "Message", "tr": "Mesaj"}} notification = onesignal.Notification(post_body) notification.post_body["included_segments"] = [ "Active Users", "Inactive Users" ] notification.post_body["filters"] = [{ "field": "tag", "key": "level", "relation": "=", "value": "10" }, { "operator": "OR" }, { "field": "tag", "key": "level", "relation": "=", "value": "20" }] response = client.send_notification(notification) self.assertEqual(response.status_code, 200)
def test_send_notification_without_app_id_fails(self): client = onesignal.Client(user_auth_key=self.USER_AUTH_KEY, app_auth_key=self.APP_AUTH_KEY) post_body = {"contents": {"en": "Message", "tr": "Mesaj"}} notification = onesignal.Notification(post_body) with self.assertRaises(onesignal.error.OneSignalError): response = client.send_notification(notification)
def test_send_notification_has_app_id(self, fake_request): client = onesignal.Client(user_auth_key=self.USER_AUTH_KEY, app_id=self.APP_ID, app_auth_key=self.APP_AUTH_KEY) post_body = {"contents": {"en": "Message", "tr": "Mesaj"}} notification = onesignal.Notification(post_body) response = client.send_notification(notification) self.assertEqual(response.status_code, 200)
def send_msg_notification_to_users(sender_name, to_user_id, message, sent_at): header = _('New message from ' f'{sender_name}' '!') message = 'Sent at ' + sent_at.strftime('%d-%m-%Y %H:%M') + ': ' + message msg = _(message) user_notify_id = CustomUser.objects.get(pk=to_user_id).id_notifications new_notification = onesignal_sdk.Notification({"en": msg}) new_notification.set_parameter("headings", {"en": header}) new_notification.set_parameter("include_player_ids", [user_notify_id]) onesignal_client.send_notification(new_notification)
def send_notification(notification_body, subscriptions, client): tokens = list(map(lambda subscription: subscription.token, subscriptions)) if tokens: notification = onesignal.Notification(post_body=notification_body) notification.post_body['include_player_ids'] = tokens onesignal_response = client.send_notification(notification) if onesignal_response.status_code == 200: app.logger.info('The notification ({}) sent out successfully'.format(notification.post_body)) else: app.logger.warn('The notification ({}) was unsuccessful'.format(notification.post_body))