Skip to content

Commit 7147d85

Browse files
committed
Using send_notification in both
1 parent b30322e commit 7147d85

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

packet/notifications.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,13 @@ def send_notification(notification_body, subscriptions, client):
2727
def packet_signed_notification(packet, signer):
2828
subscriptions = NotificationSubscription.query.filter_by(freshman_username=packet.freshman_username)
2929
if subscriptions:
30-
tokens = list(map(lambda subscription: subscription.token, subscriptions))
31-
32-
notification = onesignal.Notification(post_body=post_body)
33-
notification.post_body["contents"]["en"] = signer + ' signed your packet! Congrats or I\'m Sorry'
34-
notification.post_body["headings"]["en"] = 'New Packet Signature!'
35-
notification.post_body["chrome_web_icon"] = 'https://profiles.csh.rit.edu/image/' + signer
36-
notification.post_body["include_player_ids"] = tokens
37-
notification.post_body["url"] = app.config["PROTOCOL"] + app.config["PACKET_INTRO"]
30+
notification_body = post_body
31+
notification_body["contents"]["en"] = signer + ' signed your packet! Congrats or I\'m Sorry'
32+
notification_body["headings"]["en"] = 'New Packet Signature!'
33+
notification_body["chrome_web_icon"] = 'https://profiles.csh.rit.edu/image/' + signer
34+
notification_body["url"] = app.config["PROTOCOL"] + app.config["PACKET_INTRO"]
3835

39-
onesignal_response = intro_onesignal_client.send_notification(notification)
40-
if onesignal_response.status_code == 200:
41-
app.logger.info("The notification ({}) sent out successfully".format(notification.post_body))
36+
send_notification(notification_body, subscriptions, intro_onesignal_client)
4237

4338

4439
def packet_100_percent_notification(packet):

0 commit comments

Comments
 (0)