forked from rDrama/rDrama
1
0
Fork 0
master
Aevann1 2022-02-04 18:33:50 +02:00
parent d5c65845d4
commit f122f289b9
2 changed files with 67 additions and 61 deletions

View File

@ -552,30 +552,32 @@ def api_comment(v):
if parent.author.id != v.id and PUSHER_ID: if parent.author.id != v.id and PUSHER_ID:
if len(c.body) > 500: notifbody = c.body[:500] + '...' 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( try:
interests=[f'{request.host}{parent.author.id}'], beams_client.publish_to_interests(
publish_body={ interests=[f'{request.host}{parent.author.id}'],
'web': { publish_body={
'notification': { 'web': {
'title': f'New reply by @{c.author_name}', 'notification': {
'body': notifbody, 'title': f'New reply by @{c.author_name}',
'deep_link': f'{SITE_FULL}/comment/{c.id}?context=8&read=true#context', 'body': notifbody,
'icon': f'{SITE_FULL}/assets/images/{SITE_NAME}/icon.webp?a=1009', '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': { except: pass
'title': f'New reply by @{c.author_name}',
'body': notifbody,
},
'data': {
'url': f'/comment/{c.id}?context=8&read=true#context',
}
}
},
)
vote = CommentVote(user_id=v.id, vote = CommentVote(user_id=v.id,

View File

@ -494,28 +494,30 @@ def message2(v, username):
if len(message) > 500: notifbody = message[:500] + '...' if len(message) > 500: notifbody = message[:500] + '...'
else: notifbody = message else: notifbody = message
beams_client.publish_to_interests( try:
interests=[f'{request.host}{user.id}'], beams_client.publish_to_interests(
publish_body={ interests=[f'{request.host}{user.id}'],
'web': { publish_body={
'notification': { 'web': {
'title': f'New message from @{v.username}', 'notification': {
'body': notifbody, 'title': f'New message from @{v.username}',
'deep_link': f'{SITE_FULL}/notifications?messages=true', 'body': notifbody,
'icon': f'{SITE_FULL}/assets/images/{SITE_NAME}/icon.webp?a=1009', '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': { except: pass
'title': f'New message from @{v.username}',
'body': notifbody,
},
'data': {
'url': '/notifications?messages=true',
}
}
},
)
g.db.commit() g.db.commit()
@ -562,28 +564,30 @@ def messagereply(v):
if len(message) > 500: notifbody = message[:500] + '...' if len(message) > 500: notifbody = message[:500] + '...'
else: notifbody = message else: notifbody = message
beams_client.publish_to_interests( try:
interests=[f'{request.host}{user_id}'], beams_client.publish_to_interests(
publish_body={ interests=[f'{request.host}{user_id}'],
'web': { publish_body={
'notification': { 'web': {
'title': f'New message from @{v.username}', 'notification': {
'body': notifbody, 'title': f'New message from @{v.username}',
'deep_link': f'{SITE_FULL}/notifications?messages=true', 'body': notifbody,
'icon': f'{SITE_FULL}/assets/images/{SITE_NAME}/icon.webp"a=1008', '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': { except: pass
'title': f'New message from @{v.username}',
'body': notifbody,
},
'data': {
'url': '/notifications?messages=true',
}
}
},
)
if new_comment.top_comment.sentto == 0: if new_comment.top_comment.sentto == 0: