Skip to content

Commit 7ea68b0

Browse files
committed
Adding 100 notification
1 parent 8f5f64a commit 7ea68b0

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

packet/notifications.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,22 @@ def packet_signed_notification(packet, signer):
2727
print(onesignal_response.json())
2828
if onesignal_response.status_code == 200:
2929
app.logger.info("The notification ({}) sent out successfully".format(notification.post_body))
30+
31+
32+
def packet_100_percent_notification(packet):
33+
subscriptions = NotificationSubscription.query.all()
34+
if subscriptions:
35+
tokens = list(filter(lambda subscription: subscription.token, subscriptions))
36+
37+
notification = onesignal.Notification(post_body=post_body)
38+
notification.post_body["content"]["en"] = packet.freshman.name + ' got 💯 on packet!'
39+
notification.post_body["headings"]["en"] = 'New 100% on Packet!'
40+
# TODO: Issue #156
41+
notification.post_body["chrome_web_icon"] = 'https://profiles.csh.rit.edu/image/' + packet.freshman_username
42+
notification.post_body["include_player_ids"] = tokens
43+
44+
onesignal_response = onesignal_client.send_notification(notification)
45+
print(onesignal_response.status_code)
46+
print(onesignal_response.json())
47+
if onesignal_response.status_code == 200:
48+
app.logger.info("The notification ({}) sent out successfully".format(notification.post_body))

0 commit comments

Comments
 (0)