From ec16f11489d12e6cb01f3b52dc31dc5f33135fdc Mon Sep 17 00:00:00 2001 From: Devin Matte Date: Fri, 16 Aug 2019 00:24:21 -0400 Subject: [PATCH] Fixing Notifications and adding logging --- packet/mail.py | 2 ++ packet/notifications.py | 7 +++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packet/mail.py b/packet/mail.py index c7a653e1..a03e7901 100644 --- a/packet/mail.py +++ b/packet/mail.py @@ -16,6 +16,7 @@ def send_start_packet_mail(packet): template = 'mail/packet_start' msg.body = render_template(template + '.txt', packet=packet) msg.html = render_template(template + '.html', packet=packet) + app.logger.info("Sending mail to " + recipients[0]) mail.send(msg) @@ -32,4 +33,5 @@ def send_report_mail(form_results, reporter): template = 'mail/report' msg.body = render_template(template + '.txt', person=person, report=report, reporter=reporter) msg.html = render_template(template + '.html', person=person, report=report, reporter=reporter) + app.logger.info("Sending mail to " + recipients[0]) mail.send(msg) diff --git a/packet/notifications.py b/packet/notifications.py index e427c5df..50f7e582 100644 --- a/packet/notifications.py +++ b/packet/notifications.py @@ -4,9 +4,8 @@ from packet.models import NotificationSubscription post_body = { - "content": {"en": "Default message"}, + "contents": {"en": "Default message"}, "headings": {"en": "Default Title"}, - "included_segments": ["Active Users", "Inactive Users"], "chrome_web_icon": app.config["PROTOCOL"] + app.config["SERVER_NAME"] + "/static/android-chrome-512x512.png", "chrome_web_badge": app.config["PROTOCOL"] + app.config["SERVER_NAME"] + "/static/android-chrome-512x512.png", "url": app.config["PROTOCOL"] + app.config["SERVER_NAME"] @@ -19,7 +18,7 @@ def packet_signed_notification(packet, signer): tokens = list(map(lambda subscription: subscription.token, subscriptions)) notification = onesignal.Notification(post_body=post_body) - notification.post_body["content"]["en"] = signer + ' signed your packet! Congrats or I\'m Sorry' + notification.post_body["contents"]["en"] = signer + ' signed your packet! Congrats or I\'m Sorry' notification.post_body["headings"]["en"] = 'New Packet Signature!' notification.post_body["chrome_web_icon"] = 'https://profiles.csh.rit.edu/image/' + signer notification.post_body["include_player_ids"] = tokens @@ -35,7 +34,7 @@ def packet_100_percent_notification(packet): tokens = list(map(lambda subscription: subscription.token, subscriptions)) notification = onesignal.Notification(post_body=post_body) - notification.post_body["content"]["en"] = packet.freshman.name + ' got 💯 on packet!' + notification.post_body["contents"]["en"] = packet.freshman.name + ' got 💯 on packet!' notification.post_body["headings"]["en"] = 'New 100% on Packet!' # TODO: Issue #156 notification.post_body["chrome_web_icon"] = 'https://profiles.csh.rit.edu/image/' + packet.freshman_username