-
Notifications
You must be signed in to change notification settings - Fork 887
feat(coderd): add mark-all-as-read endpoint for inbox notifications #16976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
coderd/database/dbmem/dbmem.go
Outdated
q.inboxNotifications[idx].ReadAt = sql.NullTime{ | ||
Time: dbtime.Now(), | ||
Valid: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't you use ReadAt
from arg
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if you have a use case in mind - having it as an arg would mean the user can set the notification as read 'in the past'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take a look at coderd/inboxnotifications.go
:
err := api.Database.MarkAllInboxNotificationsAsRead(ctx, database.MarkAllInboxNotificationsAsReadParams{
UserID: apikey.UserID,
ReadAt: sql.NullTime{Time: dbtime.Now(), Valid: true},
})
This is precisely how you're calling it. You need to go one way or another:
- Remove
ReadAt
from the arg. - Modify dbmem to take
dbtime.Now()
from coderd.
Let me know if this is clear. I can hop on zoom to explain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok sorry - I understood and indeed make sense :D Should be better - otherwise please tell me. 🙏
@defelmnq Feel free to re-request reviews when the PR is ready for another look 👍 . I'll watch email notifications. |
Should be all good for another review ✅ |
coderd/database/dbmem/dbmem.go
Outdated
q.inboxNotifications[idx].ReadAt = sql.NullTime{ | ||
Time: dbtime.Now(), | ||
Valid: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take a look at coderd/inboxnotifications.go
:
err := api.Database.MarkAllInboxNotificationsAsRead(ctx, database.MarkAllInboxNotificationsAsReadParams{
UserID: apikey.UserID,
ReadAt: sql.NullTime{Time: dbtime.Now(), Valid: true},
})
This is precisely how you're calling it. You need to go one way or another:
- Remove
ReadAt
from the arg. - Modify dbmem to take
dbtime.Now()
from coderd.
Let me know if this is clear. I can hop on zoom to explain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 👍
Resolve this issue
Add a mark-all-as-read endpoint which is marking as read all notifications that are not read for the authenticated user.
Also adds the DB logic.