gildebrand / chatkit-push-helper

Pusher Chatkit Push Helper
7 stars 2 forks source link

Don't send push notifications for messages where sent in the last x seconds #2

Open gianpaj opened 6 years ago

gianpaj commented 6 years ago

Thanks again for putting this project together.

In the chat app + server I've implemented I'm getting random push notification being sent even though both users are online and setting read cursors as soon as they receive a message.

My current hypothesis is that even with a long polling period, there could be a time in which the server reads the message quicker than the client can receive it and update the read cursor.

If you agree and that's true, where would be the best place to filter messages sent in the last x seconds?

Maybe in the filterUsersRoomsAndMessages() function?

https://github.com/gildebrand/chatkit-push-helper/blob/50ff8b09d559a9e6e52f001ca5e8dda855ee4d55/chatkithelper.js#L113-L128

gildebrand commented 6 years ago

Actually I currently ignore the fact that a user is currently online. This little project is just a super hacky way of getting push notifications working. I haven't experienced the issue you are describing myself, but if you want to do any kind of filtering on the messages, then the code you refer to is a good place to add it. You could just add a third filter to room.messages to accomplish what you want :)

Sorry for this being slowly maintained. Just put it together over a day, and thought that can help some other people out but I haven't had the time recently to maintain it!