How to implement a periodic digest of messages?

My system sends messages to users (email, SMS, etc.). Currently, he sends it for each event (which has a maximum only once a day), but I would like to add a digest form to it, where the user can choose to have a weekly or monthly digest of his messages. I am looking to see if there are any existing open source solutions for this or existing templates for implementing something similar.

My system does not save any messages, they are sent as needed and then forgotten. So this is the first thing to happen. I would also like to be able to create a message page on the site, which will display the history of all messages.

Then there should be a mechanism that looks at the user's preferences in messages and decides when to send messages and how to group them into a digest form, if necessary.

Any pointers or thoughts would be appreciated.

+3
source share
2 answers

Store messages mainly in a database with such a categorical scheme (this is pseudocode):

TABLE message {
 id,
 created_timestamp,
 user_id,
 sent,
 type (sms, email, etc),
 content
}

Then, every day, say, at midnight, SELECT all messages where = 0 and user_id = were sent, and aggregate them into one message, send it using the specified type method and mark everything as sent = 1.

You can find the historical message specified only with SELECTing out messages, where = 1 was sent.

+2
source

, Listserv v16 .

+1

Source: https://habr.com/ru/post/1735107/


All Articles