mirror of
https://github.com/gravitational/teleport.git
synced 2026-11-03 16:38:35 +08:00
implement listing notifications for a user with matching (#39942)
This commit is contained in:
@@ -76,6 +76,7 @@ import (
|
||||
kubewaitingcontainerpb "github.com/gravitational/teleport/api/gen/proto/go/teleport/kubewaitingcontainer/v1"
|
||||
loginrulepb "github.com/gravitational/teleport/api/gen/proto/go/teleport/loginrule/v1"
|
||||
machineidv1pb "github.com/gravitational/teleport/api/gen/proto/go/teleport/machineid/v1"
|
||||
notificationsv1pb "github.com/gravitational/teleport/api/gen/proto/go/teleport/notifications/v1"
|
||||
oktapb "github.com/gravitational/teleport/api/gen/proto/go/teleport/okta/v1"
|
||||
pluginspb "github.com/gravitational/teleport/api/gen/proto/go/teleport/plugins/v1"
|
||||
presencepb "github.com/gravitational/teleport/api/gen/proto/go/teleport/presence/v1"
|
||||
@@ -111,6 +112,7 @@ type AuthServiceClient struct {
|
||||
assist.AssistServiceClient
|
||||
auditlogpb.AuditLogServiceClient
|
||||
userpreferencespb.UserPreferencesServiceClient
|
||||
notificationsv1pb.NotificationServiceClient
|
||||
}
|
||||
|
||||
// Client is a gRPC Client that connects to a Teleport Auth server either
|
||||
@@ -522,6 +524,7 @@ func (c *Client) dialGRPC(ctx context.Context, addr string) error {
|
||||
AssistServiceClient: assist.NewAssistServiceClient(c.conn),
|
||||
AuditLogServiceClient: auditlogpb.NewAuditLogServiceClient(c.conn),
|
||||
UserPreferencesServiceClient: userpreferencespb.NewUserPreferencesServiceClient(c.conn),
|
||||
NotificationServiceClient: notificationsv1pb.NewNotificationServiceClient(c.conn),
|
||||
}
|
||||
c.JoinServiceClient = NewJoinServiceClient(proto.NewJoinServiceClient(c.conn))
|
||||
|
||||
@@ -865,6 +868,11 @@ func (c *Client) WorkloadIdentityServiceClient() machineidv1pb.WorkloadIdentityS
|
||||
return machineidv1pb.NewWorkloadIdentityServiceClient(c.conn)
|
||||
}
|
||||
|
||||
// NotificationServiceClient returns a notification service client that can be used to fetch notifications.
|
||||
func (c *Client) NotificationServiceClient() notificationsv1pb.NotificationServiceClient {
|
||||
return notificationsv1pb.NewNotificationServiceClient(c.conn)
|
||||
}
|
||||
|
||||
// Ping gets basic info about the auth server.
|
||||
func (c *Client) Ping(ctx context.Context) (proto.PingResponse, error) {
|
||||
rsp, err := c.grpc.Ping(ctx, &proto.PingRequest{})
|
||||
@@ -4899,6 +4907,25 @@ func (c *Client) UpsertUserPreferences(ctx context.Context, in *userpreferencesp
|
||||
return nil
|
||||
}
|
||||
|
||||
// ListNotifications returns a paginated list of notifications for the user.
|
||||
// This includes global notifications which match the user, as well as user-specific notifications for the user.
|
||||
func (c *Client) ListNotifications(ctx context.Context, req *notificationsv1pb.ListNotificationsRequest) (*notificationsv1pb.ListNotificationsResponse, error) {
|
||||
rsp, err := c.NotificationServiceClient().ListNotifications(ctx, req)
|
||||
return rsp, trace.Wrap(err)
|
||||
}
|
||||
|
||||
// UpsertUserNotificationState creates or updates a user notification state which records whether the user has clicked on or dismissed a notification.
|
||||
func (c *Client) UpsertUserNotificationState(ctx context.Context, req *notificationsv1pb.UpsertUserNotificationStateRequest) (*notificationsv1pb.UserNotificationState, error) {
|
||||
rsp, err := c.NotificationServiceClient().UpsertUserNotificationState(ctx, req)
|
||||
return rsp, trace.Wrap(err)
|
||||
}
|
||||
|
||||
// UpsertUserLastSeenNotification creates or updates a user's last seen notification timestamp.
|
||||
func (c *Client) UpsertUserLastSeenNotification(ctx context.Context, req *notificationsv1pb.UpsertUserLastSeenNotificationRequest) (*notificationsv1pb.UserLastSeenNotification, error) {
|
||||
rsp, err := c.NotificationServiceClient().UpsertUserLastSeenNotification(ctx, req)
|
||||
return rsp, trace.Wrap(err)
|
||||
}
|
||||
|
||||
// ResourceUsageClient returns an unadorned Resource Usage service client,
|
||||
// using the underlying Auth gRPC connection.
|
||||
// Clients connecting to non-Enterprise clusters, or older Teleport versions,
|
||||
|
||||
Reference in New Issue
Block a user