diff --git a/files/routes/comments.py b/files/routes/comments.py index f2d6a97cf..5bb91b46d 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -552,30 +552,32 @@ def api_comment(v): if parent.author.id != v.id and PUSHER_ID: if len(c.body) > 500: notifbody = c.body[:500] + '...' - else: notifbody = c.body or 'no body' + else: notifbody = c.body - beams_client.publish_to_interests( - interests=[f'{request.host}{parent.author.id}'], - publish_body={ - 'web': { - 'notification': { - 'title': f'New reply by @{c.author_name}', - 'body': notifbody, - 'deep_link': f'{SITE_FULL}/comment/{c.id}?context=8&read=true#context', - 'icon': f'{SITE_FULL}/assets/images/{SITE_NAME}/icon.webp?a=1009', + try: + beams_client.publish_to_interests( + interests=[f'{request.host}{parent.author.id}'], + publish_body={ + 'web': { + 'notification': { + 'title': f'New reply by @{c.author_name}', + 'body': notifbody, + 'deep_link': f'{SITE_FULL}/comment/{c.id}?context=8&read=true#context', + 'icon': f'{SITE_FULL}/assets/images/{SITE_NAME}/icon.webp?a=1009', + } + }, + 'fcm': { + 'notification': { + 'title': f'New reply by @{c.author_name}', + 'body': notifbody, + }, + 'data': { + 'url': f'/comment/{c.id}?context=8&read=true#context', + } } }, - 'fcm': { - 'notification': { - 'title': f'New reply by @{c.author_name}', - 'body': notifbody, - }, - 'data': { - 'url': f'/comment/{c.id}?context=8&read=true#context', - } - } - }, - ) + ) + except: pass vote = CommentVote(user_id=v.id, diff --git a/files/routes/users.py b/files/routes/users.py index 486406588..d3edf5b81 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -494,28 +494,30 @@ def message2(v, username): if len(message) > 500: notifbody = message[:500] + '...' else: notifbody = message - beams_client.publish_to_interests( - interests=[f'{request.host}{user.id}'], - publish_body={ - 'web': { - 'notification': { - 'title': f'New message from @{v.username}', - 'body': notifbody, - 'deep_link': f'{SITE_FULL}/notifications?messages=true', - 'icon': f'{SITE_FULL}/assets/images/{SITE_NAME}/icon.webp?a=1009', + try: + beams_client.publish_to_interests( + interests=[f'{request.host}{user.id}'], + publish_body={ + 'web': { + 'notification': { + 'title': f'New message from @{v.username}', + 'body': notifbody, + 'deep_link': f'{SITE_FULL}/notifications?messages=true', + 'icon': f'{SITE_FULL}/assets/images/{SITE_NAME}/icon.webp?a=1009', + } + }, + 'fcm': { + 'notification': { + 'title': f'New message from @{v.username}', + 'body': notifbody, + }, + 'data': { + 'url': '/notifications?messages=true', + } } }, - 'fcm': { - 'notification': { - 'title': f'New message from @{v.username}', - 'body': notifbody, - }, - 'data': { - 'url': '/notifications?messages=true', - } - } - }, - ) + ) + except: pass g.db.commit() @@ -562,28 +564,30 @@ def messagereply(v): if len(message) > 500: notifbody = message[:500] + '...' else: notifbody = message - beams_client.publish_to_interests( - interests=[f'{request.host}{user_id}'], - publish_body={ - 'web': { - 'notification': { - 'title': f'New message from @{v.username}', - 'body': notifbody, - 'deep_link': f'{SITE_FULL}/notifications?messages=true', - 'icon': f'{SITE_FULL}/assets/images/{SITE_NAME}/icon.webp"a=1008', + try: + beams_client.publish_to_interests( + interests=[f'{request.host}{user_id}'], + publish_body={ + 'web': { + 'notification': { + 'title': f'New message from @{v.username}', + 'body': notifbody, + 'deep_link': f'{SITE_FULL}/notifications?messages=true', + 'icon': f'{SITE_FULL}/assets/images/{SITE_NAME}/icon.webp"a=1008', + } + }, + 'fcm': { + 'notification': { + 'title': f'New message from @{v.username}', + 'body': notifbody, + }, + 'data': { + 'url': '/notifications?messages=true', + } } }, - 'fcm': { - 'notification': { - 'title': f'New message from @{v.username}', - 'body': notifbody, - }, - 'data': { - 'url': '/notifications?messages=true', - } - } - }, - ) + ) + except: pass if new_comment.top_comment.sentto == 0: