From 6af1c3b021a44057b5fcfe967bf1dceba8e3ffe9 Mon Sep 17 00:00:00 2001 From: Christian Carlsson Date: Mon, 2 Dec 2024 18:21:57 +0000 Subject: [PATCH] empty request --- protobufs/api/v1/notifications.proto | 3 +- .../v1/apiv1connect/notifications.connect.go | 13 +- server/pkg/pb/api/v1/notifications.pb.go | 144 +++++++++++------- server/rpc/v1/notification.go | 3 +- web/src/proto/api/v1/notifications_pb.ts | 20 ++- web/src/stores/notifications.ts | 5 +- 6 files changed, 120 insertions(+), 68 deletions(-) diff --git a/protobufs/api/v1/notifications.proto b/protobufs/api/v1/notifications.proto index 6afc1fb1..5abee28b 100644 --- a/protobufs/api/v1/notifications.proto +++ b/protobufs/api/v1/notifications.proto @@ -14,7 +14,7 @@ service NotificationService { rpc ListNotifications (ListNotificationsRequest) returns (ListNotificationsResponse) { option (auth) = true; } - rpc UnreadNotifications (google.protobuf.Empty) returns (stream UnreadNotificationsResponse) { + rpc UnreadNotifications (UnreadNotificationsRequest) returns (stream UnreadNotificationsResponse) { option (auth) = true; } } @@ -47,6 +47,7 @@ message Notification { } } +message UnreadNotificationsRequest {} message UnreadNotificationsResponse { int64 count = 1; } diff --git a/server/pkg/pb/api/v1/apiv1connect/notifications.connect.go b/server/pkg/pb/api/v1/apiv1connect/notifications.connect.go index 6d3e50b1..f7ccf6c5 100644 --- a/server/pkg/pb/api/v1/apiv1connect/notifications.connect.go +++ b/server/pkg/pb/api/v1/apiv1connect/notifications.connect.go @@ -12,7 +12,6 @@ import ( connect "connectrpc.com/connect" v1 "github.com/crlssn/getstronger/server/pkg/pb/api/v1" - emptypb "google.golang.org/protobuf/types/known/emptypb" ) // This is a compile-time assertion to ensure that this generated file and the connect package are @@ -53,7 +52,7 @@ var ( // NotificationServiceClient is a client for the api.v1.NotificationService service. type NotificationServiceClient interface { ListNotifications(context.Context, *connect.Request[v1.ListNotificationsRequest]) (*connect.Response[v1.ListNotificationsResponse], error) - UnreadNotifications(context.Context, *connect.Request[emptypb.Empty]) (*connect.ServerStreamForClient[v1.UnreadNotificationsResponse], error) + UnreadNotifications(context.Context, *connect.Request[v1.UnreadNotificationsRequest]) (*connect.ServerStreamForClient[v1.UnreadNotificationsResponse], error) } // NewNotificationServiceClient constructs a client for the api.v1.NotificationService service. By @@ -72,7 +71,7 @@ func NewNotificationServiceClient(httpClient connect.HTTPClient, baseURL string, connect.WithSchema(notificationServiceListNotificationsMethodDescriptor), connect.WithClientOptions(opts...), ), - unreadNotifications: connect.NewClient[emptypb.Empty, v1.UnreadNotificationsResponse]( + unreadNotifications: connect.NewClient[v1.UnreadNotificationsRequest, v1.UnreadNotificationsResponse]( httpClient, baseURL+NotificationServiceUnreadNotificationsProcedure, connect.WithSchema(notificationServiceUnreadNotificationsMethodDescriptor), @@ -84,7 +83,7 @@ func NewNotificationServiceClient(httpClient connect.HTTPClient, baseURL string, // notificationServiceClient implements NotificationServiceClient. type notificationServiceClient struct { listNotifications *connect.Client[v1.ListNotificationsRequest, v1.ListNotificationsResponse] - unreadNotifications *connect.Client[emptypb.Empty, v1.UnreadNotificationsResponse] + unreadNotifications *connect.Client[v1.UnreadNotificationsRequest, v1.UnreadNotificationsResponse] } // ListNotifications calls api.v1.NotificationService.ListNotifications. @@ -93,14 +92,14 @@ func (c *notificationServiceClient) ListNotifications(ctx context.Context, req * } // UnreadNotifications calls api.v1.NotificationService.UnreadNotifications. -func (c *notificationServiceClient) UnreadNotifications(ctx context.Context, req *connect.Request[emptypb.Empty]) (*connect.ServerStreamForClient[v1.UnreadNotificationsResponse], error) { +func (c *notificationServiceClient) UnreadNotifications(ctx context.Context, req *connect.Request[v1.UnreadNotificationsRequest]) (*connect.ServerStreamForClient[v1.UnreadNotificationsResponse], error) { return c.unreadNotifications.CallServerStream(ctx, req) } // NotificationServiceHandler is an implementation of the api.v1.NotificationService service. type NotificationServiceHandler interface { ListNotifications(context.Context, *connect.Request[v1.ListNotificationsRequest]) (*connect.Response[v1.ListNotificationsResponse], error) - UnreadNotifications(context.Context, *connect.Request[emptypb.Empty], *connect.ServerStream[v1.UnreadNotificationsResponse]) error + UnreadNotifications(context.Context, *connect.Request[v1.UnreadNotificationsRequest], *connect.ServerStream[v1.UnreadNotificationsResponse]) error } // NewNotificationServiceHandler builds an HTTP handler from the service implementation. It returns @@ -140,6 +139,6 @@ func (UnimplementedNotificationServiceHandler) ListNotifications(context.Context return nil, connect.NewError(connect.CodeUnimplemented, errors.New("api.v1.NotificationService.ListNotifications is not implemented")) } -func (UnimplementedNotificationServiceHandler) UnreadNotifications(context.Context, *connect.Request[emptypb.Empty], *connect.ServerStream[v1.UnreadNotificationsResponse]) error { +func (UnimplementedNotificationServiceHandler) UnreadNotifications(context.Context, *connect.Request[v1.UnreadNotificationsRequest], *connect.ServerStream[v1.UnreadNotificationsResponse]) error { return connect.NewError(connect.CodeUnimplemented, errors.New("api.v1.NotificationService.UnreadNotifications is not implemented")) } diff --git a/server/pkg/pb/api/v1/notifications.pb.go b/server/pkg/pb/api/v1/notifications.pb.go index dc6c7740..ba75d5a9 100644 --- a/server/pkg/pb/api/v1/notifications.pb.go +++ b/server/pkg/pb/api/v1/notifications.pb.go @@ -13,7 +13,7 @@ import ( _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - emptypb "google.golang.org/protobuf/types/known/emptypb" + _ "google.golang.org/protobuf/types/known/emptypb" ) const ( @@ -233,6 +233,42 @@ func (*Notification_UserFollowed_) isNotification_Type() {} func (*Notification_WorkoutComment_) isNotification_Type() {} +type UnreadNotificationsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *UnreadNotificationsRequest) Reset() { + *x = UnreadNotificationsRequest{} + mi := &file_api_v1_notifications_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UnreadNotificationsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UnreadNotificationsRequest) ProtoMessage() {} + +func (x *UnreadNotificationsRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_v1_notifications_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UnreadNotificationsRequest.ProtoReflect.Descriptor instead. +func (*UnreadNotificationsRequest) Descriptor() ([]byte, []int) { + return file_api_v1_notifications_proto_rawDescGZIP(), []int{3} +} + type UnreadNotificationsResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -243,7 +279,7 @@ type UnreadNotificationsResponse struct { func (x *UnreadNotificationsResponse) Reset() { *x = UnreadNotificationsResponse{} - mi := &file_api_v1_notifications_proto_msgTypes[3] + mi := &file_api_v1_notifications_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -255,7 +291,7 @@ func (x *UnreadNotificationsResponse) String() string { func (*UnreadNotificationsResponse) ProtoMessage() {} func (x *UnreadNotificationsResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_v1_notifications_proto_msgTypes[3] + mi := &file_api_v1_notifications_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -268,7 +304,7 @@ func (x *UnreadNotificationsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use UnreadNotificationsResponse.ProtoReflect.Descriptor instead. func (*UnreadNotificationsResponse) Descriptor() ([]byte, []int) { - return file_api_v1_notifications_proto_rawDescGZIP(), []int{3} + return file_api_v1_notifications_proto_rawDescGZIP(), []int{4} } func (x *UnreadNotificationsResponse) GetCount() int64 { @@ -288,7 +324,7 @@ type Notification_UserFollowed struct { func (x *Notification_UserFollowed) Reset() { *x = Notification_UserFollowed{} - mi := &file_api_v1_notifications_proto_msgTypes[4] + mi := &file_api_v1_notifications_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -300,7 +336,7 @@ func (x *Notification_UserFollowed) String() string { func (*Notification_UserFollowed) ProtoMessage() {} func (x *Notification_UserFollowed) ProtoReflect() protoreflect.Message { - mi := &file_api_v1_notifications_proto_msgTypes[4] + mi := &file_api_v1_notifications_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -334,7 +370,7 @@ type Notification_WorkoutComment struct { func (x *Notification_WorkoutComment) Reset() { *x = Notification_WorkoutComment{} - mi := &file_api_v1_notifications_proto_msgTypes[5] + mi := &file_api_v1_notifications_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -346,7 +382,7 @@ func (x *Notification_WorkoutComment) String() string { func (*Notification_WorkoutComment) ProtoMessage() {} func (x *Notification_WorkoutComment) ProtoReflect() protoreflect.Message { - mi := &file_api_v1_notifications_proto_msgTypes[5] + mi := &file_api_v1_notifications_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -432,34 +468,36 @@ var file_api_v1_notifications_proto_rawDesc = []byte{ 0x72, 0x52, 0x05, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x29, 0x0a, 0x07, 0x77, 0x6f, 0x72, 0x6b, 0x6f, 0x75, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x6f, 0x75, 0x74, 0x52, 0x07, 0x77, 0x6f, 0x72, 0x6b, - 0x6f, 0x75, 0x74, 0x42, 0x06, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x33, 0x0a, 0x1b, 0x55, + 0x6f, 0x75, 0x74, 0x42, 0x06, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x1c, 0x0a, 0x1a, 0x55, 0x6e, 0x72, 0x65, 0x61, 0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x32, 0xd1, 0x01, 0x0a, 0x13, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5e, 0x0a, 0x11, 0x4c, 0x69, 0x73, 0x74, - 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x20, 0x2e, + 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x33, 0x0a, 0x1b, 0x55, 0x6e, 0x72, + 0x65, 0x61, 0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x32, 0xdd, + 0x01, 0x0a, 0x13, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5e, 0x0a, 0x11, 0x4c, 0x69, 0x73, 0x74, 0x4e, 0x6f, + 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x20, 0x2e, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4e, 0x6f, 0x74, 0x69, 0x66, - 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x21, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4e, 0x6f, 0x74, - 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x04, 0x88, 0xb5, 0x18, 0x01, 0x12, 0x5a, 0x0a, 0x13, 0x55, 0x6e, 0x72, 0x65, - 0x61, 0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, - 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x23, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, - 0x2e, 0x55, 0x6e, 0x72, 0x65, 0x61, 0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x04, 0x88, 0xb5, - 0x18, 0x01, 0x30, 0x01, 0x42, 0x93, 0x01, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x31, 0x42, 0x12, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x72, 0x6c, 0x73, 0x73, 0x6e, 0x2f, 0x67, 0x65, 0x74, - 0x73, 0x74, 0x72, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, - 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x3b, 0x61, 0x70, - 0x69, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x41, 0x58, 0x58, 0xaa, 0x02, 0x06, 0x41, 0x70, 0x69, 0x2e, - 0x56, 0x31, 0xca, 0x02, 0x06, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x12, 0x41, 0x70, - 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0xea, 0x02, 0x07, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x04, 0x88, 0xb5, 0x18, 0x01, 0x12, 0x66, 0x0a, 0x13, 0x55, 0x6e, 0x72, 0x65, 0x61, 0x64, + 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x22, 0x2e, + 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x6e, 0x72, 0x65, 0x61, 0x64, 0x4e, 0x6f, 0x74, + 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x23, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x6e, 0x72, 0x65, 0x61, + 0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x04, 0x88, 0xb5, 0x18, 0x01, 0x30, 0x01, 0x42, 0x93, + 0x01, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x42, 0x12, 0x4e, + 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x50, 0x72, 0x6f, 0x74, + 0x6f, 0x50, 0x01, 0x5a, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x63, 0x72, 0x6c, 0x73, 0x73, 0x6e, 0x2f, 0x67, 0x65, 0x74, 0x73, 0x74, 0x72, 0x6f, 0x6e, 0x67, + 0x65, 0x72, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, + 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x3b, 0x61, 0x70, 0x69, 0x76, 0x31, 0xa2, 0x02, 0x03, + 0x41, 0x58, 0x58, 0xaa, 0x02, 0x06, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x06, 0x41, + 0x70, 0x69, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x12, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x47, + 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x07, 0x41, 0x70, 0x69, + 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -474,33 +512,33 @@ func file_api_v1_notifications_proto_rawDescGZIP() []byte { return file_api_v1_notifications_proto_rawDescData } -var file_api_v1_notifications_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_api_v1_notifications_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_api_v1_notifications_proto_goTypes = []any{ (*ListNotificationsRequest)(nil), // 0: api.v1.ListNotificationsRequest (*ListNotificationsResponse)(nil), // 1: api.v1.ListNotificationsResponse (*Notification)(nil), // 2: api.v1.Notification - (*UnreadNotificationsResponse)(nil), // 3: api.v1.UnreadNotificationsResponse - (*Notification_UserFollowed)(nil), // 4: api.v1.Notification.UserFollowed - (*Notification_WorkoutComment)(nil), // 5: api.v1.Notification.WorkoutComment - (*PaginationRequest)(nil), // 6: api.v1.PaginationRequest - (*PaginationResponse)(nil), // 7: api.v1.PaginationResponse - (*User)(nil), // 8: api.v1.User - (*Workout)(nil), // 9: api.v1.Workout - (*emptypb.Empty)(nil), // 10: google.protobuf.Empty + (*UnreadNotificationsRequest)(nil), // 3: api.v1.UnreadNotificationsRequest + (*UnreadNotificationsResponse)(nil), // 4: api.v1.UnreadNotificationsResponse + (*Notification_UserFollowed)(nil), // 5: api.v1.Notification.UserFollowed + (*Notification_WorkoutComment)(nil), // 6: api.v1.Notification.WorkoutComment + (*PaginationRequest)(nil), // 7: api.v1.PaginationRequest + (*PaginationResponse)(nil), // 8: api.v1.PaginationResponse + (*User)(nil), // 9: api.v1.User + (*Workout)(nil), // 10: api.v1.Workout } var file_api_v1_notifications_proto_depIdxs = []int32{ - 6, // 0: api.v1.ListNotificationsRequest.pagination:type_name -> api.v1.PaginationRequest + 7, // 0: api.v1.ListNotificationsRequest.pagination:type_name -> api.v1.PaginationRequest 2, // 1: api.v1.ListNotificationsResponse.notifications:type_name -> api.v1.Notification - 7, // 2: api.v1.ListNotificationsResponse.pagination:type_name -> api.v1.PaginationResponse - 4, // 3: api.v1.Notification.user_followed:type_name -> api.v1.Notification.UserFollowed - 5, // 4: api.v1.Notification.workout_comment:type_name -> api.v1.Notification.WorkoutComment - 8, // 5: api.v1.Notification.UserFollowed.actor:type_name -> api.v1.User - 8, // 6: api.v1.Notification.WorkoutComment.actor:type_name -> api.v1.User - 9, // 7: api.v1.Notification.WorkoutComment.workout:type_name -> api.v1.Workout + 8, // 2: api.v1.ListNotificationsResponse.pagination:type_name -> api.v1.PaginationResponse + 5, // 3: api.v1.Notification.user_followed:type_name -> api.v1.Notification.UserFollowed + 6, // 4: api.v1.Notification.workout_comment:type_name -> api.v1.Notification.WorkoutComment + 9, // 5: api.v1.Notification.UserFollowed.actor:type_name -> api.v1.User + 9, // 6: api.v1.Notification.WorkoutComment.actor:type_name -> api.v1.User + 10, // 7: api.v1.Notification.WorkoutComment.workout:type_name -> api.v1.Workout 0, // 8: api.v1.NotificationService.ListNotifications:input_type -> api.v1.ListNotificationsRequest - 10, // 9: api.v1.NotificationService.UnreadNotifications:input_type -> google.protobuf.Empty + 3, // 9: api.v1.NotificationService.UnreadNotifications:input_type -> api.v1.UnreadNotificationsRequest 1, // 10: api.v1.NotificationService.ListNotifications:output_type -> api.v1.ListNotificationsResponse - 3, // 11: api.v1.NotificationService.UnreadNotifications:output_type -> api.v1.UnreadNotificationsResponse + 4, // 11: api.v1.NotificationService.UnreadNotifications:output_type -> api.v1.UnreadNotificationsResponse 10, // [10:12] is the sub-list for method output_type 8, // [8:10] is the sub-list for method input_type 8, // [8:8] is the sub-list for extension type_name @@ -526,7 +564,7 @@ func file_api_v1_notifications_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_api_v1_notifications_proto_rawDesc, NumEnums: 0, - NumMessages: 6, + NumMessages: 7, NumExtensions: 0, NumServices: 1, }, diff --git a/server/rpc/v1/notification.go b/server/rpc/v1/notification.go index c1f75b7f..54a6075e 100644 --- a/server/rpc/v1/notification.go +++ b/server/rpc/v1/notification.go @@ -7,7 +7,6 @@ import ( "connectrpc.com/connect" "go.uber.org/zap" - "google.golang.org/protobuf/types/known/emptypb" "github.com/crlssn/getstronger/server/pkg/orm" v1 "github.com/crlssn/getstronger/server/pkg/pb/api/v1" @@ -109,7 +108,7 @@ func (h *notificationHandler) ListNotifications(ctx context.Context, req *connec }, nil } -func (h *notificationHandler) UnreadNotifications(ctx context.Context, _ *connect.Request[emptypb.Empty], res *connect.ServerStream[v1.UnreadNotificationsResponse]) error { +func (h *notificationHandler) UnreadNotifications(ctx context.Context, _ *connect.Request[v1.UnreadNotificationsRequest], res *connect.ServerStream[v1.UnreadNotificationsResponse]) error { log := xcontext.MustExtractLogger(ctx) userID := xcontext.MustExtractUserID(ctx) diff --git a/web/src/proto/api/v1/notifications_pb.ts b/web/src/proto/api/v1/notifications_pb.ts index fd45b7b0..bbd372d5 100644 --- a/web/src/proto/api/v1/notifications_pb.ts +++ b/web/src/proto/api/v1/notifications_pb.ts @@ -9,7 +9,6 @@ import type { PaginationRequest, PaginationResponse, User } from "./shared_pb"; import { file_api_v1_shared } from "./shared_pb"; import type { Workout } from "./workouts_pb"; import { file_api_v1_workouts } from "./workouts_pb"; -import type { EmptySchema } from "@bufbuild/protobuf/wkt"; import { file_google_protobuf_empty } from "@bufbuild/protobuf/wkt"; import { file_buf_validate_validate } from "../../buf/validate/validate_pb"; import type { Message } from "@bufbuild/protobuf"; @@ -18,7 +17,7 @@ import type { Message } from "@bufbuild/protobuf"; * Describes the file api/v1/notifications.proto. */ export const file_api_v1_notifications: GenFile = /*@__PURE__*/ - fileDesc("ChphcGkvdjEvbm90aWZpY2F0aW9ucy5wcm90bxIGYXBpLnYxInwKGExpc3ROb3RpZmljYXRpb25zUmVxdWVzdBITCgt1bnJlYWRfb25seRgBIAEoCBIUCgxtYXJrX2FzX3JlYWQYAiABKAgSNQoKcGFnaW5hdGlvbhgDIAEoCzIZLmFwaS52MS5QYWdpbmF0aW9uUmVxdWVzdEIGukgDyAEBIngKGUxpc3ROb3RpZmljYXRpb25zUmVzcG9uc2USKwoNbm90aWZpY2F0aW9ucxgBIAMoCzIULmFwaS52MS5Ob3RpZmljYXRpb24SLgoKcGFnaW5hdGlvbhgCIAEoCzIaLmFwaS52MS5QYWdpbmF0aW9uUmVzcG9uc2UitgIKDE5vdGlmaWNhdGlvbhIKCgJpZBgBIAEoCRIYChBub3RpZmllZF9hdF91bml4GAIgASgDEjoKDXVzZXJfZm9sbG93ZWQYAyABKAsyIS5hcGkudjEuTm90aWZpY2F0aW9uLlVzZXJGb2xsb3dlZEgAEj4KD3dvcmtvdXRfY29tbWVudBgEIAEoCzIjLmFwaS52MS5Ob3RpZmljYXRpb24uV29ya291dENvbW1lbnRIABorCgxVc2VyRm9sbG93ZWQSGwoFYWN0b3IYASABKAsyDC5hcGkudjEuVXNlchpPCg5Xb3Jrb3V0Q29tbWVudBIbCgVhY3RvchgBIAEoCzIMLmFwaS52MS5Vc2VyEiAKB3dvcmtvdXQYAiABKAsyDy5hcGkudjEuV29ya291dEIGCgR0eXBlIiwKG1VucmVhZE5vdGlmaWNhdGlvbnNSZXNwb25zZRINCgVjb3VudBgBIAEoAzLRAQoTTm90aWZpY2F0aW9uU2VydmljZRJeChFMaXN0Tm90aWZpY2F0aW9ucxIgLmFwaS52MS5MaXN0Tm90aWZpY2F0aW9uc1JlcXVlc3QaIS5hcGkudjEuTGlzdE5vdGlmaWNhdGlvbnNSZXNwb25zZSIEiLUYARJaChNVbnJlYWROb3RpZmljYXRpb25zEhYuZ29vZ2xlLnByb3RvYnVmLkVtcHR5GiMuYXBpLnYxLlVucmVhZE5vdGlmaWNhdGlvbnNSZXNwb25zZSIEiLUYATABQpMBCgpjb20uYXBpLnYxQhJOb3RpZmljYXRpb25zUHJvdG9QAVo4Z2l0aHViLmNvbS9jcmxzc24vZ2V0c3Ryb25nZXIvc2VydmVyL3BrZy9wYi9hcGkvdjE7YXBpdjGiAgNBWFiqAgZBcGkuVjHKAgZBcGlcVjHiAhJBcGlcVjFcR1BCTWV0YWRhdGHqAgdBcGk6OlYxYgZwcm90bzM", [file_api_v1_options, file_api_v1_shared, file_api_v1_workouts, file_google_protobuf_empty, file_buf_validate_validate]); + fileDesc("ChphcGkvdjEvbm90aWZpY2F0aW9ucy5wcm90bxIGYXBpLnYxInwKGExpc3ROb3RpZmljYXRpb25zUmVxdWVzdBITCgt1bnJlYWRfb25seRgBIAEoCBIUCgxtYXJrX2FzX3JlYWQYAiABKAgSNQoKcGFnaW5hdGlvbhgDIAEoCzIZLmFwaS52MS5QYWdpbmF0aW9uUmVxdWVzdEIGukgDyAEBIngKGUxpc3ROb3RpZmljYXRpb25zUmVzcG9uc2USKwoNbm90aWZpY2F0aW9ucxgBIAMoCzIULmFwaS52MS5Ob3RpZmljYXRpb24SLgoKcGFnaW5hdGlvbhgCIAEoCzIaLmFwaS52MS5QYWdpbmF0aW9uUmVzcG9uc2UitgIKDE5vdGlmaWNhdGlvbhIKCgJpZBgBIAEoCRIYChBub3RpZmllZF9hdF91bml4GAIgASgDEjoKDXVzZXJfZm9sbG93ZWQYAyABKAsyIS5hcGkudjEuTm90aWZpY2F0aW9uLlVzZXJGb2xsb3dlZEgAEj4KD3dvcmtvdXRfY29tbWVudBgEIAEoCzIjLmFwaS52MS5Ob3RpZmljYXRpb24uV29ya291dENvbW1lbnRIABorCgxVc2VyRm9sbG93ZWQSGwoFYWN0b3IYASABKAsyDC5hcGkudjEuVXNlchpPCg5Xb3Jrb3V0Q29tbWVudBIbCgVhY3RvchgBIAEoCzIMLmFwaS52MS5Vc2VyEiAKB3dvcmtvdXQYAiABKAsyDy5hcGkudjEuV29ya291dEIGCgR0eXBlIhwKGlVucmVhZE5vdGlmaWNhdGlvbnNSZXF1ZXN0IiwKG1VucmVhZE5vdGlmaWNhdGlvbnNSZXNwb25zZRINCgVjb3VudBgBIAEoAzLdAQoTTm90aWZpY2F0aW9uU2VydmljZRJeChFMaXN0Tm90aWZpY2F0aW9ucxIgLmFwaS52MS5MaXN0Tm90aWZpY2F0aW9uc1JlcXVlc3QaIS5hcGkudjEuTGlzdE5vdGlmaWNhdGlvbnNSZXNwb25zZSIEiLUYARJmChNVbnJlYWROb3RpZmljYXRpb25zEiIuYXBpLnYxLlVucmVhZE5vdGlmaWNhdGlvbnNSZXF1ZXN0GiMuYXBpLnYxLlVucmVhZE5vdGlmaWNhdGlvbnNSZXNwb25zZSIEiLUYATABQpMBCgpjb20uYXBpLnYxQhJOb3RpZmljYXRpb25zUHJvdG9QAVo4Z2l0aHViLmNvbS9jcmxzc24vZ2V0c3Ryb25nZXIvc2VydmVyL3BrZy9wYi9hcGkvdjE7YXBpdjGiAgNBWFiqAgZBcGkuVjHKAgZBcGlcVjHiAhJBcGlcVjFcR1BCTWV0YWRhdGHqAgdBcGk6OlYxYgZwcm90bzM", [file_api_v1_options, file_api_v1_shared, file_api_v1_workouts, file_google_protobuf_empty, file_buf_validate_validate]); /** * @generated from message api.v1.ListNotificationsRequest @@ -149,6 +148,19 @@ export type Notification_WorkoutComment = Message<"api.v1.Notification.WorkoutCo export const Notification_WorkoutCommentSchema: GenMessage = /*@__PURE__*/ messageDesc(file_api_v1_notifications, 2, 1); +/** + * @generated from message api.v1.UnreadNotificationsRequest + */ +export type UnreadNotificationsRequest = Message<"api.v1.UnreadNotificationsRequest"> & { +}; + +/** + * Describes the message api.v1.UnreadNotificationsRequest. + * Use `create(UnreadNotificationsRequestSchema)` to create a new message. + */ +export const UnreadNotificationsRequestSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_api_v1_notifications, 3); + /** * @generated from message api.v1.UnreadNotificationsResponse */ @@ -164,7 +176,7 @@ export type UnreadNotificationsResponse = Message<"api.v1.UnreadNotificationsRes * Use `create(UnreadNotificationsResponseSchema)` to create a new message. */ export const UnreadNotificationsResponseSchema: GenMessage = /*@__PURE__*/ - messageDesc(file_api_v1_notifications, 3); + messageDesc(file_api_v1_notifications, 4); /** * @generated from service api.v1.NotificationService @@ -183,7 +195,7 @@ export const NotificationService: GenService<{ */ unreadNotifications: { methodKind: "server_streaming"; - input: typeof EmptySchema; + input: typeof UnreadNotificationsRequestSchema; output: typeof UnreadNotificationsResponseSchema; }, }> = /*@__PURE__*/ diff --git a/web/src/stores/notifications.ts b/web/src/stores/notifications.ts index 59e2134a..6dff47bc 100644 --- a/web/src/stores/notifications.ts +++ b/web/src/stores/notifications.ts @@ -1,12 +1,15 @@ import { ref } from 'vue' import { defineStore } from 'pinia' +import { create } from '@bufbuild/protobuf' import { NotificationClient } from '@/clients/clients.ts' +import { UnreadNotificationsRequestSchema } from '@/proto/api/v1/notifications_pb.ts' export const useNotificationStore = defineStore('notifications', () => { const unreadCount = ref(0) const streamUnreadNotifications = async () => { - const stream = NotificationClient.unreadNotifications({}) + const req = create(UnreadNotificationsRequestSchema, {}) + const stream = NotificationClient.unreadNotifications(req) for await (const message of stream) { unreadCount.value = Number(message.count) }