From 51a7f583dad02afb6d8e027a326f581956fb2f3e Mon Sep 17 00:00:00 2001 From: Kaien Date: Mon, 30 Mar 2026 21:28:10 +0300 Subject: [PATCH] feat: add GetLinkedAccountsByUserAndPlatform RPC --- users.pb.go | 131 ++++++++++++++++++++++++++++++++++------------- users.proto | 6 +++ users_grpc.pb.go | 54 ++++++++++++++++--- 3 files changed, 147 insertions(+), 44 deletions(-) diff --git a/users.pb.go b/users.pb.go index 66cf67c..e73df92 100644 --- a/users.pb.go +++ b/users.pb.go @@ -615,6 +615,58 @@ func (x *GetLinkedAccountsByPlatformRequest) GetPlatform() string { return "" } +type GetLinkedAccountsByUserAndPlatformRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + GlobalUserId int64 `protobuf:"varint,1,opt,name=global_user_id,json=globalUserId,proto3" json:"global_user_id,omitempty"` + Platform string `protobuf:"bytes,2,opt,name=platform,proto3" json:"platform,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetLinkedAccountsByUserAndPlatformRequest) Reset() { + *x = GetLinkedAccountsByUserAndPlatformRequest{} + mi := &file_users_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetLinkedAccountsByUserAndPlatformRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetLinkedAccountsByUserAndPlatformRequest) ProtoMessage() {} + +func (x *GetLinkedAccountsByUserAndPlatformRequest) ProtoReflect() protoreflect.Message { + mi := &file_users_proto_msgTypes[10] + 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 GetLinkedAccountsByUserAndPlatformRequest.ProtoReflect.Descriptor instead. +func (*GetLinkedAccountsByUserAndPlatformRequest) Descriptor() ([]byte, []int) { + return file_users_proto_rawDescGZIP(), []int{10} +} + +func (x *GetLinkedAccountsByUserAndPlatformRequest) GetGlobalUserId() int64 { + if x != nil { + return x.GlobalUserId + } + return 0 +} + +func (x *GetLinkedAccountsByUserAndPlatformRequest) GetPlatform() string { + if x != nil { + return x.Platform + } + return "" +} + type GetLinkedAccountsResponse struct { state protoimpl.MessageState `protogen:"open.v1"` Accounts []*LinkedAccount `protobuf:"bytes,1,rep,name=accounts,proto3" json:"accounts,omitempty"` @@ -624,7 +676,7 @@ type GetLinkedAccountsResponse struct { func (x *GetLinkedAccountsResponse) Reset() { *x = GetLinkedAccountsResponse{} - mi := &file_users_proto_msgTypes[10] + mi := &file_users_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -636,7 +688,7 @@ func (x *GetLinkedAccountsResponse) String() string { func (*GetLinkedAccountsResponse) ProtoMessage() {} func (x *GetLinkedAccountsResponse) ProtoReflect() protoreflect.Message { - mi := &file_users_proto_msgTypes[10] + mi := &file_users_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -649,7 +701,7 @@ func (x *GetLinkedAccountsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetLinkedAccountsResponse.ProtoReflect.Descriptor instead. func (*GetLinkedAccountsResponse) Descriptor() ([]byte, []int) { - return file_users_proto_rawDescGZIP(), []int{10} + return file_users_proto_rawDescGZIP(), []int{11} } func (x *GetLinkedAccountsResponse) GetAccounts() []*LinkedAccount { @@ -711,9 +763,12 @@ const file_users_proto_rawDesc = "" + "\x0eglobal_user_id\x18\x01 \x01(\x03R\fglobalUserId\x12\x1a\n" + "\bplatform\x18\x02 \x01(\tR\bplatform\"@\n" + "\"GetLinkedAccountsByPlatformRequest\x12\x1a\n" + - "\bplatform\x18\x01 \x01(\tR\bplatform\"M\n" + + "\bplatform\x18\x01 \x01(\tR\bplatform\"m\n" + + ")GetLinkedAccountsByUserAndPlatformRequest\x12$\n" + + "\x0eglobal_user_id\x18\x01 \x01(\x03R\fglobalUserId\x12\x1a\n" + + "\bplatform\x18\x02 \x01(\tR\bplatform\"M\n" + "\x19GetLinkedAccountsResponse\x120\n" + - "\baccounts\x18\x01 \x03(\v2\x14.users.LinkedAccountR\baccounts2\xef\x04\n" + + "\baccounts\x18\x01 \x03(\v2\x14.users.LinkedAccountR\baccounts2\xe9\x05\n" + "\fUsersService\x12E\n" + "\x10CreateGlobalUser\x12\x1e.users.CreateGlobalUserRequest\x1a\x11.users.GlobalUser\x12?\n" + "\rGetGlobalUser\x12\x1b.users.GetGlobalUserRequest\x1a\x11.users.GlobalUser\x12M\n" + @@ -722,7 +777,8 @@ const file_users_proto_rawDesc = "" + "\vLinkAccount\x12\x19.users.LinkAccountRequest\x1a\x14.users.LinkedAccount\x12D\n" + "\rUnlinkAccount\x12\x1b.users.UnlinkAccountRequest\x1a\x16.google.protobuf.Empty\x12H\n" + "\x10GetLinkedAccount\x12\x1e.users.GetLinkedAccountRequest\x1a\x14.users.LinkedAccount\x12j\n" + - "\x1bGetLinkedAccountsByPlatform\x12).users.GetLinkedAccountsByPlatformRequest\x1a .users.GetLinkedAccountsResponseB,Z*git.be.kaien.ru/l-ai/l-ai-core-proto/protob\x06proto3" + "\x1bGetLinkedAccountsByPlatform\x12).users.GetLinkedAccountsByPlatformRequest\x1a .users.GetLinkedAccountsResponse\x12x\n" + + "\"GetLinkedAccountsByUserAndPlatform\x120.users.GetLinkedAccountsByUserAndPlatformRequest\x1a .users.GetLinkedAccountsResponseB,Z*git.be.kaien.ru/l-ai/l-ai-core-proto/protob\x06proto3" var ( file_users_proto_rawDescOnce sync.Once @@ -736,48 +792,51 @@ func file_users_proto_rawDescGZIP() []byte { return file_users_proto_rawDescData } -var file_users_proto_msgTypes = make([]protoimpl.MessageInfo, 11) +var file_users_proto_msgTypes = make([]protoimpl.MessageInfo, 12) var file_users_proto_goTypes = []any{ - (*GlobalUser)(nil), // 0: users.GlobalUser - (*LinkedAccount)(nil), // 1: users.LinkedAccount - (*CreateGlobalUserRequest)(nil), // 2: users.CreateGlobalUserRequest - (*GetGlobalUserRequest)(nil), // 3: users.GetGlobalUserRequest - (*GetAllGlobalUsersResponse)(nil), // 4: users.GetAllGlobalUsersResponse - (*UpdateDisplayNameRequest)(nil), // 5: users.UpdateDisplayNameRequest - (*LinkAccountRequest)(nil), // 6: users.LinkAccountRequest - (*UnlinkAccountRequest)(nil), // 7: users.UnlinkAccountRequest - (*GetLinkedAccountRequest)(nil), // 8: users.GetLinkedAccountRequest - (*GetLinkedAccountsByPlatformRequest)(nil), // 9: users.GetLinkedAccountsByPlatformRequest - (*GetLinkedAccountsResponse)(nil), // 10: users.GetLinkedAccountsResponse - (*timestamppb.Timestamp)(nil), // 11: google.protobuf.Timestamp - (*emptypb.Empty)(nil), // 12: google.protobuf.Empty + (*GlobalUser)(nil), // 0: users.GlobalUser + (*LinkedAccount)(nil), // 1: users.LinkedAccount + (*CreateGlobalUserRequest)(nil), // 2: users.CreateGlobalUserRequest + (*GetGlobalUserRequest)(nil), // 3: users.GetGlobalUserRequest + (*GetAllGlobalUsersResponse)(nil), // 4: users.GetAllGlobalUsersResponse + (*UpdateDisplayNameRequest)(nil), // 5: users.UpdateDisplayNameRequest + (*LinkAccountRequest)(nil), // 6: users.LinkAccountRequest + (*UnlinkAccountRequest)(nil), // 7: users.UnlinkAccountRequest + (*GetLinkedAccountRequest)(nil), // 8: users.GetLinkedAccountRequest + (*GetLinkedAccountsByPlatformRequest)(nil), // 9: users.GetLinkedAccountsByPlatformRequest + (*GetLinkedAccountsByUserAndPlatformRequest)(nil), // 10: users.GetLinkedAccountsByUserAndPlatformRequest + (*GetLinkedAccountsResponse)(nil), // 11: users.GetLinkedAccountsResponse + (*timestamppb.Timestamp)(nil), // 12: google.protobuf.Timestamp + (*emptypb.Empty)(nil), // 13: google.protobuf.Empty } var file_users_proto_depIdxs = []int32{ - 11, // 0: users.GlobalUser.created_at:type_name -> google.protobuf.Timestamp - 11, // 1: users.GlobalUser.updated_at:type_name -> google.protobuf.Timestamp + 12, // 0: users.GlobalUser.created_at:type_name -> google.protobuf.Timestamp + 12, // 1: users.GlobalUser.updated_at:type_name -> google.protobuf.Timestamp 1, // 2: users.GlobalUser.linked_accounts:type_name -> users.LinkedAccount - 11, // 3: users.LinkedAccount.linked_at:type_name -> google.protobuf.Timestamp - 11, // 4: users.LinkedAccount.updated_at:type_name -> google.protobuf.Timestamp + 12, // 3: users.LinkedAccount.linked_at:type_name -> google.protobuf.Timestamp + 12, // 4: users.LinkedAccount.updated_at:type_name -> google.protobuf.Timestamp 0, // 5: users.GetAllGlobalUsersResponse.users:type_name -> users.GlobalUser 1, // 6: users.GetLinkedAccountsResponse.accounts:type_name -> users.LinkedAccount 2, // 7: users.UsersService.CreateGlobalUser:input_type -> users.CreateGlobalUserRequest 3, // 8: users.UsersService.GetGlobalUser:input_type -> users.GetGlobalUserRequest - 12, // 9: users.UsersService.GetAllGlobalUsers:input_type -> google.protobuf.Empty + 13, // 9: users.UsersService.GetAllGlobalUsers:input_type -> google.protobuf.Empty 5, // 10: users.UsersService.UpdateDisplayName:input_type -> users.UpdateDisplayNameRequest 6, // 11: users.UsersService.LinkAccount:input_type -> users.LinkAccountRequest 7, // 12: users.UsersService.UnlinkAccount:input_type -> users.UnlinkAccountRequest 8, // 13: users.UsersService.GetLinkedAccount:input_type -> users.GetLinkedAccountRequest 9, // 14: users.UsersService.GetLinkedAccountsByPlatform:input_type -> users.GetLinkedAccountsByPlatformRequest - 0, // 15: users.UsersService.CreateGlobalUser:output_type -> users.GlobalUser - 0, // 16: users.UsersService.GetGlobalUser:output_type -> users.GlobalUser - 4, // 17: users.UsersService.GetAllGlobalUsers:output_type -> users.GetAllGlobalUsersResponse - 12, // 18: users.UsersService.UpdateDisplayName:output_type -> google.protobuf.Empty - 1, // 19: users.UsersService.LinkAccount:output_type -> users.LinkedAccount - 12, // 20: users.UsersService.UnlinkAccount:output_type -> google.protobuf.Empty - 1, // 21: users.UsersService.GetLinkedAccount:output_type -> users.LinkedAccount - 10, // 22: users.UsersService.GetLinkedAccountsByPlatform:output_type -> users.GetLinkedAccountsResponse - 15, // [15:23] is the sub-list for method output_type - 7, // [7:15] is the sub-list for method input_type + 10, // 15: users.UsersService.GetLinkedAccountsByUserAndPlatform:input_type -> users.GetLinkedAccountsByUserAndPlatformRequest + 0, // 16: users.UsersService.CreateGlobalUser:output_type -> users.GlobalUser + 0, // 17: users.UsersService.GetGlobalUser:output_type -> users.GlobalUser + 4, // 18: users.UsersService.GetAllGlobalUsers:output_type -> users.GetAllGlobalUsersResponse + 13, // 19: users.UsersService.UpdateDisplayName:output_type -> google.protobuf.Empty + 1, // 20: users.UsersService.LinkAccount:output_type -> users.LinkedAccount + 13, // 21: users.UsersService.UnlinkAccount:output_type -> google.protobuf.Empty + 1, // 22: users.UsersService.GetLinkedAccount:output_type -> users.LinkedAccount + 11, // 23: users.UsersService.GetLinkedAccountsByPlatform:output_type -> users.GetLinkedAccountsResponse + 11, // 24: users.UsersService.GetLinkedAccountsByUserAndPlatform:output_type -> users.GetLinkedAccountsResponse + 16, // [16:25] is the sub-list for method output_type + 7, // [7:16] is the sub-list for method input_type 7, // [7:7] is the sub-list for extension type_name 7, // [7:7] is the sub-list for extension extendee 0, // [0:7] is the sub-list for field type_name @@ -794,7 +853,7 @@ func file_users_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_users_proto_rawDesc), len(file_users_proto_rawDesc)), NumEnums: 0, - NumMessages: 11, + NumMessages: 12, NumExtensions: 0, NumServices: 1, }, diff --git a/users.proto b/users.proto index fa1db0e..f33fa9b 100644 --- a/users.proto +++ b/users.proto @@ -18,6 +18,7 @@ service UsersService { rpc UnlinkAccount(UnlinkAccountRequest) returns (google.protobuf.Empty); rpc GetLinkedAccount(GetLinkedAccountRequest) returns (LinkedAccount); rpc GetLinkedAccountsByPlatform(GetLinkedAccountsByPlatformRequest) returns (GetLinkedAccountsResponse); + rpc GetLinkedAccountsByUserAndPlatform(GetLinkedAccountsByUserAndPlatformRequest) returns (GetLinkedAccountsResponse); } message GlobalUser { @@ -79,6 +80,11 @@ message GetLinkedAccountsByPlatformRequest { string platform = 1; } +message GetLinkedAccountsByUserAndPlatformRequest { + int64 global_user_id = 1; + string platform = 2; +} + message GetLinkedAccountsResponse { repeated LinkedAccount accounts = 1; } diff --git a/users_grpc.pb.go b/users_grpc.pb.go index 18c6329..8688468 100644 --- a/users_grpc.pb.go +++ b/users_grpc.pb.go @@ -20,14 +20,15 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - UsersService_CreateGlobalUser_FullMethodName = "/users.UsersService/CreateGlobalUser" - UsersService_GetGlobalUser_FullMethodName = "/users.UsersService/GetGlobalUser" - UsersService_GetAllGlobalUsers_FullMethodName = "/users.UsersService/GetAllGlobalUsers" - UsersService_UpdateDisplayName_FullMethodName = "/users.UsersService/UpdateDisplayName" - UsersService_LinkAccount_FullMethodName = "/users.UsersService/LinkAccount" - UsersService_UnlinkAccount_FullMethodName = "/users.UsersService/UnlinkAccount" - UsersService_GetLinkedAccount_FullMethodName = "/users.UsersService/GetLinkedAccount" - UsersService_GetLinkedAccountsByPlatform_FullMethodName = "/users.UsersService/GetLinkedAccountsByPlatform" + UsersService_CreateGlobalUser_FullMethodName = "/users.UsersService/CreateGlobalUser" + UsersService_GetGlobalUser_FullMethodName = "/users.UsersService/GetGlobalUser" + UsersService_GetAllGlobalUsers_FullMethodName = "/users.UsersService/GetAllGlobalUsers" + UsersService_UpdateDisplayName_FullMethodName = "/users.UsersService/UpdateDisplayName" + UsersService_LinkAccount_FullMethodName = "/users.UsersService/LinkAccount" + UsersService_UnlinkAccount_FullMethodName = "/users.UsersService/UnlinkAccount" + UsersService_GetLinkedAccount_FullMethodName = "/users.UsersService/GetLinkedAccount" + UsersService_GetLinkedAccountsByPlatform_FullMethodName = "/users.UsersService/GetLinkedAccountsByPlatform" + UsersService_GetLinkedAccountsByUserAndPlatform_FullMethodName = "/users.UsersService/GetLinkedAccountsByUserAndPlatform" ) // UsersServiceClient is the client API for UsersService service. @@ -44,6 +45,7 @@ type UsersServiceClient interface { UnlinkAccount(ctx context.Context, in *UnlinkAccountRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) GetLinkedAccount(ctx context.Context, in *GetLinkedAccountRequest, opts ...grpc.CallOption) (*LinkedAccount, error) GetLinkedAccountsByPlatform(ctx context.Context, in *GetLinkedAccountsByPlatformRequest, opts ...grpc.CallOption) (*GetLinkedAccountsResponse, error) + GetLinkedAccountsByUserAndPlatform(ctx context.Context, in *GetLinkedAccountsByUserAndPlatformRequest, opts ...grpc.CallOption) (*GetLinkedAccountsResponse, error) } type usersServiceClient struct { @@ -134,6 +136,16 @@ func (c *usersServiceClient) GetLinkedAccountsByPlatform(ctx context.Context, in return out, nil } +func (c *usersServiceClient) GetLinkedAccountsByUserAndPlatform(ctx context.Context, in *GetLinkedAccountsByUserAndPlatformRequest, opts ...grpc.CallOption) (*GetLinkedAccountsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetLinkedAccountsResponse) + err := c.cc.Invoke(ctx, UsersService_GetLinkedAccountsByUserAndPlatform_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // UsersServiceServer is the server API for UsersService service. // All implementations must embed UnimplementedUsersServiceServer // for forward compatibility. @@ -148,6 +160,7 @@ type UsersServiceServer interface { UnlinkAccount(context.Context, *UnlinkAccountRequest) (*emptypb.Empty, error) GetLinkedAccount(context.Context, *GetLinkedAccountRequest) (*LinkedAccount, error) GetLinkedAccountsByPlatform(context.Context, *GetLinkedAccountsByPlatformRequest) (*GetLinkedAccountsResponse, error) + GetLinkedAccountsByUserAndPlatform(context.Context, *GetLinkedAccountsByUserAndPlatformRequest) (*GetLinkedAccountsResponse, error) mustEmbedUnimplementedUsersServiceServer() } @@ -182,6 +195,9 @@ func (UnimplementedUsersServiceServer) GetLinkedAccount(context.Context, *GetLin func (UnimplementedUsersServiceServer) GetLinkedAccountsByPlatform(context.Context, *GetLinkedAccountsByPlatformRequest) (*GetLinkedAccountsResponse, error) { return nil, status.Error(codes.Unimplemented, "method GetLinkedAccountsByPlatform not implemented") } +func (UnimplementedUsersServiceServer) GetLinkedAccountsByUserAndPlatform(context.Context, *GetLinkedAccountsByUserAndPlatformRequest) (*GetLinkedAccountsResponse, error) { + return nil, status.Error(codes.Unimplemented, "method GetLinkedAccountsByUserAndPlatform not implemented") +} func (UnimplementedUsersServiceServer) mustEmbedUnimplementedUsersServiceServer() {} func (UnimplementedUsersServiceServer) testEmbeddedByValue() {} @@ -347,6 +363,24 @@ func _UsersService_GetLinkedAccountsByPlatform_Handler(srv interface{}, ctx cont return interceptor(ctx, in, info, handler) } +func _UsersService_GetLinkedAccountsByUserAndPlatform_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetLinkedAccountsByUserAndPlatformRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UsersServiceServer).GetLinkedAccountsByUserAndPlatform(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UsersService_GetLinkedAccountsByUserAndPlatform_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UsersServiceServer).GetLinkedAccountsByUserAndPlatform(ctx, req.(*GetLinkedAccountsByUserAndPlatformRequest)) + } + return interceptor(ctx, in, info, handler) +} + // UsersService_ServiceDesc is the grpc.ServiceDesc for UsersService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -386,6 +420,10 @@ var UsersService_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetLinkedAccountsByPlatform", Handler: _UsersService_GetLinkedAccountsByPlatform_Handler, }, + { + MethodName: "GetLinkedAccountsByUserAndPlatform", + Handler: _UsersService_GetLinkedAccountsByUserAndPlatform_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "users.proto",