From 21eb20c9dfca9712348495d15b828c16db1d1c45 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Mon, 17 Jan 2022 17:13:35 +0200 Subject: [PATCH] bb --- files/routes/comments.py | 48 +++++++++++++++++++++------------------- files/routes/users.py | 6 ++--- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/files/routes/comments.py b/files/routes/comments.py index 5c05d86ac..ef3534d28 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -467,32 +467,34 @@ def api_comment(v): if parent.author.id != v.id: if len(c.body) > 500: notifbody = c.body[:500] + '...' - elif c.body: notifbody = c.body - else: notifbody = '' + 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 @{v.username}', - 'body': notifbody, - 'deep_link': f'https://{site}/comment/{c.id}?context=9&read=true#context', - 'icon': f'https://{request.host}/assets/images/{SITE_NAME}/icon.webp', - } - }, - 'fcm': { - 'notification': { - 'title': f'New reply by @{v.username}', - 'body': notifbody, + try: + beams_client.publish_to_interests( + interests=[f'{request.host}{parent.author.id}'], + publish_body={ + 'web': { + 'notification': { + 'title': f'New reply by @{v.username}', + 'body': notifbody, + 'deep_link': f'https://{site}/comment/{c.id}?context=9&read=true#context', + 'icon': f'https://{request.host}/assets/images/{SITE_NAME}/icon.webp', + } }, - 'data': { - 'url': f'comment/{c.id}?context=9&read=true#context', + 'fcm': { + 'notification': { + 'title': f'New reply by @{v.username}', + 'body': notifbody, + }, + 'data': { + 'url': f'comment/{c.id}?context=9&read=true#context', + } } - } - }, - ) - + }, + ) + except Exception as e: + print(e) + print(c.id) vote = CommentVote(user_id=v.id, diff --git a/files/routes/users.py b/files/routes/users.py index bc95ec608..b8580474e 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -437,8 +437,7 @@ def message2(v, username): g.db.add(notif) if len(message) > 500: notifbody = message[:500] + '...' - elif message: notifbody = message - else: notifbody = '' + else: notifbody = message beams_client.publish_to_interests( interests=[f'{request.host}{user.id}'], @@ -505,8 +504,7 @@ def messagereply(v): g.db.add(notif) if len(message) > 500: notifbody = message[:500] + '...' - elif message: notifbody = message - else: notifbody = '' + else: notifbody = message beams_client.publish_to_interests( interests=[f'{request.host}{user_id}'],