From 7a548ac24e5cc88545e2859f8187739b6b9dce87 Mon Sep 17 00:00:00 2001 From: SpeedReach <37238439+SpeedReach@users.noreply.github.com> Date: Mon, 3 Jun 2024 13:17:25 +0800 Subject: [PATCH] feature: add security for certain swagger routes --- README.md | Bin 22 -> 54 bytes internal/services/group/get_members.go | 53 ++++ protobuf/gen/go/group.pb.go | 324 +++++++++++++++++++++---- protobuf/gen/go/group.pb.gw.go | 103 ++++++++ protobuf/gen/go/group_grpc.pb.go | 64 ++++- protobuf/gen/monify.swagger.json | 37 +-- protobuf/group.proto | 29 ++- 7 files changed, 524 insertions(+), 86 deletions(-) create mode 100644 internal/services/group/get_members.go diff --git a/README.md b/README.md index 9ef7b97cc04d4412d2adc216c24d1658ac370593..6c1c3056a4915a73d0ebcc5e6c06598a97a76398 100644 GIT binary patch literal 54 vcmezWPnjW?A)g_SA(J7Ep^|}@feVat84?+?8B!S(7)pR-F_2UMLYOQ7J9P-n literal 22 dcmezWPnki1A(tVaA&()GA&sGuftP`c0RT)y1nK|) diff --git a/internal/services/group/get_members.go b/internal/services/group/get_members.go new file mode 100644 index 0000000..2af1a5b --- /dev/null +++ b/internal/services/group/get_members.go @@ -0,0 +1,53 @@ +package group + +import ( + "context" + "database/sql" + "github.com/google/uuid" + "go.uber.org/zap" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "monify/internal/middlewares" + monify "monify/protobuf/gen/go" +) + +func (s Service) GetGroupMembers(ctx context.Context, req *monify.GetGroupMembersRequest) (*monify.GetGroupMembersResponse, error) { + userId, ok := ctx.Value(middlewares.UserIdContextKey{}).(uuid.UUID) + if !ok { + return nil, status.Error(codes.Internal, "user id not found in context") + } + groupId, err := uuid.Parse(req.GroupId) + if err != nil { + return nil, status.Error(codes.InvalidArgument, "invalid group id") + } + db := ctx.Value(middlewares.StorageContextKey{}).(*sql.DB) + logger := ctx.Value(middlewares.LoggerContextKey{}).(*zap.Logger) + permission, err := CheckPermission(ctx, db, groupId, userId) + if err != nil { + logger.Error("failed to check permission", zap.Error(err)) + return nil, status.Error(codes.Internal, "failed to check permission") + } + if !permission { + return nil, status.Error(codes.PermissionDenied, "permission denied") + } + + rows, err := db.QueryContext(ctx, ` + SELECT gm.user_id, gm.group_member_id, ui.name + FROM group_member gm + LEFT JOIN user_identity ui on gm.user_id = ui.user_id + WHERE group_id = $1 + `, groupId) + if err != nil { + return nil, status.Error(codes.Internal, "failed to fetch group members") + } + defer rows.Close() + var members []*monify.GroupMember + for rows.Next() { + var member monify.GroupMember + if err := rows.Scan(&member.UserId, &member.MemberId, &member.UserName); err != nil { + return nil, status.Error(codes.Internal, "failed to fetch group members") + } + members = append(members, &member) + } + return &monify.GetGroupMembersResponse{Members: members}, nil +} diff --git a/protobuf/gen/go/group.pb.go b/protobuf/gen/go/group.pb.go index dfa1304..0124dda 100644 --- a/protobuf/gen/go/group.pb.go +++ b/protobuf/gen/go/group.pb.go @@ -1,12 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v5.27.0 +// protoc-gen-go v1.34.1 +// protoc v4.25.2 // source: group.proto package monify import ( + _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -530,11 +531,179 @@ func (x *Group) GetDescription() string { return "" } +type GetGroupMembersRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + GroupId string `protobuf:"bytes,1,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` +} + +func (x *GetGroupMembersRequest) Reset() { + *x = GetGroupMembersRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_group_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetGroupMembersRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetGroupMembersRequest) ProtoMessage() {} + +func (x *GetGroupMembersRequest) ProtoReflect() protoreflect.Message { + mi := &file_group_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetGroupMembersRequest.ProtoReflect.Descriptor instead. +func (*GetGroupMembersRequest) Descriptor() ([]byte, []int) { + return file_group_proto_rawDescGZIP(), []int{10} +} + +func (x *GetGroupMembersRequest) GetGroupId() string { + if x != nil { + return x.GroupId + } + return "" +} + +type GetGroupMembersResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Members []*GroupMember `protobuf:"bytes,1,rep,name=members,proto3" json:"members,omitempty"` +} + +func (x *GetGroupMembersResponse) Reset() { + *x = GetGroupMembersResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_group_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetGroupMembersResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetGroupMembersResponse) ProtoMessage() {} + +func (x *GetGroupMembersResponse) ProtoReflect() protoreflect.Message { + mi := &file_group_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetGroupMembersResponse.ProtoReflect.Descriptor instead. +func (*GetGroupMembersResponse) Descriptor() ([]byte, []int) { + return file_group_proto_rawDescGZIP(), []int{11} +} + +func (x *GetGroupMembersResponse) GetMembers() []*GroupMember { + if x != nil { + return x.Members + } + return nil +} + +type GroupMember struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + MemberId string `protobuf:"bytes,1,opt,name=member_id,json=memberId,proto3" json:"member_id,omitempty"` + UserId string `protobuf:"bytes,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + UserName string `protobuf:"bytes,3,opt,name=user_name,json=userName,proto3" json:"user_name,omitempty"` + AvatarUrl string `protobuf:"bytes,4,opt,name=avatar_url,json=avatarUrl,proto3" json:"avatar_url,omitempty"` +} + +func (x *GroupMember) Reset() { + *x = GroupMember{} + if protoimpl.UnsafeEnabled { + mi := &file_group_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GroupMember) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GroupMember) ProtoMessage() {} + +func (x *GroupMember) ProtoReflect() protoreflect.Message { + mi := &file_group_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GroupMember.ProtoReflect.Descriptor instead. +func (*GroupMember) Descriptor() ([]byte, []int) { + return file_group_proto_rawDescGZIP(), []int{12} +} + +func (x *GroupMember) GetMemberId() string { + if x != nil { + return x.MemberId + } + return "" +} + +func (x *GroupMember) GetUserId() string { + if x != nil { + return x.UserId + } + return "" +} + +func (x *GroupMember) GetUserName() string { + if x != nil { + return x.UserName + } + return "" +} + +func (x *GroupMember) GetAvatarUrl() string { + if x != nil { + return x.AvatarUrl + } + return "" +} + var File_group_proto protoreflect.FileDescriptor var file_group_proto_rawDesc = []byte{ 0x0a, 0x0b, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, + 0x32, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x4a, 0x0a, 0x12, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, @@ -574,33 +743,56 @@ var file_group_proto_rawDesc = []byte{ 0x70, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, - 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x32, 0xef, 0x02, 0x0a, 0x0c, 0x47, 0x72, - 0x6f, 0x75, 0x70, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x4e, 0x0a, 0x0b, 0x43, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x13, 0x2e, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, - 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, 0x09, 0x2f, 0x76, - 0x31, 0x2f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x3a, 0x01, 0x2a, 0x12, 0x4f, 0x0a, 0x10, 0x4c, 0x69, - 0x73, 0x74, 0x4a, 0x6f, 0x69, 0x6e, 0x65, 0x64, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x12, 0x06, - 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x19, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4a, 0x6f, 0x69, - 0x6e, 0x65, 0x64, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x12, 0x10, 0x2f, 0x76, 0x31, 0x2f, 0x67, - 0x72, 0x6f, 0x75, 0x70, 0x2f, 0x6a, 0x6f, 0x69, 0x6e, 0x65, 0x64, 0x12, 0x6f, 0x0a, 0x12, 0x47, - 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x43, 0x6f, 0x64, - 0x65, 0x12, 0x1a, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x76, 0x69, - 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, - 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x43, 0x6f, - 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x20, 0x82, 0xd3, 0xe4, 0x93, - 0x02, 0x1a, 0x22, 0x15, 0x2f, 0x76, 0x31, 0x2f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2f, 0x69, 0x6e, - 0x76, 0x69, 0x74, 0x65, 0x2d, 0x63, 0x6f, 0x64, 0x65, 0x3a, 0x01, 0x2a, 0x12, 0x4d, 0x0a, 0x09, - 0x4a, 0x6f, 0x69, 0x6e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x11, 0x2e, 0x4a, 0x6f, 0x69, 0x6e, - 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x4a, - 0x6f, 0x69, 0x6e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x22, 0x0e, 0x2f, 0x76, 0x31, 0x2f, 0x67, 0x72, - 0x6f, 0x75, 0x70, 0x2f, 0x6a, 0x6f, 0x69, 0x6e, 0x3a, 0x01, 0x2a, 0x42, 0x1e, 0x5a, 0x1c, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x53, 0x70, 0x65, 0x65, 0x64, 0x52, - 0x65, 0x61, 0x63, 0x68, 0x2f, 0x6d, 0x6f, 0x6e, 0x69, 0x66, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x33, 0x0a, 0x16, 0x47, 0x65, 0x74, + 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x22, 0x41, + 0x0a, 0x17, 0x47, 0x65, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x07, 0x6d, 0x65, 0x6d, + 0x62, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x47, 0x72, 0x6f, + 0x75, 0x70, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, + 0x73, 0x22, 0x7f, 0x0a, 0x0b, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, + 0x12, 0x1b, 0x0a, 0x09, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x49, 0x64, 0x12, 0x17, 0x0a, + 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x4e, + 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x5f, 0x75, 0x72, + 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x55, + 0x72, 0x6c, 0x32, 0xec, 0x03, 0x0a, 0x0c, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x12, 0x5f, 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, + 0x75, 0x70, 0x12, 0x13, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x25, 0x92, + 0x41, 0x0e, 0x62, 0x0c, 0x0a, 0x0a, 0x0a, 0x06, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x12, 0x00, + 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x3a, 0x01, 0x2a, 0x22, 0x09, 0x2f, 0x76, 0x31, 0x2f, 0x67, + 0x72, 0x6f, 0x75, 0x70, 0x12, 0x4f, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x4a, 0x6f, 0x69, 0x6e, + 0x65, 0x64, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x12, 0x06, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, + 0x1a, 0x19, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4a, 0x6f, 0x69, 0x6e, 0x65, 0x64, 0x47, 0x72, 0x6f, + 0x75, 0x70, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x18, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x12, 0x12, 0x10, 0x2f, 0x76, 0x31, 0x2f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2f, 0x6a, + 0x6f, 0x69, 0x6e, 0x65, 0x64, 0x12, 0x6f, 0x0a, 0x12, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, + 0x65, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1a, 0x2e, 0x47, 0x65, + 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, + 0x74, 0x65, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x20, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1a, 0x3a, 0x01, 0x2a, 0x22, + 0x15, 0x2f, 0x76, 0x31, 0x2f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2f, 0x69, 0x6e, 0x76, 0x69, 0x74, + 0x65, 0x2d, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x4d, 0x0a, 0x09, 0x4a, 0x6f, 0x69, 0x6e, 0x47, 0x72, + 0x6f, 0x75, 0x70, 0x12, 0x11, 0x2e, 0x4a, 0x6f, 0x69, 0x6e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x4a, 0x6f, 0x69, 0x6e, 0x47, 0x72, 0x6f, + 0x75, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, + 0x02, 0x13, 0x3a, 0x01, 0x2a, 0x22, 0x0e, 0x2f, 0x76, 0x31, 0x2f, 0x67, 0x72, 0x6f, 0x75, 0x70, + 0x2f, 0x6a, 0x6f, 0x69, 0x6e, 0x12, 0x6a, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x47, 0x72, 0x6f, 0x75, + 0x70, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x12, 0x17, 0x2e, 0x47, 0x65, 0x74, 0x47, 0x72, + 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x18, 0x2e, 0x47, 0x65, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x6d, 0x62, + 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x24, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x1e, 0x12, 0x1c, 0x2f, 0x76, 0x31, 0x2f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2f, 0x6d, + 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x2f, 0x7b, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x69, 0x64, + 0x7d, 0x42, 0x1e, 0x5a, 0x1c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x53, 0x70, 0x65, 0x65, 0x64, 0x52, 0x65, 0x61, 0x63, 0x68, 0x2f, 0x6d, 0x6f, 0x6e, 0x69, 0x66, + 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -615,7 +807,7 @@ func file_group_proto_rawDescGZIP() []byte { return file_group_proto_rawDescData } -var file_group_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_group_proto_msgTypes = make([]protoimpl.MessageInfo, 13) var file_group_proto_goTypes = []interface{}{ (*Empty)(nil), // 0: Empty (*CreateGroupRequest)(nil), // 1: CreateGroupRequest @@ -627,22 +819,28 @@ var file_group_proto_goTypes = []interface{}{ (*JoinGroupResponse)(nil), // 7: JoinGroupResponse (*ListJoinedGroupsResponse)(nil), // 8: ListJoinedGroupsResponse (*Group)(nil), // 9: Group + (*GetGroupMembersRequest)(nil), // 10: GetGroupMembersRequest + (*GetGroupMembersResponse)(nil), // 11: GetGroupMembersResponse + (*GroupMember)(nil), // 12: GroupMember } var file_group_proto_depIdxs = []int32{ - 9, // 0: ListJoinedGroupsResponse.groups:type_name -> Group - 1, // 1: GroupService.CreateGroup:input_type -> CreateGroupRequest - 0, // 2: GroupService.ListJoinedGroups:input_type -> Empty - 4, // 3: GroupService.GenerateInviteCode:input_type -> GenerateInviteCodeRequest - 6, // 4: GroupService.JoinGroup:input_type -> JoinGroupRequest - 3, // 5: GroupService.CreateGroup:output_type -> CreateGroupResponse - 8, // 6: GroupService.ListJoinedGroups:output_type -> ListJoinedGroupsResponse - 5, // 7: GroupService.GenerateInviteCode:output_type -> GenerateInviteCodeResponse - 7, // 8: GroupService.JoinGroup:output_type -> JoinGroupResponse - 5, // [5:9] is the sub-list for method output_type - 1, // [1:5] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 9, // 0: ListJoinedGroupsResponse.groups:type_name -> Group + 12, // 1: GetGroupMembersResponse.members:type_name -> GroupMember + 1, // 2: GroupService.CreateGroup:input_type -> CreateGroupRequest + 0, // 3: GroupService.ListJoinedGroups:input_type -> Empty + 4, // 4: GroupService.GenerateInviteCode:input_type -> GenerateInviteCodeRequest + 6, // 5: GroupService.JoinGroup:input_type -> JoinGroupRequest + 10, // 6: GroupService.GetGroupMembers:input_type -> GetGroupMembersRequest + 3, // 7: GroupService.CreateGroup:output_type -> CreateGroupResponse + 8, // 8: GroupService.ListJoinedGroups:output_type -> ListJoinedGroupsResponse + 5, // 9: GroupService.GenerateInviteCode:output_type -> GenerateInviteCodeResponse + 7, // 10: GroupService.JoinGroup:output_type -> JoinGroupResponse + 11, // 11: GroupService.GetGroupMembers:output_type -> GetGroupMembersResponse + 7, // [7:12] is the sub-list for method output_type + 2, // [2:7] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_group_proto_init() } @@ -771,6 +969,42 @@ func file_group_proto_init() { return nil } } + file_group_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetGroupMembersRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_group_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetGroupMembersResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_group_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupMember); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -778,7 +1012,7 @@ func file_group_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_group_proto_rawDesc, NumEnums: 0, - NumMessages: 10, + NumMessages: 13, NumExtensions: 0, NumServices: 1, }, diff --git a/protobuf/gen/go/group.pb.gw.go b/protobuf/gen/go/group.pb.gw.go index a2e1f3a..325d4d3 100644 --- a/protobuf/gen/go/group.pb.gw.go +++ b/protobuf/gen/go/group.pb.gw.go @@ -127,6 +127,58 @@ func local_request_GroupService_JoinGroup_0(ctx context.Context, marshaler runti } +func request_GroupService_GetGroupMembers_0(ctx context.Context, marshaler runtime.Marshaler, client GroupServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetGroupMembersRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["group_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "group_id") + } + + protoReq.GroupId, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "group_id", err) + } + + msg, err := client.GetGroupMembers(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_GroupService_GetGroupMembers_0(ctx context.Context, marshaler runtime.Marshaler, server GroupServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetGroupMembersRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["group_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "group_id") + } + + protoReq.GroupId, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "group_id", err) + } + + msg, err := server.GetGroupMembers(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterGroupServiceHandlerServer registers the http handlers for service GroupService to "mux". // UnaryRPC :call GroupServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -233,6 +285,31 @@ func RegisterGroupServiceHandlerServer(ctx context.Context, mux *runtime.ServeMu }) + mux.Handle("GET", pattern_GroupService_GetGroupMembers_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/.GroupService/GetGroupMembers", runtime.WithHTTPPathPattern("/v1/group/members/{group_id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_GroupService_GetGroupMembers_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_GroupService_GetGroupMembers_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -362,6 +439,28 @@ func RegisterGroupServiceHandlerClient(ctx context.Context, mux *runtime.ServeMu }) + mux.Handle("GET", pattern_GroupService_GetGroupMembers_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/.GroupService/GetGroupMembers", runtime.WithHTTPPathPattern("/v1/group/members/{group_id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_GroupService_GetGroupMembers_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_GroupService_GetGroupMembers_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -373,6 +472,8 @@ var ( pattern_GroupService_GenerateInviteCode_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "group", "invite-code"}, "")) pattern_GroupService_JoinGroup_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "group", "join"}, "")) + + pattern_GroupService_GetGroupMembers_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "group", "members", "group_id"}, "")) ) var ( @@ -383,4 +484,6 @@ var ( forward_GroupService_GenerateInviteCode_0 = runtime.ForwardResponseMessage forward_GroupService_JoinGroup_0 = runtime.ForwardResponseMessage + + forward_GroupService_GetGroupMembers_0 = runtime.ForwardResponseMessage ) diff --git a/protobuf/gen/go/group_grpc.pb.go b/protobuf/gen/go/group_grpc.pb.go index 453dbbb..3f3370e 100644 --- a/protobuf/gen/go/group_grpc.pb.go +++ b/protobuf/gen/go/group_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v5.27.0 +// - protoc-gen-go-grpc v1.3.0 +// - protoc v4.25.2 // source: group.proto package monify @@ -18,6 +18,14 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + GroupService_CreateGroup_FullMethodName = "/GroupService/CreateGroup" + GroupService_ListJoinedGroups_FullMethodName = "/GroupService/ListJoinedGroups" + GroupService_GenerateInviteCode_FullMethodName = "/GroupService/GenerateInviteCode" + GroupService_JoinGroup_FullMethodName = "/GroupService/JoinGroup" + GroupService_GetGroupMembers_FullMethodName = "/GroupService/GetGroupMembers" +) + // GroupServiceClient is the client API for GroupService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -26,6 +34,7 @@ type GroupServiceClient interface { ListJoinedGroups(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*ListJoinedGroupsResponse, error) GenerateInviteCode(ctx context.Context, in *GenerateInviteCodeRequest, opts ...grpc.CallOption) (*GenerateInviteCodeResponse, error) JoinGroup(ctx context.Context, in *JoinGroupRequest, opts ...grpc.CallOption) (*JoinGroupResponse, error) + GetGroupMembers(ctx context.Context, in *GetGroupMembersRequest, opts ...grpc.CallOption) (*GetGroupMembersResponse, error) } type groupServiceClient struct { @@ -38,7 +47,7 @@ func NewGroupServiceClient(cc grpc.ClientConnInterface) GroupServiceClient { func (c *groupServiceClient) CreateGroup(ctx context.Context, in *CreateGroupRequest, opts ...grpc.CallOption) (*CreateGroupResponse, error) { out := new(CreateGroupResponse) - err := c.cc.Invoke(ctx, "/GroupService/CreateGroup", in, out, opts...) + err := c.cc.Invoke(ctx, GroupService_CreateGroup_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -47,7 +56,7 @@ func (c *groupServiceClient) CreateGroup(ctx context.Context, in *CreateGroupReq func (c *groupServiceClient) ListJoinedGroups(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*ListJoinedGroupsResponse, error) { out := new(ListJoinedGroupsResponse) - err := c.cc.Invoke(ctx, "/GroupService/ListJoinedGroups", in, out, opts...) + err := c.cc.Invoke(ctx, GroupService_ListJoinedGroups_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -56,7 +65,7 @@ func (c *groupServiceClient) ListJoinedGroups(ctx context.Context, in *Empty, op func (c *groupServiceClient) GenerateInviteCode(ctx context.Context, in *GenerateInviteCodeRequest, opts ...grpc.CallOption) (*GenerateInviteCodeResponse, error) { out := new(GenerateInviteCodeResponse) - err := c.cc.Invoke(ctx, "/GroupService/GenerateInviteCode", in, out, opts...) + err := c.cc.Invoke(ctx, GroupService_GenerateInviteCode_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -65,7 +74,16 @@ func (c *groupServiceClient) GenerateInviteCode(ctx context.Context, in *Generat func (c *groupServiceClient) JoinGroup(ctx context.Context, in *JoinGroupRequest, opts ...grpc.CallOption) (*JoinGroupResponse, error) { out := new(JoinGroupResponse) - err := c.cc.Invoke(ctx, "/GroupService/JoinGroup", in, out, opts...) + err := c.cc.Invoke(ctx, GroupService_JoinGroup_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *groupServiceClient) GetGroupMembers(ctx context.Context, in *GetGroupMembersRequest, opts ...grpc.CallOption) (*GetGroupMembersResponse, error) { + out := new(GetGroupMembersResponse) + err := c.cc.Invoke(ctx, GroupService_GetGroupMembers_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -80,6 +98,7 @@ type GroupServiceServer interface { ListJoinedGroups(context.Context, *Empty) (*ListJoinedGroupsResponse, error) GenerateInviteCode(context.Context, *GenerateInviteCodeRequest) (*GenerateInviteCodeResponse, error) JoinGroup(context.Context, *JoinGroupRequest) (*JoinGroupResponse, error) + GetGroupMembers(context.Context, *GetGroupMembersRequest) (*GetGroupMembersResponse, error) mustEmbedUnimplementedGroupServiceServer() } @@ -99,6 +118,9 @@ func (UnimplementedGroupServiceServer) GenerateInviteCode(context.Context, *Gene func (UnimplementedGroupServiceServer) JoinGroup(context.Context, *JoinGroupRequest) (*JoinGroupResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method JoinGroup not implemented") } +func (UnimplementedGroupServiceServer) GetGroupMembers(context.Context, *GetGroupMembersRequest) (*GetGroupMembersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetGroupMembers not implemented") +} func (UnimplementedGroupServiceServer) mustEmbedUnimplementedGroupServiceServer() {} // UnsafeGroupServiceServer may be embedded to opt out of forward compatibility for this service. @@ -122,7 +144,7 @@ func _GroupService_CreateGroup_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/GroupService/CreateGroup", + FullMethod: GroupService_CreateGroup_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(GroupServiceServer).CreateGroup(ctx, req.(*CreateGroupRequest)) @@ -140,7 +162,7 @@ func _GroupService_ListJoinedGroups_Handler(srv interface{}, ctx context.Context } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/GroupService/ListJoinedGroups", + FullMethod: GroupService_ListJoinedGroups_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(GroupServiceServer).ListJoinedGroups(ctx, req.(*Empty)) @@ -158,7 +180,7 @@ func _GroupService_GenerateInviteCode_Handler(srv interface{}, ctx context.Conte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/GroupService/GenerateInviteCode", + FullMethod: GroupService_GenerateInviteCode_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(GroupServiceServer).GenerateInviteCode(ctx, req.(*GenerateInviteCodeRequest)) @@ -176,7 +198,7 @@ func _GroupService_JoinGroup_Handler(srv interface{}, ctx context.Context, dec f } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/GroupService/JoinGroup", + FullMethod: GroupService_JoinGroup_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(GroupServiceServer).JoinGroup(ctx, req.(*JoinGroupRequest)) @@ -184,6 +206,24 @@ func _GroupService_JoinGroup_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } +func _GroupService_GetGroupMembers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetGroupMembersRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GroupServiceServer).GetGroupMembers(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: GroupService_GetGroupMembers_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GroupServiceServer).GetGroupMembers(ctx, req.(*GetGroupMembersRequest)) + } + return interceptor(ctx, in, info, handler) +} + // GroupService_ServiceDesc is the grpc.ServiceDesc for GroupService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -207,6 +247,10 @@ var GroupService_ServiceDesc = grpc.ServiceDesc{ MethodName: "JoinGroup", Handler: _GroupService_JoinGroup_Handler, }, + { + MethodName: "GetGroupMembers", + Handler: _GroupService_GetGroupMembers_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "group.proto", diff --git a/protobuf/gen/monify.swagger.json b/protobuf/gen/monify.swagger.json index 8ce543f..e01b78d 100644 --- a/protobuf/gen/monify.swagger.json +++ b/protobuf/gen/monify.swagger.json @@ -362,14 +362,14 @@ "type": "array", "items": { "type": "object", - "$ref": "#/definitions/InsertPrepaidPerson" + "$ref": "#/definitions/PrepaidPerson" } }, "splitPeople": { "type": "array", "items": { "type": "object", - "$ref": "#/definitions/InsertSplitPerson" + "$ref": "#/definitions/SplitPerson" } } } @@ -546,7 +546,7 @@ "type": { "$ref": "#/definitions/GroupBillHistoryType" }, - "operatorName": { + "operator": { "type": "string", "title": "The member_name who did the operation" }, @@ -574,6 +574,9 @@ "GroupsBillServiceModifyGroupBillBody": { "type": "object", "properties": { + "memberId": { + "type": "string" + }, "totalMoney": { "type": "number", "format": "double" @@ -588,42 +591,18 @@ "type": "array", "items": { "type": "object", - "$ref": "#/definitions/InsertPrepaidPerson" + "$ref": "#/definitions/PrepaidPerson" } }, "splitPeople": { "type": "array", "items": { "type": "object", - "$ref": "#/definitions/InsertSplitPerson" + "$ref": "#/definitions/SplitPerson" } } } }, - "InsertPrepaidPerson": { - "type": "object", - "properties": { - "memberId": { - "type": "string" - }, - "amount": { - "type": "number", - "format": "double" - } - } - }, - "InsertSplitPerson": { - "type": "object", - "properties": { - "memberId": { - "type": "string" - }, - "amount": { - "type": "number", - "format": "double" - } - } - }, "JoinGroupRequest": { "type": "object", "properties": { diff --git a/protobuf/group.proto b/protobuf/group.proto index 5e326b4..b9e2ea1 100644 --- a/protobuf/group.proto +++ b/protobuf/group.proto @@ -2,7 +2,7 @@ syntax = "proto3"; option go_package = "github.com/SpeedReach/monify"; import "google/api/annotations.proto"; - +import "protoc-gen-openapiv2/options/annotations.proto"; message Empty {} @@ -14,6 +14,13 @@ service GroupService{ post: "/v1/group" body: "*" }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) ={ + security: { + security_requirement: { + key: "Bearer" + } + } + }; } rpc ListJoinedGroups(Empty) returns (ListJoinedGroupsResponse) { @@ -36,7 +43,11 @@ service GroupService{ }; } - + rpc GetGroupMembers(GetGroupMembersRequest) returns (GetGroupMembersResponse) { + option (google.api.http) = { + get: "/v1/group/members/{group_id}" + }; + } } @@ -83,3 +94,17 @@ message Group{ string description = 3; } +message GetGroupMembersRequest{ + string group_id = 1; +} + +message GetGroupMembersResponse{ + repeated GroupMember members = 1; +} + +message GroupMember{ + string member_id = 1; + string user_id = 2; + string user_name = 3; + string avatar_url = 4; +}