We want to show notifications to users when someone comments on their post.
Task
Create Notification model containing -
post_id
username
comment_author
created_at
clicked
When someone comments on a post, create a new Notification entry in db where post_id is the post where someone commented. username is whom's post someone commented. comment_author is the username of the commenter. created_at is the time.now() and clicked is false.
Create an endpoint /api/notification/:username GET to get notifications of a user by username.
Create an endpoint /api/notification/:id/clicked POST to make clicked true for the user. Please ensure that the token user and the clicked notification's username is same, otherwise throw error.
Context
We want to show notifications to users when someone comments on their post.
Task
Notification
entry in db wherepost_id
is the post where someone commented.username
is whom's post someone commented.comment_author
is the username of the commenter.created_at
is the time.now() andclicked
is false./api/notification/:username
GET to get notifications of a user by username./api/notification/:id/clicked
POST to makeclicked
true for the user. Please ensure that the token user and the clicked notification'susername
is same, otherwise throw error.