Skip to content

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

Merged
merged 12 commits into from
Mar 20, 2025

Conversation

defelmnq
Copy link
Contributor

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.

@defelmnq defelmnq self-assigned this Mar 18, 2025
@defelmnq defelmnq requested a review from BrunoQuaresma March 18, 2025 13:52
@defelmnq defelmnq marked this pull request as ready for review March 18, 2025 17:56
Comment on lines 9509 to 9511
q.inboxNotifications[idx].ReadAt = sql.NullTime{
Time: dbtime.Now(),
Valid: true,
Copy link
Member

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?

Copy link
Contributor Author

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'.

Copy link
Member

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:

  1. Remove ReadAt from the arg.
  2. Modify dbmem to take dbtime.Now() from coderd.

Let me know if this is clear. I can hop on zoom to explain.

Copy link
Contributor Author

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. 🙏

@mtojek
Copy link
Member

mtojek commented Mar 19, 2025

@defelmnq Feel free to re-request reviews when the PR is ready for another look 👍 . I'll watch email notifications.

@defelmnq
Copy link
Contributor Author

Should be all good for another review ✅

Comment on lines 9509 to 9511
q.inboxNotifications[idx].ReadAt = sql.NullTime{
Time: dbtime.Now(),
Valid: true,
Copy link
Member

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:

  1. Remove ReadAt from the arg.
  2. Modify dbmem to take dbtime.Now() from coderd.

Let me know if this is clear. I can hop on zoom to explain.

@defelmnq defelmnq requested a review from mtojek March 20, 2025 12:19
Copy link
Member

@mtojek mtojek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

@defelmnq defelmnq merged commit 4960a1e into main Mar 20, 2025
32 checks passed
@defelmnq defelmnq deleted the coder-inbox/internal-506 branch March 20, 2025 12:41
@github-actions github-actions bot locked and limited conversation to collaborators Mar 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants