-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Introduce Notifications CRUD Service #38327
Conversation
3eb723a
to
61fb59b
Compare
api/proto/teleport/notifications/v1/notifications_service.proto
Outdated
Show resolved
Hide resolved
api/proto/teleport/notifications/v1/notifications_service.proto
Outdated
Show resolved
Hide resolved
if !cfg.PreserveResourceID { | ||
notification = proto.Clone(notification).(*notificationsv1.Notification) | ||
//nolint:staticcheck // SA1019. Deprecated, but still needed. | ||
notification.Metadata.Id = 0 | ||
notification.Metadata.Revision = "" | ||
} |
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.
We could probably improve maybeResetProtoResourceID
to use types.SetRevision
and add an equivalent types.SetResource
so that it could be used. Not something you need to do here but a good example of where we fell slightly short in making these helpers support legacy and new resources.
|
||
// DeleteGlobalNotification deletes a global notification. | ||
func (s *NotificationsService) DeleteGlobalNotification(ctx context.Context, notificationId string) error { | ||
err := s.globalNotificationService.DeleteResource(ctx, notificationId) |
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.
Do we need to clean up any associated resources for the notification as well?
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.
Hmm, we would want to delete the notification states for this notification, but I don't think there is a performant way to do it here. We would need to list all notification states for all users, filter them for ones that are for this notification, and then loop through them and delete each one. I think this might be better if this was done during a periodic cleanup, what do you think?
23819f9
to
62e7db7
Compare
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.
Overall looks pretty good, just a few small things I hadn't noticed before.
1718af6
to
ca536aa
Compare
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.
Nice work @rudream!!
229f064
to
2595958
Compare
2595958
to
fdf95dc
Compare
Purpose
Part of #37704
This PR introduces the backend CRUD service for creating, updating, deleting and listing Notifications-related resources.
Note: The logic for fetching notifications for a user will be in a separate PR as that implementation is more complex.