push notifications: fix pusher causing errors on large unicode msgs

remotes/1693176582716663532/tmp_refs/heads/watchparty
justcool393 2022-11-13 05:11:55 -06:00
parent f4f03f6582
commit bf98444ead
2 changed files with 4 additions and 0 deletions

View File

@ -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],

View File

@ -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