From 34d7c42c35c323bf705a1a058f163f19fb52ba91 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 16 Jan 2022 03:44:07 +0200 Subject: [PATCH] bbbb --- files/routes/comments.py | 7 +++++-- files/routes/users.py | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/files/routes/comments.py b/files/routes/comments.py index 444362f2f..4b530ec6e 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -466,13 +466,16 @@ def api_comment(v): g.db.add(n) if parent.author.id != v.id: + if len(message) > 100: notifbody = c.body[:100] + '...' + 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': c.body, + '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', } @@ -480,7 +483,7 @@ def api_comment(v): 'fcm': { 'notification': { 'title': f'New reply by @{v.username}', - 'body': c.body, + 'body': notifbody, 'click_action': 'android.intent.category.DEFAULT', }, 'data': { diff --git a/files/routes/users.py b/files/routes/users.py index 2fa5beb32..d6096651f 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -434,6 +434,8 @@ def message2(v, username): notif = Notification(comment_id=new_comment.id, user_id=user.id) g.db.add(notif) + if len(message) > 100: notifbody = message[:100] + '...' + else: notifbody = message beams_client.publish_to_interests( interests=[str(user.id)], @@ -441,7 +443,7 @@ def message2(v, username): 'web': { 'notification': { 'title': f'New message from @{v.username}', - 'body': message, + 'body': notifbody, 'deep_link': f'https://{site}/notifications', 'icon': f'https://{request.host}/assets/images/{SITE_NAME}/icon.webp', } @@ -449,7 +451,7 @@ def message2(v, username): 'fcm': { 'notification': { 'title': f'New message from @{v.username}', - 'body': message, + 'body': notifbody, 'click_action': 'android.intent.category.DEFAULT', }, 'data': {