blackmann / compa

🌁 scoodent companion. Stay on top of tertiary school lifestyle with modern experiences.
https://compa.so
58 stars 19 forks source link

RFC - Notification system #61

Closed auxibee closed 6 months ago

auxibee commented 7 months ago

A non-realtime notification system for Compa.

Features

Implementation

Notifications are events that happen we would like to inform users about such as comment added, comment deleted, a new feature added etc.

We will have a table to capture the different kinds of events that occur in our system. For now only comment added event will be added

Event {
 id
name
}

A notification table which will capture the main notification message, actor_id-optional(the user performing the event) and entity id-optional(being link to a particular post, comment etc). Some notifications will just be a message hence the actor id and entity id being optional

Notification {
       message
       entity_id(foreign key)
       actor_id
}

Notification subscribers table(many to many) will capture users and their notifications

{
  user_id
 notification_id
} 

User story for Comment Added Event

user adds comment to a post get all users who have comments on the post including the original poster Notification - username has added a comment on post_title

blackmann commented 7 months ago

Thanks for this. Some comments:

  1. entity_id only captures the entity's id. But we can't tell what entity that is.
  2. We need to be able to know if a notification has been read by its recipient.
  3. What will be the purpose of the events table?
  4. We need to know when the notification was added.
auxibee commented 7 months ago
  1. We could add entity_type to capture if its a post/comment etc.
  2. Yeah a read field will be added to the notification subscribers.
  3. Yeah I think it is redundant
  4. Yeah sure a createdAtDate will be added.
auxibee commented 7 months ago

What about making it modular by separating the type of notifications ? We have have a different table for each type of notifications like comments notifications, post notification, community notifications etc. In this case each notification table will store its actor id and the comment/post /etc id We will fetch from notification subscribers and join all the notification tables.

blackmann commented 7 months ago

What benefits do we get from doing it like this?

auxibee commented 7 months ago

i was confused with how we will fetch the post/comment/etc of the notification with the initial approach and hence this new suggestion.

blackmann commented 7 months ago

You need to update the issue with the new fields, etc.

auxibee commented 7 months ago

Schema design

Notification {
id
message
actor_id
entity_id
entity_type
dateCreated
}

NotificationSuscribers{
id
notification_id
user_id
read
}
blackmann commented 6 months ago

Completed with #64