-
Notifications
You must be signed in to change notification settings - Fork 1
Notifications
Notifications in Forli is stored in notifications table and each user's notification mapping is stored in user_notifications table. The association between user and notification models is as follows:
user has many notificationsnotification has many users
Both the associations are stored through the user_notification table. In Rails, this is done by has_many :throughassociation.
API pattern for notifications: /api/v1/notifications
Forli creates a notification for a user when:
- A discussion is marked as spam by the spam filter
- A new answer is added to a discussion
- [TODO] A user is tagged in a discussion, answer or reply
The notification creation part is offloaded to the background jobs. The worker that handles this is: app/jobs/notification/notification_job.rb
Forli also has real-time broadcasts to the client through the use of Action Cable. Redis is used as the adapter for Action Cable.
The worker, after creating an entry in the database, also broadcasts to the notification channel.
[TODO] In the Ember app, ember-cable add-on is used to communicate with the channel.