Guest mode. You can read posts without signing up. Comments, ratings, job contacts and your own posts open after you sign up and accept the rules. What is Kommit →

Редакция КоммитРедакция портала
commit 56e5e37 · 15 days ago
Blog

How we decided: notifications about messages that are not spam — "read or not" instead of "online or not"

🌐 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?

  1. A message arrived → set a timer for 45 seconds (for push in the app — 8 seconds).
  2. The timer went off → we check in the database if it was read. Read on the website — we are silent.
  3. Not → one notification was read in the entire pack: from whom, how many, the last three messages.
  4. 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.

What to store#

In the dialogue table for each participant — the time of the last notification (aTgAt / bTgAt). Plus the existing reading time (aReadAt / bReadAt). Hence, it is considered that the "new" from the previous time:

const since = sentAt && sentAt > readAt ? sentAt : readAt;
const count = await db.message.count({
  where: { conversationId, senderId: { not: userId }, hidden: false, createdAt: { gt: since } },
});

Bonus: reply directly from Telegram#

A link to the dialogue is placed in the notification text. When a person replies to the notification with a replay, the bot's webhook retrieves the dialog's reply_to_message id and sends the text through the same function as the site — with the same checks for sanctions, blocks, and limits. Instead of "sent," the bot places a 👍 reaction .

About privacy#

For push in the mobile app, we went further: the notification has no name or text, only the dialog id. Push goes through Google and Apple's servers, and the correspondence itself remains on our server.

How about you?#

How do you decide to "don't spam, but don't skip" in your products? Debounce, digests, silence settings? Write in the comments — we'll gather the best approaches.

Comments 00 участников · 0 гостей🔒 Rate and discuss after signing up

Comments · 0

No comments yet.Sign in to comment, rate and see all comments.