this repo has no description

full profile implementation

+386 -30
+233 -19
database/proto/profile.pb.go
··· 10 10 _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" 11 11 protoreflect "google.golang.org/protobuf/reflect/protoreflect" 12 12 protoimpl "google.golang.org/protobuf/runtime/protoimpl" 13 - _ "google.golang.org/protobuf/types/known/timestamppb" 13 + timestamppb "google.golang.org/protobuf/types/known/timestamppb" 14 14 reflect "reflect" 15 15 sync "sync" 16 16 unsafe "unsafe" ··· 69 69 70 70 type GetProfileResponse struct { 71 71 state protoimpl.MessageState `protogen:"open.v1"` 72 - Did string `protobuf:"bytes,1,opt,name=did,proto3" json:"did,omitempty"` 72 + Error *string `protobuf:"bytes,1,opt,name=error,proto3,oneof" json:"error,omitempty"` 73 + Did string `protobuf:"bytes,2,opt,name=did,proto3" json:"did,omitempty"` 74 + DisplayName *string `protobuf:"bytes,3,opt,name=display_name,json=displayName,proto3,oneof" json:"display_name,omitempty"` 75 + Description *string `protobuf:"bytes,4,opt,name=description,proto3,oneof" json:"description,omitempty"` 76 + Pronouns *string `protobuf:"bytes,5,opt,name=pronouns,proto3,oneof" json:"pronouns,omitempty"` 77 + Avatar *string `protobuf:"bytes,6,opt,name=avatar,proto3,oneof" json:"avatar,omitempty"` 78 + CreatedAt *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=created_at,json=createdAt,proto3,oneof" json:"created_at,omitempty"` 79 + IndexedAt *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=indexed_at,json=indexedAt,proto3" json:"indexed_at,omitempty"` 73 80 unknownFields protoimpl.UnknownFields 74 81 sizeCache protoimpl.SizeCache 75 82 } ··· 104 111 return file_profile_proto_rawDescGZIP(), []int{1} 105 112 } 106 113 114 + func (x *GetProfileResponse) GetError() string { 115 + if x != nil && x.Error != nil { 116 + return *x.Error 117 + } 118 + return "" 119 + } 120 + 107 121 func (x *GetProfileResponse) GetDid() string { 108 122 if x != nil { 109 123 return x.Did ··· 111 125 return "" 112 126 } 113 127 128 + func (x *GetProfileResponse) GetDisplayName() string { 129 + if x != nil && x.DisplayName != nil { 130 + return *x.DisplayName 131 + } 132 + return "" 133 + } 134 + 135 + func (x *GetProfileResponse) GetDescription() string { 136 + if x != nil && x.Description != nil { 137 + return *x.Description 138 + } 139 + return "" 140 + } 141 + 142 + func (x *GetProfileResponse) GetPronouns() string { 143 + if x != nil && x.Pronouns != nil { 144 + return *x.Pronouns 145 + } 146 + return "" 147 + } 148 + 149 + func (x *GetProfileResponse) GetAvatar() string { 150 + if x != nil && x.Avatar != nil { 151 + return *x.Avatar 152 + } 153 + return "" 154 + } 155 + 156 + func (x *GetProfileResponse) GetCreatedAt() *timestamppb.Timestamp { 157 + if x != nil { 158 + return x.CreatedAt 159 + } 160 + return nil 161 + } 162 + 163 + func (x *GetProfileResponse) GetIndexedAt() *timestamppb.Timestamp { 164 + if x != nil { 165 + return x.IndexedAt 166 + } 167 + return nil 168 + } 169 + 114 170 type CreateProfileRequest struct { 115 171 state protoimpl.MessageState `protogen:"open.v1"` 116 172 Did string `protobuf:"bytes,1,opt,name=did,proto3" json:"did,omitempty"` 117 173 CreatedAt *string `protobuf:"bytes,2,opt,name=created_at,json=createdAt,proto3,oneof" json:"created_at,omitempty"` 174 + DisplayName *string `protobuf:"bytes,3,opt,name=display_name,json=displayName,proto3,oneof" json:"display_name,omitempty"` 175 + Description *string `protobuf:"bytes,4,opt,name=description,proto3,oneof" json:"description,omitempty"` 176 + Pronouns *string `protobuf:"bytes,5,opt,name=pronouns,proto3,oneof" json:"pronouns,omitempty"` 177 + Avatar *string `protobuf:"bytes,6,opt,name=avatar,proto3,oneof" json:"avatar,omitempty"` 118 178 unknownFields protoimpl.UnknownFields 119 179 sizeCache protoimpl.SizeCache 120 180 } ··· 163 223 return "" 164 224 } 165 225 226 + func (x *CreateProfileRequest) GetDisplayName() string { 227 + if x != nil && x.DisplayName != nil { 228 + return *x.DisplayName 229 + } 230 + return "" 231 + } 232 + 233 + func (x *CreateProfileRequest) GetDescription() string { 234 + if x != nil && x.Description != nil { 235 + return *x.Description 236 + } 237 + return "" 238 + } 239 + 240 + func (x *CreateProfileRequest) GetPronouns() string { 241 + if x != nil && x.Pronouns != nil { 242 + return *x.Pronouns 243 + } 244 + return "" 245 + } 246 + 247 + func (x *CreateProfileRequest) GetAvatar() string { 248 + if x != nil && x.Avatar != nil { 249 + return *x.Avatar 250 + } 251 + return "" 252 + } 253 + 166 254 type CreateProfileResponse struct { 167 255 state protoimpl.MessageState `protogen:"open.v1"` 168 256 Error *string `protobuf:"bytes,1,opt,name=error,proto3,oneof" json:"error,omitempty"` ··· 207 295 return "" 208 296 } 209 297 298 + type DeleteProfileRequest struct { 299 + state protoimpl.MessageState `protogen:"open.v1"` 300 + Did string `protobuf:"bytes,1,opt,name=did,proto3" json:"did,omitempty"` 301 + unknownFields protoimpl.UnknownFields 302 + sizeCache protoimpl.SizeCache 303 + } 304 + 305 + func (x *DeleteProfileRequest) Reset() { 306 + *x = DeleteProfileRequest{} 307 + mi := &file_profile_proto_msgTypes[4] 308 + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 309 + ms.StoreMessageInfo(mi) 310 + } 311 + 312 + func (x *DeleteProfileRequest) String() string { 313 + return protoimpl.X.MessageStringOf(x) 314 + } 315 + 316 + func (*DeleteProfileRequest) ProtoMessage() {} 317 + 318 + func (x *DeleteProfileRequest) ProtoReflect() protoreflect.Message { 319 + mi := &file_profile_proto_msgTypes[4] 320 + if x != nil { 321 + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 322 + if ms.LoadMessageInfo() == nil { 323 + ms.StoreMessageInfo(mi) 324 + } 325 + return ms 326 + } 327 + return mi.MessageOf(x) 328 + } 329 + 330 + // Deprecated: Use DeleteProfileRequest.ProtoReflect.Descriptor instead. 331 + func (*DeleteProfileRequest) Descriptor() ([]byte, []int) { 332 + return file_profile_proto_rawDescGZIP(), []int{4} 333 + } 334 + 335 + func (x *DeleteProfileRequest) GetDid() string { 336 + if x != nil { 337 + return x.Did 338 + } 339 + return "" 340 + } 341 + 342 + type DeleteProfileResponse struct { 343 + state protoimpl.MessageState `protogen:"open.v1"` 344 + Error *string `protobuf:"bytes,1,opt,name=error,proto3,oneof" json:"error,omitempty"` 345 + unknownFields protoimpl.UnknownFields 346 + sizeCache protoimpl.SizeCache 347 + } 348 + 349 + func (x *DeleteProfileResponse) Reset() { 350 + *x = DeleteProfileResponse{} 351 + mi := &file_profile_proto_msgTypes[5] 352 + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 353 + ms.StoreMessageInfo(mi) 354 + } 355 + 356 + func (x *DeleteProfileResponse) String() string { 357 + return protoimpl.X.MessageStringOf(x) 358 + } 359 + 360 + func (*DeleteProfileResponse) ProtoMessage() {} 361 + 362 + func (x *DeleteProfileResponse) ProtoReflect() protoreflect.Message { 363 + mi := &file_profile_proto_msgTypes[5] 364 + if x != nil { 365 + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 366 + if ms.LoadMessageInfo() == nil { 367 + ms.StoreMessageInfo(mi) 368 + } 369 + return ms 370 + } 371 + return mi.MessageOf(x) 372 + } 373 + 374 + // Deprecated: Use DeleteProfileResponse.ProtoReflect.Descriptor instead. 375 + func (*DeleteProfileResponse) Descriptor() ([]byte, []int) { 376 + return file_profile_proto_rawDescGZIP(), []int{5} 377 + } 378 + 379 + func (x *DeleteProfileResponse) GetError() string { 380 + if x != nil && x.Error != nil { 381 + return *x.Error 382 + } 383 + return "" 384 + } 385 + 210 386 var File_profile_proto protoreflect.FileDescriptor 211 387 212 388 const file_profile_proto_rawDesc = "" + 213 389 "\n" + 214 390 "\rprofile.proto\x12\rvyletdatabase\x1a\x1bbuf/validate/validate.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"-\n" + 215 391 "\x11GetProfileRequest\x12\x18\n" + 216 - "\x03did\x18\x01 \x01(\tB\x06\xbaH\x03\xc8\x01\x01R\x03did\".\n" + 217 - "\x12GetProfileResponse\x12\x18\n" + 218 - "\x03did\x18\x01 \x01(\tB\x06\xbaH\x03\xc8\x01\x01R\x03did\"c\n" + 392 + "\x03did\x18\x01 \x01(\tB\x06\xbaH\x03\xc8\x01\x01R\x03did\"\xa3\x03\n" + 393 + "\x12GetProfileResponse\x12\x19\n" + 394 + "\x05error\x18\x01 \x01(\tH\x00R\x05error\x88\x01\x01\x12\x18\n" + 395 + "\x03did\x18\x02 \x01(\tB\x06\xbaH\x03\xc8\x01\x01R\x03did\x12&\n" + 396 + "\fdisplay_name\x18\x03 \x01(\tH\x01R\vdisplayName\x88\x01\x01\x12%\n" + 397 + "\vdescription\x18\x04 \x01(\tH\x02R\vdescription\x88\x01\x01\x12\x1f\n" + 398 + "\bpronouns\x18\x05 \x01(\tH\x03R\bpronouns\x88\x01\x01\x12\x1b\n" + 399 + "\x06avatar\x18\x06 \x01(\tH\x04R\x06avatar\x88\x01\x01\x12>\n" + 400 + "\n" + 401 + "created_at\x18\a \x01(\v2\x1a.google.protobuf.TimestampH\x05R\tcreatedAt\x88\x01\x01\x129\n" + 402 + "\n" + 403 + "indexed_at\x18\b \x01(\v2\x1a.google.protobuf.TimestampR\tindexedAtB\b\n" + 404 + "\x06_errorB\x0f\n" + 405 + "\r_display_nameB\x0e\n" + 406 + "\f_descriptionB\v\n" + 407 + "\t_pronounsB\t\n" + 408 + "\a_avatarB\r\n" + 409 + "\v_created_at\"\xa9\x02\n" + 219 410 "\x14CreateProfileRequest\x12\x18\n" + 220 411 "\x03did\x18\x01 \x01(\tB\x06\xbaH\x03\xc8\x01\x01R\x03did\x12\"\n" + 221 412 "\n" + 222 - "created_at\x18\x02 \x01(\tH\x00R\tcreatedAt\x88\x01\x01B\r\n" + 223 - "\v_created_at\"<\n" + 413 + "created_at\x18\x02 \x01(\tH\x00R\tcreatedAt\x88\x01\x01\x12&\n" + 414 + "\fdisplay_name\x18\x03 \x01(\tH\x01R\vdisplayName\x88\x01\x01\x12%\n" + 415 + "\vdescription\x18\x04 \x01(\tH\x02R\vdescription\x88\x01\x01\x12\x1f\n" + 416 + "\bpronouns\x18\x05 \x01(\tH\x03R\bpronouns\x88\x01\x01\x12\x1b\n" + 417 + "\x06avatar\x18\x06 \x01(\tH\x04R\x06avatar\x88\x01\x01B\r\n" + 418 + "\v_created_atB\x0f\n" + 419 + "\r_display_nameB\x0e\n" + 420 + "\f_descriptionB\v\n" + 421 + "\t_pronounsB\t\n" + 422 + "\a_avatar\"<\n" + 224 423 "\x15CreateProfileResponse\x12\x19\n" + 225 424 "\x05error\x18\x01 \x01(\tH\x00R\x05error\x88\x01\x01B\b\n" + 226 - "\x06_error2\xbf\x01\n" + 425 + "\x06_error\"0\n" + 426 + "\x14DeleteProfileRequest\x12\x18\n" + 427 + "\x03did\x18\x01 \x01(\tB\x06\xbaH\x03\xc8\x01\x01R\x03did\"<\n" + 428 + "\x15DeleteProfileResponse\x12\x19\n" + 429 + "\x05error\x18\x01 \x01(\tH\x00R\x05error\x88\x01\x01B\b\n" + 430 + "\x06_error2\x9b\x02\n" + 227 431 "\x0eProfileService\x12Q\n" + 228 432 "\n" + 229 433 "GetProfile\x12 .vyletdatabase.GetProfileRequest\x1a!.vyletdatabase.GetProfileResponse\x12Z\n" + 434 + "\rDeleteProfile\x12#.vyletdatabase.DeleteProfileRequest\x1a$.vyletdatabase.DeleteProfileResponse\x12Z\n" + 230 435 "\rCreateProfile\x12#.vyletdatabase.CreateProfileRequest\x1a$.vyletdatabase.CreateProfileResponseB\x87\x01\n" + 231 436 "\x11com.vyletdatabaseB\fProfileProtoP\x01Z\x10./;vyletdatabase\xa2\x02\x03VXX\xaa\x02\rVyletdatabase\xca\x02\rVyletdatabase\xe2\x02\x19Vyletdatabase\\GPBMetadata\xea\x02\rVyletdatabaseb\x06proto3" 232 437 ··· 242 447 return file_profile_proto_rawDescData 243 448 } 244 449 245 - var file_profile_proto_msgTypes = make([]protoimpl.MessageInfo, 4) 450 + var file_profile_proto_msgTypes = make([]protoimpl.MessageInfo, 6) 246 451 var file_profile_proto_goTypes = []any{ 247 452 (*GetProfileRequest)(nil), // 0: vyletdatabase.GetProfileRequest 248 453 (*GetProfileResponse)(nil), // 1: vyletdatabase.GetProfileResponse 249 454 (*CreateProfileRequest)(nil), // 2: vyletdatabase.CreateProfileRequest 250 455 (*CreateProfileResponse)(nil), // 3: vyletdatabase.CreateProfileResponse 456 + (*DeleteProfileRequest)(nil), // 4: vyletdatabase.DeleteProfileRequest 457 + (*DeleteProfileResponse)(nil), // 5: vyletdatabase.DeleteProfileResponse 458 + (*timestamppb.Timestamp)(nil), // 6: google.protobuf.Timestamp 251 459 } 252 460 var file_profile_proto_depIdxs = []int32{ 253 - 0, // 0: vyletdatabase.ProfileService.GetProfile:input_type -> vyletdatabase.GetProfileRequest 254 - 2, // 1: vyletdatabase.ProfileService.CreateProfile:input_type -> vyletdatabase.CreateProfileRequest 255 - 1, // 2: vyletdatabase.ProfileService.GetProfile:output_type -> vyletdatabase.GetProfileResponse 256 - 3, // 3: vyletdatabase.ProfileService.CreateProfile:output_type -> vyletdatabase.CreateProfileResponse 257 - 2, // [2:4] is the sub-list for method output_type 258 - 0, // [0:2] is the sub-list for method input_type 259 - 0, // [0:0] is the sub-list for extension type_name 260 - 0, // [0:0] is the sub-list for extension extendee 261 - 0, // [0:0] is the sub-list for field type_name 461 + 6, // 0: vyletdatabase.GetProfileResponse.created_at:type_name -> google.protobuf.Timestamp 462 + 6, // 1: vyletdatabase.GetProfileResponse.indexed_at:type_name -> google.protobuf.Timestamp 463 + 0, // 2: vyletdatabase.ProfileService.GetProfile:input_type -> vyletdatabase.GetProfileRequest 464 + 4, // 3: vyletdatabase.ProfileService.DeleteProfile:input_type -> vyletdatabase.DeleteProfileRequest 465 + 2, // 4: vyletdatabase.ProfileService.CreateProfile:input_type -> vyletdatabase.CreateProfileRequest 466 + 1, // 5: vyletdatabase.ProfileService.GetProfile:output_type -> vyletdatabase.GetProfileResponse 467 + 5, // 6: vyletdatabase.ProfileService.DeleteProfile:output_type -> vyletdatabase.DeleteProfileResponse 468 + 3, // 7: vyletdatabase.ProfileService.CreateProfile:output_type -> vyletdatabase.CreateProfileResponse 469 + 5, // [5:8] is the sub-list for method output_type 470 + 2, // [2:5] is the sub-list for method input_type 471 + 2, // [2:2] is the sub-list for extension type_name 472 + 2, // [2:2] is the sub-list for extension extendee 473 + 0, // [0:2] is the sub-list for field type_name 262 474 } 263 475 264 476 func init() { file_profile_proto_init() } ··· 266 478 if File_profile_proto != nil { 267 479 return 268 480 } 481 + file_profile_proto_msgTypes[1].OneofWrappers = []any{} 269 482 file_profile_proto_msgTypes[2].OneofWrappers = []any{} 270 483 file_profile_proto_msgTypes[3].OneofWrappers = []any{} 484 + file_profile_proto_msgTypes[5].OneofWrappers = []any{} 271 485 type x struct{} 272 486 out := protoimpl.TypeBuilder{ 273 487 File: protoimpl.DescBuilder{ 274 488 GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 275 489 RawDescriptor: unsafe.Slice(unsafe.StringData(file_profile_proto_rawDesc), len(file_profile_proto_rawDesc)), 276 490 NumEnums: 0, 277 - NumMessages: 4, 491 + NumMessages: 6, 278 492 NumExtensions: 0, 279 493 NumServices: 1, 280 494 },
+23 -1
database/proto/profile.proto
··· 9 9 10 10 service ProfileService { 11 11 rpc GetProfile(GetProfileRequest) returns (GetProfileResponse); 12 + rpc DeleteProfile(DeleteProfileRequest) returns (DeleteProfileResponse); 12 13 rpc CreateProfile(CreateProfileRequest) returns (CreateProfileResponse); 13 14 } 14 15 ··· 19 20 } 20 21 21 22 message GetProfileResponse { 22 - string did = 1 [ 23 + optional string error = 1; 24 + 25 + string did = 2 [ 23 26 (buf.validate.field).required = true 24 27 ]; 28 + optional string display_name = 3; 29 + optional string description = 4; 30 + optional string pronouns = 5; 31 + optional string avatar = 6; 32 + optional google.protobuf.Timestamp created_at = 7; 33 + google.protobuf.Timestamp indexed_at = 8; 25 34 } 26 35 27 36 message CreateProfileRequest { ··· 29 38 (buf.validate.field).required = true 30 39 ]; 31 40 optional string created_at = 2; 41 + optional string display_name = 3; 42 + optional string description = 4; 43 + optional string pronouns = 5; 44 + optional string avatar = 6; 32 45 } 33 46 34 47 message CreateProfileResponse { 35 48 optional string error = 1; 36 49 } 37 50 51 + message DeleteProfileRequest { 52 + string did = 1 [ 53 + (buf.validate.field).required = true 54 + ]; 55 + } 56 + 57 + message DeleteProfileResponse { 58 + optional string error = 1; 59 + }
+38
database/proto/profile_grpc.pb.go
··· 20 20 21 21 const ( 22 22 ProfileService_GetProfile_FullMethodName = "/vyletdatabase.ProfileService/GetProfile" 23 + ProfileService_DeleteProfile_FullMethodName = "/vyletdatabase.ProfileService/DeleteProfile" 23 24 ProfileService_CreateProfile_FullMethodName = "/vyletdatabase.ProfileService/CreateProfile" 24 25 ) 25 26 ··· 28 29 // 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. 29 30 type ProfileServiceClient interface { 30 31 GetProfile(ctx context.Context, in *GetProfileRequest, opts ...grpc.CallOption) (*GetProfileResponse, error) 32 + DeleteProfile(ctx context.Context, in *DeleteProfileRequest, opts ...grpc.CallOption) (*DeleteProfileResponse, error) 31 33 CreateProfile(ctx context.Context, in *CreateProfileRequest, opts ...grpc.CallOption) (*CreateProfileResponse, error) 32 34 } 33 35 ··· 49 51 return out, nil 50 52 } 51 53 54 + func (c *profileServiceClient) DeleteProfile(ctx context.Context, in *DeleteProfileRequest, opts ...grpc.CallOption) (*DeleteProfileResponse, error) { 55 + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 56 + out := new(DeleteProfileResponse) 57 + err := c.cc.Invoke(ctx, ProfileService_DeleteProfile_FullMethodName, in, out, cOpts...) 58 + if err != nil { 59 + return nil, err 60 + } 61 + return out, nil 62 + } 63 + 52 64 func (c *profileServiceClient) CreateProfile(ctx context.Context, in *CreateProfileRequest, opts ...grpc.CallOption) (*CreateProfileResponse, error) { 53 65 cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 54 66 out := new(CreateProfileResponse) ··· 64 76 // for forward compatibility. 65 77 type ProfileServiceServer interface { 66 78 GetProfile(context.Context, *GetProfileRequest) (*GetProfileResponse, error) 79 + DeleteProfile(context.Context, *DeleteProfileRequest) (*DeleteProfileResponse, error) 67 80 CreateProfile(context.Context, *CreateProfileRequest) (*CreateProfileResponse, error) 68 81 mustEmbedUnimplementedProfileServiceServer() 69 82 } ··· 77 90 78 91 func (UnimplementedProfileServiceServer) GetProfile(context.Context, *GetProfileRequest) (*GetProfileResponse, error) { 79 92 return nil, status.Error(codes.Unimplemented, "method GetProfile not implemented") 93 + } 94 + func (UnimplementedProfileServiceServer) DeleteProfile(context.Context, *DeleteProfileRequest) (*DeleteProfileResponse, error) { 95 + return nil, status.Error(codes.Unimplemented, "method DeleteProfile not implemented") 80 96 } 81 97 func (UnimplementedProfileServiceServer) CreateProfile(context.Context, *CreateProfileRequest) (*CreateProfileResponse, error) { 82 98 return nil, status.Error(codes.Unimplemented, "method CreateProfile not implemented") ··· 120 136 return interceptor(ctx, in, info, handler) 121 137 } 122 138 139 + func _ProfileService_DeleteProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 140 + in := new(DeleteProfileRequest) 141 + if err := dec(in); err != nil { 142 + return nil, err 143 + } 144 + if interceptor == nil { 145 + return srv.(ProfileServiceServer).DeleteProfile(ctx, in) 146 + } 147 + info := &grpc.UnaryServerInfo{ 148 + Server: srv, 149 + FullMethod: ProfileService_DeleteProfile_FullMethodName, 150 + } 151 + handler := func(ctx context.Context, req interface{}) (interface{}, error) { 152 + return srv.(ProfileServiceServer).DeleteProfile(ctx, req.(*DeleteProfileRequest)) 153 + } 154 + return interceptor(ctx, in, info, handler) 155 + } 156 + 123 157 func _ProfileService_CreateProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 124 158 in := new(CreateProfileRequest) 125 159 if err := dec(in); err != nil { ··· 148 182 { 149 183 MethodName: "GetProfile", 150 184 Handler: _ProfileService_GetProfile_Handler, 185 + }, 186 + { 187 + MethodName: "DeleteProfile", 188 + Handler: _ProfileService_DeleteProfile_Handler, 151 189 }, 152 190 { 153 191 MethodName: "CreateProfile",
+61 -4
database/server/profile.go
··· 6 6 7 7 vyletdatabase "github.com/vylet-app/go/database/proto" 8 8 "github.com/vylet-app/go/internal/helpers" 9 + "google.golang.org/protobuf/types/known/timestamppb" 9 10 ) 10 11 11 12 func (s *Server) CreateProfile(ctx context.Context, req *vyletdatabase.CreateProfileRequest) (*vyletdatabase.CreateProfileResponse, error) { ··· 26 27 if err := s.cqlSession.Query( 27 28 ` 28 29 INSERT INTO profiles 29 - (did, created_at, indexed_at, updated_at) 30 + (did, display_name, description, pronouns, avatar, created_at, indexed_at, updated_at) 30 31 VALUES 31 - (?, ?, ?, ?) 32 - `, req.Did, createdAtTime, now, now, 32 + (?, ?, ?, ?, ?, ?, ?, ?) 33 + `, 34 + req.Did, 35 + req.DisplayName, 36 + req.Description, 37 + req.Pronouns, 38 + req.Avatar, 39 + createdAtTime, 40 + now, 41 + now, 33 42 ).WithContext(ctx).Exec(); err != nil { 34 43 logger.Error("failed to create profile", "did", req.Did, "err", err) 35 44 return &vyletdatabase.CreateProfileResponse{ ··· 41 50 } 42 51 43 52 func (s *Server) GetProfile(ctx context.Context, req *vyletdatabase.GetProfileRequest) (*vyletdatabase.GetProfileResponse, error) { 44 - return nil, nil 53 + logger := s.logger.With("name", "GetProfile") 54 + 55 + resp := &vyletdatabase.GetProfileResponse{} 56 + var createdAt, indexedAt time.Time 57 + 58 + if err := s.cqlSession.Query( 59 + `SELECT 60 + did, display_name, description, pronouns, avatar, created_at, indexed_at 61 + FROM profiles 62 + WHERE did = ? 63 + `, 64 + req.Did, 65 + ).WithContext(ctx).Scan( 66 + &resp.Did, 67 + &resp.DisplayName, 68 + &resp.Description, 69 + &resp.Pronouns, 70 + &resp.Avatar, 71 + &createdAt, 72 + &indexedAt, 73 + ); err != nil { 74 + logger.Error("failed to get profile", "did", req.Did, "err", err) 75 + return &vyletdatabase.GetProfileResponse{ 76 + Error: helpers.ToStringPtr(err.Error()), 77 + }, nil 78 + } 79 + 80 + resp.CreatedAt = timestamppb.New(createdAt) 81 + resp.IndexedAt = timestamppb.New(indexedAt) 82 + 83 + return resp, nil 84 + } 85 + 86 + func (s *Server) DeleteProfile(ctx context.Context, req *vyletdatabase.DeleteProfileRequest) (*vyletdatabase.DeleteProfileResponse, error) { 87 + logger := s.logger.With("name", "DeleteProfile") 88 + 89 + if err := s.cqlSession.Query( 90 + ` 91 + DELETE FROM profiles WHERE did = ? 92 + `, 93 + req.Did, 94 + ).WithContext(ctx).Exec(); err != nil { 95 + logger.Error("failed to delete profile", "did", req.Did, "err", err) 96 + return &vyletdatabase.DeleteProfileResponse{ 97 + Error: helpers.ToStringPtr(err.Error()), 98 + }, nil 99 + } 100 + 101 + return &vyletdatabase.DeleteProfileResponse{}, nil 45 102 }
+27 -6
indexer/actorprofile.go
··· 8 8 vyletkafka "github.com/vylet-app/go/bus/proto" 9 9 vyletdatabase "github.com/vylet-app/go/database/proto" 10 10 "github.com/vylet-app/go/generated/vylet" 11 + "github.com/vylet-app/go/internal/helpers" 11 12 ) 12 13 13 14 func (s *Server) handleActorProfile(ctx context.Context, evt *vyletkafka.FirehoseEvent) error { 14 15 var rec vylet.ActorProfile 15 16 op := evt.Commit 16 17 17 - if op.Operation == vyletkafka.CommitOperation_COMMIT_OPERATION_CREATE { 18 + switch op.Operation { 19 + case vyletkafka.CommitOperation_COMMIT_OPERATION_CREATE: 18 20 if err := json.Unmarshal(op.Record, &rec); err != nil { 19 21 return fmt.Errorf("failed to unmarshal profile record: %w", err) 20 22 } 21 23 22 - resp, err := s.db.Profile.CreateProfile(ctx, &vyletdatabase.CreateProfileRequest{ 23 - Did: evt.Did, 24 - CreatedAt: rec.CreatedAt, 25 - }) 24 + req := vyletdatabase.CreateProfileRequest{ 25 + Did: evt.Did, 26 + DisplayName: rec.DisplayName, 27 + Description: rec.Description, 28 + Pronouns: rec.Pronouns, 29 + CreatedAt: rec.CreatedAt, 30 + } 31 + 32 + if rec.Avatar != nil { 33 + req.Avatar = helpers.ToStringPtr(rec.Avatar.Ref.String()) 34 + } 35 + 36 + resp, err := s.db.Profile.CreateProfile(ctx, &req) 26 37 if err != nil { 27 38 return fmt.Errorf("failed to create create profile request: %w", err) 28 39 } 29 40 if resp.Error != nil { 30 41 return fmt.Errorf("error creating profile: %s", *resp.Error) 31 42 } 32 - } else { 43 + case vyletkafka.CommitOperation_COMMIT_OPERATION_UPDATE: 33 44 return fmt.Errorf("unhandled operation") 45 + case vyletkafka.CommitOperation_COMMIT_OPERATION_DELETE: 46 + resp, err := s.db.Profile.DeleteProfile(ctx, &vyletdatabase.DeleteProfileRequest{ 47 + Did: evt.Did, 48 + }) 49 + if err != nil { 50 + return fmt.Errorf("failed to create delete profile request: %w", err) 51 + } 52 + if resp.Error != nil { 53 + return fmt.Errorf("error deleting profile: %s", *resp.Error) 54 + } 34 55 } 35 56 36 57 return nil
+4
migrations/000001_create_profiles_table.up.cql
··· 1 1 CREATE TABLE IF NOT EXISTS profiles ( 2 2 did TEXT PRIMARY KEY, 3 + display_name TEXT, 4 + description TEXT, 5 + pronouns TEXT, 6 + avatar TEXT, 3 7 created_at TIMESTAMP, 4 8 indexed_at TIMESTAMP, 5 9 updated_at TIMESTAMP,