From bf98444ead05cca4b42c48d689220f3754402753 Mon Sep 17 00:00:00 2001 From: justcool393 Date: Sun, 13 Nov 2022 05:11:55 -0600 Subject: [PATCH] push notifications: fix pusher causing errors on large unicode msgs --- files/helpers/alerts.py | 2 ++ files/helpers/const.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index ffff2e041..649511a28 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -106,6 +106,8 @@ if PUSHER_ID != 'blahblahblah': def pusher_thread(interests, title, notifbody, url): title = censor_slurs(title, None) notifbody = censor_slurs(notifbody, None) + if len(notifbody) > PUSHER_LIMIT: + notifbody = notifbody[:PUSHER_LIMIT] + "..." beams_client.publish_to_interests( interests=[interests], diff --git a/files/helpers/const.py b/files/helpers/const.py index 304008cad..66f221cec 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -57,6 +57,8 @@ DEFAULT_RATELIMIT = "3/second;30/minute;200/hour;1000/day" DEFAULT_RATELIMIT_SLOWER = "1/second;30/minute;200/hour;1000/day" DEFAULT_RATELIMIT_USER = DEFAULT_RATELIMIT_SLOWER +PUSHER_LIMIT = 1000 # API allows 10 KB but better safe than sorry + if SITE == "localhost": SITE_FULL = 'http://' + SITE else: SITE_FULL = 'https://' + SITE