🌐 Machine-translated from Russian. Show original
A brief overview of a task from the portal's life: how to send notifications about private messages so they arrive when needed and don't fall flat.
In this part:
What went wrong
The first version was simple: "if the recipient is not on the site — send it to Telegram, but no more than once every 10 minutes for dialogue." In practice:
- An open background tab was considered "on the site" — the person left the computer, but there were no notifications.
- The 10-minute window swallowed messages: the first arrived, the next five did not, and no one found out about them.
Idea: what matters is not "online," but "read"
We stopped guessing where the person was and started looking at the fact: was the message left unread?
- A message arrived → set a timer for 45 seconds (for push in the app — 8 seconds).
- The timer went off → we check in the database if it was read. Read on the website — we are silent.
- Not → one notification was read in the entire pack: from whom, how many, the last three messages.
- The next notification for the same dialog is no earlier than 3 minutes later and only for messages received after the previous one.
While the timer waits, new messages simply go into the same batch — the timer does not restart.
