# Chat
# Scheduled chat message
# Background
We need a way for admin/coordinator to schedule a message to the cohort wide chat channel. It should also be deletable.
# Key logic
- DB change
- Add new db fields
scheduled
(datetime),is_sent
(boolean) to chat log table.
- Add new db fields
- Create chat channel
- Admin/coordinator will be able to create 2 new announcement channels (only admin/coordinator are allowed to post message to the channel).
- One is a cohort wide channel for learner only.
- The other is a cohort wide channel for expert only.
- Create/update/delete scheduled message
- Use the normal create message API with a new parameter
scheduled
to pass a datetime string. - Create a new API to update a message.
- Create a new API to delete a message.
- Use the normal create message API with a new parameter
- Chat messages
- To get normal chat message history, filter by
is_sent = true
- To get scheduled chat messages, filter by
is_sent = false
- To get normal chat message history, filter by
- Cronjob
- A cronjob that checks db regularly for every X minutes.
- Check if there are past scheduled messages that haven't been sent. If so, change the
is_sent
to true and send the Pusher event. - Send an unread chat reminder email to the user when there are unread chat messages and the user hasn’t seen them within 10 minutes.
- Only send one email to the user before he checks the chat.
# Tasks
- [CORE] Create migration to add field "scheduled", "is_sent" to chat log table.
- [Chat API] Able to pass scheduled time when create message.
- [Chat API] Filter the chat messages that are scheduled later.
- [Chat API] Create API to update a message.
- [Chat API] Create API to delete a message.
- [CORE] New unread chat reminder email (new reminder email logic, send Pusher event if a passed scheduled message hasn’t been sent).
- [CUTIE] UI to allow schedule cohort wide message.