V
V
vikholodov2018-06-26 15:56:57
Django
vikholodov, 2018-06-26 15:56:57

How to make unobtrusive notifications about new messages in the messenger?

Hello!
The project has a built-in messenger for users and the task is to send notifications about unread messages from the messenger.
So far, nothing good has come to mind. The task is not to send bundles of email notifications for every unread message.
It suggests a countdown from the moment the message arrives, if it is not read in 5 minutes, for example, then the email notification goes out. But loading each message with such a check is not good. It turns out that you need to do a check only if the user is not online. But, I don’t really want to send each new message either, i.e. you need to record somewhere that the message has already been sent. If we imagine that this whole mountain will work simultaneously for several thousand users, then I somehow don’t like the idea described above.
In general, I need your advice, colleagues.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-06-26
@vikholodov

When opening a window with a list of messages, set a timeout for launching a javascript function after 15-30 seconds, which will receive from this window a list of all messages marked "unread", send a list of their IDs to a special view via ajax, and in case of a positive response, mark them "read". The view on the server turns out to be extremely fast - all you need to do is to do a batch update according to the list of primary keys. And you need to write a management command that is run by cron once every 10 minutes, raking out all messages older than 10 minutes with the "unread" label from the database and sending a letter "You have unread messages." Moreover, after sending, you need to put a mark somewhere that a notification was sent to such and such a user, and do not send new ones until

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question