chat21-cloud-functions
chat21-cloud-functions copied to clipboard
Unnecessary notification when joining group
The function in index.js duplicateTimelineOnJoinGroup
triggers the function sendNotification
in push-notification.js. So if someone joins a group chat with 1000 users, the user gets 1000 push notifications from system. Is there a way to stop this?
You should modify the source code to disable this kind of push notifications, disabling sending the notification for the old messages.
There are actually no alternatives, because the functions were developed for a client with this specific requirement.
Andrea
On Mon, 9 May 2022 at 12:13, Bobbykart @.***> wrote:
The function in index.js duplicateTimelineOnJoinGroup triggers the function sendNotification in push-notification.js. So if someone joins a group chat with 1000 messages, the user gets 1000 push notifications. Is there a way to stop this?
— Reply to this email directly, view it on GitHub https://github.com/chat21/chat21-cloud-functions/issues/32, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHYOM3QPQ4USQG5BE47NUFLVJDQN3ANCNFSM5VNYKEOA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
-- Andrea Sponziello, Frontiere21 SRL Tiledesk Live Chat Product Manager https://tiledesk.com/ https://www.frontiere21.it http://www.frontiere21.it @.*** Mobile: +39 329 3529380
the function duplicateTimelineOnJoinGroup disable the notification when someone joins the chat. As you see from the code below:
Only one notification is sent.
Wrong. There is no database field called attributes.sendnotification and is not even mentioned in the sendNotification
function. There is only forcenotification and only this field is asked in a if-statement in sendNotification
. I had to rewrite the code and replace message.atteibutes.sendnotification
to message.attributes.forcenotification
.
the logic is this: if you send a message with message.attributes.forcenotification=true then a notification is sent for each message if you send a message without message.attributes.forcenotification=true then a notification is sent only for the first message
Yes but the forcenotification isn't set to false in the code. Therefore the system messages, which were true in one node, are copied as true and bypass the if-statement in sendNotification. The joined user gets all system messages of the chatgroup because of the onCreate. The code you provided is useless because in push-notifications.js the field message.attributes.sendnotification isnt mentioned once.