+10
-10
api/server/actorgetprofile.go
+10
-10
api/server/actorgetprofile.go
···
38
38
return ErrInternalServerErr
39
39
}
40
40
41
-
profile, err := s.client.Profile.GetProfile(ctx, &vyletdatabase.GetProfileRequest{
41
+
resp, err := s.client.Profile.GetProfile(ctx, &vyletdatabase.GetProfileRequest{
42
42
Did: did,
43
43
})
44
44
if err != nil {
45
45
logger.Error("error getting profile", "err", err)
46
46
return ErrInternalServerErr
47
47
}
48
-
if profile.Error != nil {
49
-
if client.IsNotFoundError(profile.Error) {
48
+
if resp.Error != nil {
49
+
if client.IsNotFoundError(resp.Error) {
50
50
return ErrNotFound
51
51
}
52
52
53
-
logger.Error("error getting profile", "err", *profile.Error)
53
+
logger.Error("error getting profile", "err", *resp.Error)
54
54
return ErrInternalServerErr
55
55
}
56
56
57
57
pv := vylet.ActorDefs_ProfileView{
58
58
Did: did,
59
59
Handle: handle,
60
-
Description: profile.Description,
61
-
DisplayName: profile.DisplayName,
62
-
Avatar: profile.Avatar,
63
-
CreatedAt: profile.CreatedAt.AsTime().Format(time.RFC3339Nano),
64
-
IndexedAt: profile.IndexedAt.AsTime().Format(time.RFC3339Nano),
60
+
Avatar: resp.Profile.Avatar,
61
+
Description: resp.Profile.Description,
62
+
DisplayName: resp.Profile.DisplayName,
63
+
Pronouns: resp.Profile.Pronouns,
64
+
CreatedAt: resp.Profile.CreatedAt.AsTime().Format(time.RFC3339Nano),
65
+
IndexedAt: resp.Profile.IndexedAt.AsTime().Format(time.RFC3339Nano),
65
66
Viewer: &vylet.ActorDefs_ViewerState{
66
67
BlockedBy: new(bool),
67
68
Blocking: new(string),
···
69
70
Following: new(string),
70
71
Muted: new(bool),
71
72
},
72
-
Pronouns: new(string),
73
73
}
74
74
75
75
return e.JSON(200, pv)
+87
api/server/actorgetprofiles.go
+87
api/server/actorgetprofiles.go
···
1
+
package server
2
+
3
+
import (
4
+
"sync"
5
+
"time"
6
+
7
+
"github.com/labstack/echo/v4"
8
+
"github.com/vylet-app/go/database/client"
9
+
vyletdatabase "github.com/vylet-app/go/database/proto"
10
+
"github.com/vylet-app/go/generated/vylet"
11
+
)
12
+
13
+
type ActorGetProfilesInput struct {
14
+
Dids []string `query:"dids"`
15
+
}
16
+
17
+
func (s *Server) handleGetProfiles(e echo.Context) error {
18
+
ctx := e.Request().Context()
19
+
logger := s.logger.With("name", "handleActorGetProfiles")
20
+
21
+
var input ActorGetProfilesInput
22
+
if err := e.Bind(&input); err != nil {
23
+
return ErrInternalServerErr
24
+
}
25
+
26
+
if len(input.Dids) == 0 {
27
+
return NewValidationError("dids", "at least one DID is required")
28
+
}
29
+
30
+
if len(input.Dids) > 25 {
31
+
return NewValidationError("dids", "at most 25 DIDs may be supplied")
32
+
}
33
+
34
+
logger = logger.With("dids", input.Dids)
35
+
36
+
resp, err := s.client.Profile.GetProfiles(ctx, &vyletdatabase.GetProfilesRequest{
37
+
Dids: input.Dids,
38
+
})
39
+
if err != nil {
40
+
logger.Error("error getting profile", "err", err)
41
+
return ErrInternalServerErr
42
+
}
43
+
if resp.Error != nil {
44
+
if client.IsNotFoundError(resp.Error) {
45
+
return ErrNotFound
46
+
}
47
+
48
+
logger.Error("error getting profile", "err", *resp.Error)
49
+
return ErrInternalServerErr
50
+
}
51
+
52
+
profiles := make([]vylet.ActorDefs_ProfileView, 0, len(resp.Profiles))
53
+
var wg sync.WaitGroup
54
+
var lk sync.Mutex
55
+
for _, profile := range resp.Profiles {
56
+
wg.Go(func() {
57
+
_, handle, err := s.fetchDidHandleFromActor(ctx, profile.Did)
58
+
if err != nil {
59
+
s.logger.Error("error getting handle for did", "did", profile.Did, "err", err)
60
+
return
61
+
}
62
+
63
+
lk.Lock()
64
+
defer lk.Unlock()
65
+
profiles = append(profiles, vylet.ActorDefs_ProfileView{
66
+
Did: profile.Did,
67
+
Handle: handle,
68
+
Avatar: profile.Avatar,
69
+
Description: profile.Description,
70
+
DisplayName: profile.DisplayName,
71
+
Pronouns: profile.Pronouns,
72
+
CreatedAt: profile.CreatedAt.AsTime().Format(time.RFC3339Nano),
73
+
IndexedAt: profile.IndexedAt.AsTime().Format(time.RFC3339Nano),
74
+
Viewer: &vylet.ActorDefs_ViewerState{
75
+
BlockedBy: new(bool),
76
+
Blocking: new(string),
77
+
FollowedBy: new(string),
78
+
Following: new(string),
79
+
Muted: new(bool),
80
+
},
81
+
})
82
+
})
83
+
}
84
+
wg.Wait()
85
+
86
+
return e.JSON(200, profiles)
87
+
}
+1
api/server/server.go
+1
api/server/server.go
···
125
125
func (s *Server) registerHandlers() {
126
126
// app.vylet.actor
127
127
s.echo.GET("/xrpc/app.vylet.actor.getProfile", s.handleGetProfile)
128
+
s.echo.GET("/xrpc/app.vylet.actor.getProfiles", s.handleGetProfiles)
128
129
}
129
130
130
131
func (s *Server) errorHandler(err error, c echo.Context) {
+1
database/client/client.go
+1
database/client/client.go
+680
database/proto/post.pb.go
+680
database/proto/post.pb.go
···
1
+
// Code generated by protoc-gen-go. DO NOT EDIT.
2
+
// versions:
3
+
// protoc-gen-go v1.36.6
4
+
// protoc (unknown)
5
+
// source: post.proto
6
+
7
+
package vyletdatabase
8
+
9
+
import (
10
+
_ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
11
+
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
12
+
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
13
+
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
14
+
reflect "reflect"
15
+
sync "sync"
16
+
unsafe "unsafe"
17
+
)
18
+
19
+
const (
20
+
// Verify that this generated code is sufficiently up-to-date.
21
+
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
22
+
// Verify that runtime/protoimpl is sufficiently up-to-date.
23
+
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
24
+
)
25
+
26
+
type Image struct {
27
+
state protoimpl.MessageState `protogen:"open.v1"`
28
+
Cid string `protobuf:"bytes,1,opt,name=cid,proto3" json:"cid,omitempty"`
29
+
Alt *string `protobuf:"bytes,2,opt,name=alt,proto3,oneof" json:"alt,omitempty"`
30
+
Width *int64 `protobuf:"varint,3,opt,name=width,proto3,oneof" json:"width,omitempty"`
31
+
Height *int64 `protobuf:"varint,4,opt,name=height,proto3,oneof" json:"height,omitempty"`
32
+
unknownFields protoimpl.UnknownFields
33
+
sizeCache protoimpl.SizeCache
34
+
}
35
+
36
+
func (x *Image) Reset() {
37
+
*x = Image{}
38
+
mi := &file_post_proto_msgTypes[0]
39
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
40
+
ms.StoreMessageInfo(mi)
41
+
}
42
+
43
+
func (x *Image) String() string {
44
+
return protoimpl.X.MessageStringOf(x)
45
+
}
46
+
47
+
func (*Image) ProtoMessage() {}
48
+
49
+
func (x *Image) ProtoReflect() protoreflect.Message {
50
+
mi := &file_post_proto_msgTypes[0]
51
+
if x != nil {
52
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
53
+
if ms.LoadMessageInfo() == nil {
54
+
ms.StoreMessageInfo(mi)
55
+
}
56
+
return ms
57
+
}
58
+
return mi.MessageOf(x)
59
+
}
60
+
61
+
// Deprecated: Use Image.ProtoReflect.Descriptor instead.
62
+
func (*Image) Descriptor() ([]byte, []int) {
63
+
return file_post_proto_rawDescGZIP(), []int{0}
64
+
}
65
+
66
+
func (x *Image) GetCid() string {
67
+
if x != nil {
68
+
return x.Cid
69
+
}
70
+
return ""
71
+
}
72
+
73
+
func (x *Image) GetAlt() string {
74
+
if x != nil && x.Alt != nil {
75
+
return *x.Alt
76
+
}
77
+
return ""
78
+
}
79
+
80
+
func (x *Image) GetWidth() int64 {
81
+
if x != nil && x.Width != nil {
82
+
return *x.Width
83
+
}
84
+
return 0
85
+
}
86
+
87
+
func (x *Image) GetHeight() int64 {
88
+
if x != nil && x.Height != nil {
89
+
return *x.Height
90
+
}
91
+
return 0
92
+
}
93
+
94
+
type Post struct {
95
+
state protoimpl.MessageState `protogen:"open.v1"`
96
+
Uri string `protobuf:"bytes,1,opt,name=uri,proto3" json:"uri,omitempty"`
97
+
Images []*Image `protobuf:"bytes,2,rep,name=images,proto3" json:"images,omitempty"`
98
+
Caption *string `protobuf:"bytes,3,opt,name=caption,proto3,oneof" json:"caption,omitempty"`
99
+
Facets []byte `protobuf:"bytes,4,opt,name=facets,proto3,oneof" json:"facets,omitempty"`
100
+
CreatedAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
101
+
IndexedAt *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=indexed_at,json=indexedAt,proto3" json:"indexed_at,omitempty"`
102
+
unknownFields protoimpl.UnknownFields
103
+
sizeCache protoimpl.SizeCache
104
+
}
105
+
106
+
func (x *Post) Reset() {
107
+
*x = Post{}
108
+
mi := &file_post_proto_msgTypes[1]
109
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
110
+
ms.StoreMessageInfo(mi)
111
+
}
112
+
113
+
func (x *Post) String() string {
114
+
return protoimpl.X.MessageStringOf(x)
115
+
}
116
+
117
+
func (*Post) ProtoMessage() {}
118
+
119
+
func (x *Post) ProtoReflect() protoreflect.Message {
120
+
mi := &file_post_proto_msgTypes[1]
121
+
if x != nil {
122
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
123
+
if ms.LoadMessageInfo() == nil {
124
+
ms.StoreMessageInfo(mi)
125
+
}
126
+
return ms
127
+
}
128
+
return mi.MessageOf(x)
129
+
}
130
+
131
+
// Deprecated: Use Post.ProtoReflect.Descriptor instead.
132
+
func (*Post) Descriptor() ([]byte, []int) {
133
+
return file_post_proto_rawDescGZIP(), []int{1}
134
+
}
135
+
136
+
func (x *Post) GetUri() string {
137
+
if x != nil {
138
+
return x.Uri
139
+
}
140
+
return ""
141
+
}
142
+
143
+
func (x *Post) GetImages() []*Image {
144
+
if x != nil {
145
+
return x.Images
146
+
}
147
+
return nil
148
+
}
149
+
150
+
func (x *Post) GetCaption() string {
151
+
if x != nil && x.Caption != nil {
152
+
return *x.Caption
153
+
}
154
+
return ""
155
+
}
156
+
157
+
func (x *Post) GetFacets() []byte {
158
+
if x != nil {
159
+
return x.Facets
160
+
}
161
+
return nil
162
+
}
163
+
164
+
func (x *Post) GetCreatedAt() *timestamppb.Timestamp {
165
+
if x != nil {
166
+
return x.CreatedAt
167
+
}
168
+
return nil
169
+
}
170
+
171
+
func (x *Post) GetIndexedAt() *timestamppb.Timestamp {
172
+
if x != nil {
173
+
return x.IndexedAt
174
+
}
175
+
return nil
176
+
}
177
+
178
+
type CreatePostRequest struct {
179
+
state protoimpl.MessageState `protogen:"open.v1"`
180
+
Post *Post `protobuf:"bytes,1,opt,name=post,proto3" json:"post,omitempty"`
181
+
unknownFields protoimpl.UnknownFields
182
+
sizeCache protoimpl.SizeCache
183
+
}
184
+
185
+
func (x *CreatePostRequest) Reset() {
186
+
*x = CreatePostRequest{}
187
+
mi := &file_post_proto_msgTypes[2]
188
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
189
+
ms.StoreMessageInfo(mi)
190
+
}
191
+
192
+
func (x *CreatePostRequest) String() string {
193
+
return protoimpl.X.MessageStringOf(x)
194
+
}
195
+
196
+
func (*CreatePostRequest) ProtoMessage() {}
197
+
198
+
func (x *CreatePostRequest) ProtoReflect() protoreflect.Message {
199
+
mi := &file_post_proto_msgTypes[2]
200
+
if x != nil {
201
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
202
+
if ms.LoadMessageInfo() == nil {
203
+
ms.StoreMessageInfo(mi)
204
+
}
205
+
return ms
206
+
}
207
+
return mi.MessageOf(x)
208
+
}
209
+
210
+
// Deprecated: Use CreatePostRequest.ProtoReflect.Descriptor instead.
211
+
func (*CreatePostRequest) Descriptor() ([]byte, []int) {
212
+
return file_post_proto_rawDescGZIP(), []int{2}
213
+
}
214
+
215
+
func (x *CreatePostRequest) GetPost() *Post {
216
+
if x != nil {
217
+
return x.Post
218
+
}
219
+
return nil
220
+
}
221
+
222
+
type CreatePostResponse struct {
223
+
state protoimpl.MessageState `protogen:"open.v1"`
224
+
Error *string `protobuf:"bytes,1,opt,name=error,proto3,oneof" json:"error,omitempty"`
225
+
unknownFields protoimpl.UnknownFields
226
+
sizeCache protoimpl.SizeCache
227
+
}
228
+
229
+
func (x *CreatePostResponse) Reset() {
230
+
*x = CreatePostResponse{}
231
+
mi := &file_post_proto_msgTypes[3]
232
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
233
+
ms.StoreMessageInfo(mi)
234
+
}
235
+
236
+
func (x *CreatePostResponse) String() string {
237
+
return protoimpl.X.MessageStringOf(x)
238
+
}
239
+
240
+
func (*CreatePostResponse) ProtoMessage() {}
241
+
242
+
func (x *CreatePostResponse) ProtoReflect() protoreflect.Message {
243
+
mi := &file_post_proto_msgTypes[3]
244
+
if x != nil {
245
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
246
+
if ms.LoadMessageInfo() == nil {
247
+
ms.StoreMessageInfo(mi)
248
+
}
249
+
return ms
250
+
}
251
+
return mi.MessageOf(x)
252
+
}
253
+
254
+
// Deprecated: Use CreatePostResponse.ProtoReflect.Descriptor instead.
255
+
func (*CreatePostResponse) Descriptor() ([]byte, []int) {
256
+
return file_post_proto_rawDescGZIP(), []int{3}
257
+
}
258
+
259
+
func (x *CreatePostResponse) GetError() string {
260
+
if x != nil && x.Error != nil {
261
+
return *x.Error
262
+
}
263
+
return ""
264
+
}
265
+
266
+
type DeletePostRequest struct {
267
+
state protoimpl.MessageState `protogen:"open.v1"`
268
+
Uri string `protobuf:"bytes,1,opt,name=uri,proto3" json:"uri,omitempty"`
269
+
unknownFields protoimpl.UnknownFields
270
+
sizeCache protoimpl.SizeCache
271
+
}
272
+
273
+
func (x *DeletePostRequest) Reset() {
274
+
*x = DeletePostRequest{}
275
+
mi := &file_post_proto_msgTypes[4]
276
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
277
+
ms.StoreMessageInfo(mi)
278
+
}
279
+
280
+
func (x *DeletePostRequest) String() string {
281
+
return protoimpl.X.MessageStringOf(x)
282
+
}
283
+
284
+
func (*DeletePostRequest) ProtoMessage() {}
285
+
286
+
func (x *DeletePostRequest) ProtoReflect() protoreflect.Message {
287
+
mi := &file_post_proto_msgTypes[4]
288
+
if x != nil {
289
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
290
+
if ms.LoadMessageInfo() == nil {
291
+
ms.StoreMessageInfo(mi)
292
+
}
293
+
return ms
294
+
}
295
+
return mi.MessageOf(x)
296
+
}
297
+
298
+
// Deprecated: Use DeletePostRequest.ProtoReflect.Descriptor instead.
299
+
func (*DeletePostRequest) Descriptor() ([]byte, []int) {
300
+
return file_post_proto_rawDescGZIP(), []int{4}
301
+
}
302
+
303
+
func (x *DeletePostRequest) GetUri() string {
304
+
if x != nil {
305
+
return x.Uri
306
+
}
307
+
return ""
308
+
}
309
+
310
+
type DeletePostResponse struct {
311
+
state protoimpl.MessageState `protogen:"open.v1"`
312
+
Error *string `protobuf:"bytes,1,opt,name=error,proto3,oneof" json:"error,omitempty"`
313
+
unknownFields protoimpl.UnknownFields
314
+
sizeCache protoimpl.SizeCache
315
+
}
316
+
317
+
func (x *DeletePostResponse) Reset() {
318
+
*x = DeletePostResponse{}
319
+
mi := &file_post_proto_msgTypes[5]
320
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
321
+
ms.StoreMessageInfo(mi)
322
+
}
323
+
324
+
func (x *DeletePostResponse) String() string {
325
+
return protoimpl.X.MessageStringOf(x)
326
+
}
327
+
328
+
func (*DeletePostResponse) ProtoMessage() {}
329
+
330
+
func (x *DeletePostResponse) ProtoReflect() protoreflect.Message {
331
+
mi := &file_post_proto_msgTypes[5]
332
+
if x != nil {
333
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
334
+
if ms.LoadMessageInfo() == nil {
335
+
ms.StoreMessageInfo(mi)
336
+
}
337
+
return ms
338
+
}
339
+
return mi.MessageOf(x)
340
+
}
341
+
342
+
// Deprecated: Use DeletePostResponse.ProtoReflect.Descriptor instead.
343
+
func (*DeletePostResponse) Descriptor() ([]byte, []int) {
344
+
return file_post_proto_rawDescGZIP(), []int{5}
345
+
}
346
+
347
+
func (x *DeletePostResponse) GetError() string {
348
+
if x != nil && x.Error != nil {
349
+
return *x.Error
350
+
}
351
+
return ""
352
+
}
353
+
354
+
type GetPostRequest struct {
355
+
state protoimpl.MessageState `protogen:"open.v1"`
356
+
Uri string `protobuf:"bytes,1,opt,name=uri,proto3" json:"uri,omitempty"`
357
+
unknownFields protoimpl.UnknownFields
358
+
sizeCache protoimpl.SizeCache
359
+
}
360
+
361
+
func (x *GetPostRequest) Reset() {
362
+
*x = GetPostRequest{}
363
+
mi := &file_post_proto_msgTypes[6]
364
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
365
+
ms.StoreMessageInfo(mi)
366
+
}
367
+
368
+
func (x *GetPostRequest) String() string {
369
+
return protoimpl.X.MessageStringOf(x)
370
+
}
371
+
372
+
func (*GetPostRequest) ProtoMessage() {}
373
+
374
+
func (x *GetPostRequest) ProtoReflect() protoreflect.Message {
375
+
mi := &file_post_proto_msgTypes[6]
376
+
if x != nil {
377
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
378
+
if ms.LoadMessageInfo() == nil {
379
+
ms.StoreMessageInfo(mi)
380
+
}
381
+
return ms
382
+
}
383
+
return mi.MessageOf(x)
384
+
}
385
+
386
+
// Deprecated: Use GetPostRequest.ProtoReflect.Descriptor instead.
387
+
func (*GetPostRequest) Descriptor() ([]byte, []int) {
388
+
return file_post_proto_rawDescGZIP(), []int{6}
389
+
}
390
+
391
+
func (x *GetPostRequest) GetUri() string {
392
+
if x != nil {
393
+
return x.Uri
394
+
}
395
+
return ""
396
+
}
397
+
398
+
type GetPostResponse struct {
399
+
state protoimpl.MessageState `protogen:"open.v1"`
400
+
Error *string `protobuf:"bytes,1,opt,name=error,proto3,oneof" json:"error,omitempty"`
401
+
Post *Post `protobuf:"bytes,2,opt,name=post,proto3,oneof" json:"post,omitempty"`
402
+
unknownFields protoimpl.UnknownFields
403
+
sizeCache protoimpl.SizeCache
404
+
}
405
+
406
+
func (x *GetPostResponse) Reset() {
407
+
*x = GetPostResponse{}
408
+
mi := &file_post_proto_msgTypes[7]
409
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
410
+
ms.StoreMessageInfo(mi)
411
+
}
412
+
413
+
func (x *GetPostResponse) String() string {
414
+
return protoimpl.X.MessageStringOf(x)
415
+
}
416
+
417
+
func (*GetPostResponse) ProtoMessage() {}
418
+
419
+
func (x *GetPostResponse) ProtoReflect() protoreflect.Message {
420
+
mi := &file_post_proto_msgTypes[7]
421
+
if x != nil {
422
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
423
+
if ms.LoadMessageInfo() == nil {
424
+
ms.StoreMessageInfo(mi)
425
+
}
426
+
return ms
427
+
}
428
+
return mi.MessageOf(x)
429
+
}
430
+
431
+
// Deprecated: Use GetPostResponse.ProtoReflect.Descriptor instead.
432
+
func (*GetPostResponse) Descriptor() ([]byte, []int) {
433
+
return file_post_proto_rawDescGZIP(), []int{7}
434
+
}
435
+
436
+
func (x *GetPostResponse) GetError() string {
437
+
if x != nil && x.Error != nil {
438
+
return *x.Error
439
+
}
440
+
return ""
441
+
}
442
+
443
+
func (x *GetPostResponse) GetPost() *Post {
444
+
if x != nil {
445
+
return x.Post
446
+
}
447
+
return nil
448
+
}
449
+
450
+
type GetPostsRequest struct {
451
+
state protoimpl.MessageState `protogen:"open.v1"`
452
+
Uris []string `protobuf:"bytes,1,rep,name=uris,proto3" json:"uris,omitempty"`
453
+
unknownFields protoimpl.UnknownFields
454
+
sizeCache protoimpl.SizeCache
455
+
}
456
+
457
+
func (x *GetPostsRequest) Reset() {
458
+
*x = GetPostsRequest{}
459
+
mi := &file_post_proto_msgTypes[8]
460
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
461
+
ms.StoreMessageInfo(mi)
462
+
}
463
+
464
+
func (x *GetPostsRequest) String() string {
465
+
return protoimpl.X.MessageStringOf(x)
466
+
}
467
+
468
+
func (*GetPostsRequest) ProtoMessage() {}
469
+
470
+
func (x *GetPostsRequest) ProtoReflect() protoreflect.Message {
471
+
mi := &file_post_proto_msgTypes[8]
472
+
if x != nil {
473
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
474
+
if ms.LoadMessageInfo() == nil {
475
+
ms.StoreMessageInfo(mi)
476
+
}
477
+
return ms
478
+
}
479
+
return mi.MessageOf(x)
480
+
}
481
+
482
+
// Deprecated: Use GetPostsRequest.ProtoReflect.Descriptor instead.
483
+
func (*GetPostsRequest) Descriptor() ([]byte, []int) {
484
+
return file_post_proto_rawDescGZIP(), []int{8}
485
+
}
486
+
487
+
func (x *GetPostsRequest) GetUris() []string {
488
+
if x != nil {
489
+
return x.Uris
490
+
}
491
+
return nil
492
+
}
493
+
494
+
type GetPostsResponse struct {
495
+
state protoimpl.MessageState `protogen:"open.v1"`
496
+
Error *string `protobuf:"bytes,1,opt,name=error,proto3,oneof" json:"error,omitempty"`
497
+
Posts []*Post `protobuf:"bytes,2,rep,name=posts,proto3" json:"posts,omitempty"`
498
+
unknownFields protoimpl.UnknownFields
499
+
sizeCache protoimpl.SizeCache
500
+
}
501
+
502
+
func (x *GetPostsResponse) Reset() {
503
+
*x = GetPostsResponse{}
504
+
mi := &file_post_proto_msgTypes[9]
505
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
506
+
ms.StoreMessageInfo(mi)
507
+
}
508
+
509
+
func (x *GetPostsResponse) String() string {
510
+
return protoimpl.X.MessageStringOf(x)
511
+
}
512
+
513
+
func (*GetPostsResponse) ProtoMessage() {}
514
+
515
+
func (x *GetPostsResponse) ProtoReflect() protoreflect.Message {
516
+
mi := &file_post_proto_msgTypes[9]
517
+
if x != nil {
518
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
519
+
if ms.LoadMessageInfo() == nil {
520
+
ms.StoreMessageInfo(mi)
521
+
}
522
+
return ms
523
+
}
524
+
return mi.MessageOf(x)
525
+
}
526
+
527
+
// Deprecated: Use GetPostsResponse.ProtoReflect.Descriptor instead.
528
+
func (*GetPostsResponse) Descriptor() ([]byte, []int) {
529
+
return file_post_proto_rawDescGZIP(), []int{9}
530
+
}
531
+
532
+
func (x *GetPostsResponse) GetError() string {
533
+
if x != nil && x.Error != nil {
534
+
return *x.Error
535
+
}
536
+
return ""
537
+
}
538
+
539
+
func (x *GetPostsResponse) GetPosts() []*Post {
540
+
if x != nil {
541
+
return x.Posts
542
+
}
543
+
return nil
544
+
}
545
+
546
+
var File_post_proto protoreflect.FileDescriptor
547
+
548
+
const file_post_proto_rawDesc = "" +
549
+
"\n" +
550
+
"\n" +
551
+
"post.proto\x12\rvyletdatabase\x1a\x1bbuf/validate/validate.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\x8d\x01\n" +
552
+
"\x05Image\x12\x18\n" +
553
+
"\x03cid\x18\x01 \x01(\tB\x06\xbaH\x03\xc8\x01\x01R\x03cid\x12\x15\n" +
554
+
"\x03alt\x18\x02 \x01(\tH\x00R\x03alt\x88\x01\x01\x12\x19\n" +
555
+
"\x05width\x18\x03 \x01(\x03H\x01R\x05width\x88\x01\x01\x12\x1b\n" +
556
+
"\x06height\x18\x04 \x01(\x03H\x02R\x06height\x88\x01\x01B\x06\n" +
557
+
"\x04_altB\b\n" +
558
+
"\x06_widthB\t\n" +
559
+
"\a_height\"\x97\x02\n" +
560
+
"\x04Post\x12\x18\n" +
561
+
"\x03uri\x18\x01 \x01(\tB\x06\xbaH\x03\xc8\x01\x01R\x03uri\x12,\n" +
562
+
"\x06images\x18\x02 \x03(\v2\x14.vyletdatabase.ImageR\x06images\x12\x1d\n" +
563
+
"\acaption\x18\x03 \x01(\tH\x00R\acaption\x88\x01\x01\x12\x1b\n" +
564
+
"\x06facets\x18\x04 \x01(\fH\x01R\x06facets\x88\x01\x01\x129\n" +
565
+
"\n" +
566
+
"created_at\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAt\x129\n" +
567
+
"\n" +
568
+
"indexed_at\x18\x06 \x01(\v2\x1a.google.protobuf.TimestampR\tindexedAtB\n" +
569
+
"\n" +
570
+
"\b_captionB\t\n" +
571
+
"\a_facets\"<\n" +
572
+
"\x11CreatePostRequest\x12'\n" +
573
+
"\x04post\x18\x01 \x01(\v2\x13.vyletdatabase.PostR\x04post\"9\n" +
574
+
"\x12CreatePostResponse\x12\x19\n" +
575
+
"\x05error\x18\x01 \x01(\tH\x00R\x05error\x88\x01\x01B\b\n" +
576
+
"\x06_error\"-\n" +
577
+
"\x11DeletePostRequest\x12\x18\n" +
578
+
"\x03uri\x18\x01 \x01(\tB\x06\xbaH\x03\xc8\x01\x01R\x03uri\"9\n" +
579
+
"\x12DeletePostResponse\x12\x19\n" +
580
+
"\x05error\x18\x01 \x01(\tH\x00R\x05error\x88\x01\x01B\b\n" +
581
+
"\x06_error\"*\n" +
582
+
"\x0eGetPostRequest\x12\x18\n" +
583
+
"\x03uri\x18\x01 \x01(\tB\x06\xbaH\x03\xc8\x01\x01R\x03uri\"m\n" +
584
+
"\x0fGetPostResponse\x12\x19\n" +
585
+
"\x05error\x18\x01 \x01(\tH\x00R\x05error\x88\x01\x01\x12,\n" +
586
+
"\x04post\x18\x02 \x01(\v2\x13.vyletdatabase.PostH\x01R\x04post\x88\x01\x01B\b\n" +
587
+
"\x06_errorB\a\n" +
588
+
"\x05_post\"-\n" +
589
+
"\x0fGetPostsRequest\x12\x1a\n" +
590
+
"\x04uris\x18\x01 \x03(\tB\x06\xbaH\x03\xc8\x01\x01R\x04uris\"b\n" +
591
+
"\x10GetPostsResponse\x12\x19\n" +
592
+
"\x05error\x18\x01 \x01(\tH\x00R\x05error\x88\x01\x01\x12)\n" +
593
+
"\x05posts\x18\x02 \x03(\v2\x13.vyletdatabase.PostR\x05postsB\b\n" +
594
+
"\x06_error2\xca\x02\n" +
595
+
"\vPostService\x12Q\n" +
596
+
"\n" +
597
+
"CreatePost\x12 .vyletdatabase.CreatePostRequest\x1a!.vyletdatabase.CreatePostResponse\x12Q\n" +
598
+
"\n" +
599
+
"DeletePost\x12 .vyletdatabase.DeletePostRequest\x1a!.vyletdatabase.DeletePostResponse\x12H\n" +
600
+
"\aGetPost\x12\x1d.vyletdatabase.GetPostRequest\x1a\x1e.vyletdatabase.GetPostResponse\x12K\n" +
601
+
"\bGetPosts\x12\x1e.vyletdatabase.GetPostsRequest\x1a\x1f.vyletdatabase.GetPostsResponseB\x84\x01\n" +
602
+
"\x11com.vyletdatabaseB\tPostProtoP\x01Z\x10./;vyletdatabase\xa2\x02\x03VXX\xaa\x02\rVyletdatabase\xca\x02\rVyletdatabase\xe2\x02\x19Vyletdatabase\\GPBMetadata\xea\x02\rVyletdatabaseb\x06proto3"
603
+
604
+
var (
605
+
file_post_proto_rawDescOnce sync.Once
606
+
file_post_proto_rawDescData []byte
607
+
)
608
+
609
+
func file_post_proto_rawDescGZIP() []byte {
610
+
file_post_proto_rawDescOnce.Do(func() {
611
+
file_post_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_post_proto_rawDesc), len(file_post_proto_rawDesc)))
612
+
})
613
+
return file_post_proto_rawDescData
614
+
}
615
+
616
+
var file_post_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
617
+
var file_post_proto_goTypes = []any{
618
+
(*Image)(nil), // 0: vyletdatabase.Image
619
+
(*Post)(nil), // 1: vyletdatabase.Post
620
+
(*CreatePostRequest)(nil), // 2: vyletdatabase.CreatePostRequest
621
+
(*CreatePostResponse)(nil), // 3: vyletdatabase.CreatePostResponse
622
+
(*DeletePostRequest)(nil), // 4: vyletdatabase.DeletePostRequest
623
+
(*DeletePostResponse)(nil), // 5: vyletdatabase.DeletePostResponse
624
+
(*GetPostRequest)(nil), // 6: vyletdatabase.GetPostRequest
625
+
(*GetPostResponse)(nil), // 7: vyletdatabase.GetPostResponse
626
+
(*GetPostsRequest)(nil), // 8: vyletdatabase.GetPostsRequest
627
+
(*GetPostsResponse)(nil), // 9: vyletdatabase.GetPostsResponse
628
+
(*timestamppb.Timestamp)(nil), // 10: google.protobuf.Timestamp
629
+
}
630
+
var file_post_proto_depIdxs = []int32{
631
+
0, // 0: vyletdatabase.Post.images:type_name -> vyletdatabase.Image
632
+
10, // 1: vyletdatabase.Post.created_at:type_name -> google.protobuf.Timestamp
633
+
10, // 2: vyletdatabase.Post.indexed_at:type_name -> google.protobuf.Timestamp
634
+
1, // 3: vyletdatabase.CreatePostRequest.post:type_name -> vyletdatabase.Post
635
+
1, // 4: vyletdatabase.GetPostResponse.post:type_name -> vyletdatabase.Post
636
+
1, // 5: vyletdatabase.GetPostsResponse.posts:type_name -> vyletdatabase.Post
637
+
2, // 6: vyletdatabase.PostService.CreatePost:input_type -> vyletdatabase.CreatePostRequest
638
+
4, // 7: vyletdatabase.PostService.DeletePost:input_type -> vyletdatabase.DeletePostRequest
639
+
6, // 8: vyletdatabase.PostService.GetPost:input_type -> vyletdatabase.GetPostRequest
640
+
8, // 9: vyletdatabase.PostService.GetPosts:input_type -> vyletdatabase.GetPostsRequest
641
+
3, // 10: vyletdatabase.PostService.CreatePost:output_type -> vyletdatabase.CreatePostResponse
642
+
5, // 11: vyletdatabase.PostService.DeletePost:output_type -> vyletdatabase.DeletePostResponse
643
+
7, // 12: vyletdatabase.PostService.GetPost:output_type -> vyletdatabase.GetPostResponse
644
+
9, // 13: vyletdatabase.PostService.GetPosts:output_type -> vyletdatabase.GetPostsResponse
645
+
10, // [10:14] is the sub-list for method output_type
646
+
6, // [6:10] is the sub-list for method input_type
647
+
6, // [6:6] is the sub-list for extension type_name
648
+
6, // [6:6] is the sub-list for extension extendee
649
+
0, // [0:6] is the sub-list for field type_name
650
+
}
651
+
652
+
func init() { file_post_proto_init() }
653
+
func file_post_proto_init() {
654
+
if File_post_proto != nil {
655
+
return
656
+
}
657
+
file_post_proto_msgTypes[0].OneofWrappers = []any{}
658
+
file_post_proto_msgTypes[1].OneofWrappers = []any{}
659
+
file_post_proto_msgTypes[3].OneofWrappers = []any{}
660
+
file_post_proto_msgTypes[5].OneofWrappers = []any{}
661
+
file_post_proto_msgTypes[7].OneofWrappers = []any{}
662
+
file_post_proto_msgTypes[9].OneofWrappers = []any{}
663
+
type x struct{}
664
+
out := protoimpl.TypeBuilder{
665
+
File: protoimpl.DescBuilder{
666
+
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
667
+
RawDescriptor: unsafe.Slice(unsafe.StringData(file_post_proto_rawDesc), len(file_post_proto_rawDesc)),
668
+
NumEnums: 0,
669
+
NumMessages: 10,
670
+
NumExtensions: 0,
671
+
NumServices: 1,
672
+
},
673
+
GoTypes: file_post_proto_goTypes,
674
+
DependencyIndexes: file_post_proto_depIdxs,
675
+
MessageInfos: file_post_proto_msgTypes,
676
+
}.Build()
677
+
File_post_proto = out.File
678
+
file_post_proto_goTypes = nil
679
+
file_post_proto_depIdxs = nil
680
+
}
+76
database/proto/post.proto
+76
database/proto/post.proto
···
1
+
syntax = "proto3";
2
+
3
+
package vyletdatabase;
4
+
option go_package = "./;vyletdatabase";
5
+
6
+
import "buf/validate/validate.proto";
7
+
8
+
import "google/protobuf/timestamp.proto";
9
+
10
+
service PostService {
11
+
rpc CreatePost(CreatePostRequest) returns (CreatePostResponse);
12
+
rpc DeletePost(DeletePostRequest) returns (DeletePostResponse);
13
+
14
+
rpc GetPost(GetPostRequest) returns (GetPostResponse);
15
+
rpc GetPosts(GetPostsRequest) returns (GetPostsResponse);
16
+
}
17
+
18
+
message Image {
19
+
string cid = 1 [
20
+
(buf.validate.field).required = true
21
+
];
22
+
optional string alt = 2;
23
+
optional int64 width = 3;
24
+
optional int64 height = 4;
25
+
}
26
+
27
+
message Post {
28
+
string uri = 1 [
29
+
(buf.validate.field).required = true
30
+
];
31
+
repeated Image images = 2;
32
+
optional string caption = 3;
33
+
optional bytes facets = 4;
34
+
google.protobuf.Timestamp created_at = 5;
35
+
google.protobuf.Timestamp indexed_at = 6;
36
+
}
37
+
38
+
message CreatePostRequest {
39
+
Post post = 1;
40
+
}
41
+
42
+
message CreatePostResponse {
43
+
optional string error = 1;
44
+
}
45
+
46
+
message DeletePostRequest {
47
+
string uri = 1 [
48
+
(buf.validate.field).required = true
49
+
];
50
+
}
51
+
52
+
message DeletePostResponse {
53
+
optional string error = 1;
54
+
}
55
+
56
+
message GetPostRequest {
57
+
string uri = 1 [
58
+
(buf.validate.field).required = true
59
+
];
60
+
}
61
+
62
+
message GetPostResponse {
63
+
optional string error = 1;
64
+
optional Post post = 2;
65
+
}
66
+
67
+
message GetPostsRequest {
68
+
repeated string uris = 1 [
69
+
(buf.validate.field).required = true
70
+
];
71
+
}
72
+
73
+
message GetPostsResponse {
74
+
optional string error = 1;
75
+
repeated Post posts = 2;
76
+
}
+235
database/proto/post_grpc.pb.go
+235
database/proto/post_grpc.pb.go
···
1
+
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
2
+
// versions:
3
+
// - protoc-gen-go-grpc v1.6.0
4
+
// - protoc (unknown)
5
+
// source: post.proto
6
+
7
+
package vyletdatabase
8
+
9
+
import (
10
+
context "context"
11
+
grpc "google.golang.org/grpc"
12
+
codes "google.golang.org/grpc/codes"
13
+
status "google.golang.org/grpc/status"
14
+
)
15
+
16
+
// This is a compile-time assertion to ensure that this generated file
17
+
// is compatible with the grpc package it is being compiled against.
18
+
// Requires gRPC-Go v1.64.0 or later.
19
+
const _ = grpc.SupportPackageIsVersion9
20
+
21
+
const (
22
+
PostService_CreatePost_FullMethodName = "/vyletdatabase.PostService/CreatePost"
23
+
PostService_DeletePost_FullMethodName = "/vyletdatabase.PostService/DeletePost"
24
+
PostService_GetPost_FullMethodName = "/vyletdatabase.PostService/GetPost"
25
+
PostService_GetPosts_FullMethodName = "/vyletdatabase.PostService/GetPosts"
26
+
)
27
+
28
+
// PostServiceClient is the client API for PostService service.
29
+
//
30
+
// 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.
31
+
type PostServiceClient interface {
32
+
CreatePost(ctx context.Context, in *CreatePostRequest, opts ...grpc.CallOption) (*CreatePostResponse, error)
33
+
DeletePost(ctx context.Context, in *DeletePostRequest, opts ...grpc.CallOption) (*DeletePostResponse, error)
34
+
GetPost(ctx context.Context, in *GetPostRequest, opts ...grpc.CallOption) (*GetPostResponse, error)
35
+
GetPosts(ctx context.Context, in *GetPostsRequest, opts ...grpc.CallOption) (*GetPostsResponse, error)
36
+
}
37
+
38
+
type postServiceClient struct {
39
+
cc grpc.ClientConnInterface
40
+
}
41
+
42
+
func NewPostServiceClient(cc grpc.ClientConnInterface) PostServiceClient {
43
+
return &postServiceClient{cc}
44
+
}
45
+
46
+
func (c *postServiceClient) CreatePost(ctx context.Context, in *CreatePostRequest, opts ...grpc.CallOption) (*CreatePostResponse, error) {
47
+
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
48
+
out := new(CreatePostResponse)
49
+
err := c.cc.Invoke(ctx, PostService_CreatePost_FullMethodName, in, out, cOpts...)
50
+
if err != nil {
51
+
return nil, err
52
+
}
53
+
return out, nil
54
+
}
55
+
56
+
func (c *postServiceClient) DeletePost(ctx context.Context, in *DeletePostRequest, opts ...grpc.CallOption) (*DeletePostResponse, error) {
57
+
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
58
+
out := new(DeletePostResponse)
59
+
err := c.cc.Invoke(ctx, PostService_DeletePost_FullMethodName, in, out, cOpts...)
60
+
if err != nil {
61
+
return nil, err
62
+
}
63
+
return out, nil
64
+
}
65
+
66
+
func (c *postServiceClient) GetPost(ctx context.Context, in *GetPostRequest, opts ...grpc.CallOption) (*GetPostResponse, error) {
67
+
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
68
+
out := new(GetPostResponse)
69
+
err := c.cc.Invoke(ctx, PostService_GetPost_FullMethodName, in, out, cOpts...)
70
+
if err != nil {
71
+
return nil, err
72
+
}
73
+
return out, nil
74
+
}
75
+
76
+
func (c *postServiceClient) GetPosts(ctx context.Context, in *GetPostsRequest, opts ...grpc.CallOption) (*GetPostsResponse, error) {
77
+
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
78
+
out := new(GetPostsResponse)
79
+
err := c.cc.Invoke(ctx, PostService_GetPosts_FullMethodName, in, out, cOpts...)
80
+
if err != nil {
81
+
return nil, err
82
+
}
83
+
return out, nil
84
+
}
85
+
86
+
// PostServiceServer is the server API for PostService service.
87
+
// All implementations must embed UnimplementedPostServiceServer
88
+
// for forward compatibility.
89
+
type PostServiceServer interface {
90
+
CreatePost(context.Context, *CreatePostRequest) (*CreatePostResponse, error)
91
+
DeletePost(context.Context, *DeletePostRequest) (*DeletePostResponse, error)
92
+
GetPost(context.Context, *GetPostRequest) (*GetPostResponse, error)
93
+
GetPosts(context.Context, *GetPostsRequest) (*GetPostsResponse, error)
94
+
mustEmbedUnimplementedPostServiceServer()
95
+
}
96
+
97
+
// UnimplementedPostServiceServer must be embedded to have
98
+
// forward compatible implementations.
99
+
//
100
+
// NOTE: this should be embedded by value instead of pointer to avoid a nil
101
+
// pointer dereference when methods are called.
102
+
type UnimplementedPostServiceServer struct{}
103
+
104
+
func (UnimplementedPostServiceServer) CreatePost(context.Context, *CreatePostRequest) (*CreatePostResponse, error) {
105
+
return nil, status.Error(codes.Unimplemented, "method CreatePost not implemented")
106
+
}
107
+
func (UnimplementedPostServiceServer) DeletePost(context.Context, *DeletePostRequest) (*DeletePostResponse, error) {
108
+
return nil, status.Error(codes.Unimplemented, "method DeletePost not implemented")
109
+
}
110
+
func (UnimplementedPostServiceServer) GetPost(context.Context, *GetPostRequest) (*GetPostResponse, error) {
111
+
return nil, status.Error(codes.Unimplemented, "method GetPost not implemented")
112
+
}
113
+
func (UnimplementedPostServiceServer) GetPosts(context.Context, *GetPostsRequest) (*GetPostsResponse, error) {
114
+
return nil, status.Error(codes.Unimplemented, "method GetPosts not implemented")
115
+
}
116
+
func (UnimplementedPostServiceServer) mustEmbedUnimplementedPostServiceServer() {}
117
+
func (UnimplementedPostServiceServer) testEmbeddedByValue() {}
118
+
119
+
// UnsafePostServiceServer may be embedded to opt out of forward compatibility for this service.
120
+
// Use of this interface is not recommended, as added methods to PostServiceServer will
121
+
// result in compilation errors.
122
+
type UnsafePostServiceServer interface {
123
+
mustEmbedUnimplementedPostServiceServer()
124
+
}
125
+
126
+
func RegisterPostServiceServer(s grpc.ServiceRegistrar, srv PostServiceServer) {
127
+
// If the following call panics, it indicates UnimplementedPostServiceServer was
128
+
// embedded by pointer and is nil. This will cause panics if an
129
+
// unimplemented method is ever invoked, so we test this at initialization
130
+
// time to prevent it from happening at runtime later due to I/O.
131
+
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
132
+
t.testEmbeddedByValue()
133
+
}
134
+
s.RegisterService(&PostService_ServiceDesc, srv)
135
+
}
136
+
137
+
func _PostService_CreatePost_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
138
+
in := new(CreatePostRequest)
139
+
if err := dec(in); err != nil {
140
+
return nil, err
141
+
}
142
+
if interceptor == nil {
143
+
return srv.(PostServiceServer).CreatePost(ctx, in)
144
+
}
145
+
info := &grpc.UnaryServerInfo{
146
+
Server: srv,
147
+
FullMethod: PostService_CreatePost_FullMethodName,
148
+
}
149
+
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
150
+
return srv.(PostServiceServer).CreatePost(ctx, req.(*CreatePostRequest))
151
+
}
152
+
return interceptor(ctx, in, info, handler)
153
+
}
154
+
155
+
func _PostService_DeletePost_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
156
+
in := new(DeletePostRequest)
157
+
if err := dec(in); err != nil {
158
+
return nil, err
159
+
}
160
+
if interceptor == nil {
161
+
return srv.(PostServiceServer).DeletePost(ctx, in)
162
+
}
163
+
info := &grpc.UnaryServerInfo{
164
+
Server: srv,
165
+
FullMethod: PostService_DeletePost_FullMethodName,
166
+
}
167
+
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
168
+
return srv.(PostServiceServer).DeletePost(ctx, req.(*DeletePostRequest))
169
+
}
170
+
return interceptor(ctx, in, info, handler)
171
+
}
172
+
173
+
func _PostService_GetPost_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
174
+
in := new(GetPostRequest)
175
+
if err := dec(in); err != nil {
176
+
return nil, err
177
+
}
178
+
if interceptor == nil {
179
+
return srv.(PostServiceServer).GetPost(ctx, in)
180
+
}
181
+
info := &grpc.UnaryServerInfo{
182
+
Server: srv,
183
+
FullMethod: PostService_GetPost_FullMethodName,
184
+
}
185
+
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
186
+
return srv.(PostServiceServer).GetPost(ctx, req.(*GetPostRequest))
187
+
}
188
+
return interceptor(ctx, in, info, handler)
189
+
}
190
+
191
+
func _PostService_GetPosts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
192
+
in := new(GetPostsRequest)
193
+
if err := dec(in); err != nil {
194
+
return nil, err
195
+
}
196
+
if interceptor == nil {
197
+
return srv.(PostServiceServer).GetPosts(ctx, in)
198
+
}
199
+
info := &grpc.UnaryServerInfo{
200
+
Server: srv,
201
+
FullMethod: PostService_GetPosts_FullMethodName,
202
+
}
203
+
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
204
+
return srv.(PostServiceServer).GetPosts(ctx, req.(*GetPostsRequest))
205
+
}
206
+
return interceptor(ctx, in, info, handler)
207
+
}
208
+
209
+
// PostService_ServiceDesc is the grpc.ServiceDesc for PostService service.
210
+
// It's only intended for direct use with grpc.RegisterService,
211
+
// and not to be introspected or modified (even as a copy)
212
+
var PostService_ServiceDesc = grpc.ServiceDesc{
213
+
ServiceName: "vyletdatabase.PostService",
214
+
HandlerType: (*PostServiceServer)(nil),
215
+
Methods: []grpc.MethodDesc{
216
+
{
217
+
MethodName: "CreatePost",
218
+
Handler: _PostService_CreatePost_Handler,
219
+
},
220
+
{
221
+
MethodName: "DeletePost",
222
+
Handler: _PostService_DeletePost_Handler,
223
+
},
224
+
{
225
+
MethodName: "GetPost",
226
+
Handler: _PostService_GetPost_Handler,
227
+
},
228
+
{
229
+
MethodName: "GetPosts",
230
+
Handler: _PostService_GetPosts_Handler,
231
+
},
232
+
},
233
+
Streams: []grpc.StreamDesc{},
234
+
Metadata: "post.proto",
235
+
}
+298
-187
database/proto/profile.pb.go
+298
-187
database/proto/profile.pb.go
···
23
23
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
24
24
)
25
25
26
-
type GetProfileRequest struct {
26
+
type Profile struct {
27
27
state protoimpl.MessageState `protogen:"open.v1"`
28
28
Did string `protobuf:"bytes,1,opt,name=did,proto3" json:"did,omitempty"`
29
+
DisplayName *string `protobuf:"bytes,2,opt,name=display_name,json=displayName,proto3,oneof" json:"display_name,omitempty"`
30
+
Description *string `protobuf:"bytes,3,opt,name=description,proto3,oneof" json:"description,omitempty"`
31
+
Pronouns *string `protobuf:"bytes,4,opt,name=pronouns,proto3,oneof" json:"pronouns,omitempty"`
32
+
Avatar *string `protobuf:"bytes,5,opt,name=avatar,proto3,oneof" json:"avatar,omitempty"`
33
+
CreatedAt *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
34
+
IndexedAt *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=indexed_at,json=indexedAt,proto3" json:"indexed_at,omitempty"`
29
35
unknownFields protoimpl.UnknownFields
30
36
sizeCache protoimpl.SizeCache
31
37
}
32
38
33
-
func (x *GetProfileRequest) Reset() {
34
-
*x = GetProfileRequest{}
39
+
func (x *Profile) Reset() {
40
+
*x = Profile{}
35
41
mi := &file_profile_proto_msgTypes[0]
36
42
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
37
43
ms.StoreMessageInfo(mi)
38
44
}
39
45
40
-
func (x *GetProfileRequest) String() string {
46
+
func (x *Profile) String() string {
41
47
return protoimpl.X.MessageStringOf(x)
42
48
}
43
49
44
-
func (*GetProfileRequest) ProtoMessage() {}
50
+
func (*Profile) ProtoMessage() {}
45
51
46
-
func (x *GetProfileRequest) ProtoReflect() protoreflect.Message {
52
+
func (x *Profile) ProtoReflect() protoreflect.Message {
47
53
mi := &file_profile_proto_msgTypes[0]
48
54
if x != nil {
49
55
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
···
55
61
return mi.MessageOf(x)
56
62
}
57
63
58
-
// Deprecated: Use GetProfileRequest.ProtoReflect.Descriptor instead.
59
-
func (*GetProfileRequest) Descriptor() ([]byte, []int) {
64
+
// Deprecated: Use Profile.ProtoReflect.Descriptor instead.
65
+
func (*Profile) Descriptor() ([]byte, []int) {
60
66
return file_profile_proto_rawDescGZIP(), []int{0}
61
67
}
62
68
63
-
func (x *GetProfileRequest) GetDid() string {
64
-
if x != nil {
65
-
return x.Did
66
-
}
67
-
return ""
68
-
}
69
-
70
-
type GetProfileResponse struct {
71
-
state protoimpl.MessageState `protogen:"open.v1"`
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"`
80
-
unknownFields protoimpl.UnknownFields
81
-
sizeCache protoimpl.SizeCache
82
-
}
83
-
84
-
func (x *GetProfileResponse) Reset() {
85
-
*x = GetProfileResponse{}
86
-
mi := &file_profile_proto_msgTypes[1]
87
-
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
88
-
ms.StoreMessageInfo(mi)
89
-
}
90
-
91
-
func (x *GetProfileResponse) String() string {
92
-
return protoimpl.X.MessageStringOf(x)
93
-
}
94
-
95
-
func (*GetProfileResponse) ProtoMessage() {}
96
-
97
-
func (x *GetProfileResponse) ProtoReflect() protoreflect.Message {
98
-
mi := &file_profile_proto_msgTypes[1]
99
-
if x != nil {
100
-
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
101
-
if ms.LoadMessageInfo() == nil {
102
-
ms.StoreMessageInfo(mi)
103
-
}
104
-
return ms
105
-
}
106
-
return mi.MessageOf(x)
107
-
}
108
-
109
-
// Deprecated: Use GetProfileResponse.ProtoReflect.Descriptor instead.
110
-
func (*GetProfileResponse) Descriptor() ([]byte, []int) {
111
-
return file_profile_proto_rawDescGZIP(), []int{1}
112
-
}
113
-
114
-
func (x *GetProfileResponse) GetError() string {
115
-
if x != nil && x.Error != nil {
116
-
return *x.Error
117
-
}
118
-
return ""
119
-
}
120
-
121
-
func (x *GetProfileResponse) GetDid() string {
69
+
func (x *Profile) GetDid() string {
122
70
if x != nil {
123
71
return x.Did
124
72
}
125
73
return ""
126
74
}
127
75
128
-
func (x *GetProfileResponse) GetDisplayName() string {
76
+
func (x *Profile) GetDisplayName() string {
129
77
if x != nil && x.DisplayName != nil {
130
78
return *x.DisplayName
131
79
}
132
80
return ""
133
81
}
134
82
135
-
func (x *GetProfileResponse) GetDescription() string {
83
+
func (x *Profile) GetDescription() string {
136
84
if x != nil && x.Description != nil {
137
85
return *x.Description
138
86
}
139
87
return ""
140
88
}
141
89
142
-
func (x *GetProfileResponse) GetPronouns() string {
90
+
func (x *Profile) GetPronouns() string {
143
91
if x != nil && x.Pronouns != nil {
144
92
return *x.Pronouns
145
93
}
146
94
return ""
147
95
}
148
96
149
-
func (x *GetProfileResponse) GetAvatar() string {
97
+
func (x *Profile) GetAvatar() string {
150
98
if x != nil && x.Avatar != nil {
151
99
return *x.Avatar
152
100
}
153
101
return ""
154
102
}
155
103
156
-
func (x *GetProfileResponse) GetCreatedAt() *timestamppb.Timestamp {
104
+
func (x *Profile) GetCreatedAt() *timestamppb.Timestamp {
157
105
if x != nil {
158
106
return x.CreatedAt
159
107
}
160
108
return nil
161
109
}
162
110
163
-
func (x *GetProfileResponse) GetIndexedAt() *timestamppb.Timestamp {
111
+
func (x *Profile) GetIndexedAt() *timestamppb.Timestamp {
164
112
if x != nil {
165
113
return x.IndexedAt
166
114
}
···
169
117
170
118
type CreateProfileRequest struct {
171
119
state protoimpl.MessageState `protogen:"open.v1"`
172
-
Did string `protobuf:"bytes,1,opt,name=did,proto3" json:"did,omitempty"`
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"`
120
+
Profile *Profile `protobuf:"bytes,1,opt,name=profile,proto3" json:"profile,omitempty"`
178
121
unknownFields protoimpl.UnknownFields
179
122
sizeCache protoimpl.SizeCache
180
123
}
181
124
182
125
func (x *CreateProfileRequest) Reset() {
183
126
*x = CreateProfileRequest{}
184
-
mi := &file_profile_proto_msgTypes[2]
127
+
mi := &file_profile_proto_msgTypes[1]
185
128
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
186
129
ms.StoreMessageInfo(mi)
187
130
}
···
193
136
func (*CreateProfileRequest) ProtoMessage() {}
194
137
195
138
func (x *CreateProfileRequest) ProtoReflect() protoreflect.Message {
196
-
mi := &file_profile_proto_msgTypes[2]
139
+
mi := &file_profile_proto_msgTypes[1]
197
140
if x != nil {
198
141
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
199
142
if ms.LoadMessageInfo() == nil {
···
206
149
207
150
// Deprecated: Use CreateProfileRequest.ProtoReflect.Descriptor instead.
208
151
func (*CreateProfileRequest) Descriptor() ([]byte, []int) {
209
-
return file_profile_proto_rawDescGZIP(), []int{2}
152
+
return file_profile_proto_rawDescGZIP(), []int{1}
210
153
}
211
154
212
-
func (x *CreateProfileRequest) GetDid() string {
155
+
func (x *CreateProfileRequest) GetProfile() *Profile {
213
156
if x != nil {
214
-
return x.Did
157
+
return x.Profile
215
158
}
216
-
return ""
217
-
}
218
-
219
-
func (x *CreateProfileRequest) GetCreatedAt() string {
220
-
if x != nil && x.CreatedAt != nil {
221
-
return *x.CreatedAt
222
-
}
223
-
return ""
224
-
}
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 ""
159
+
return nil
252
160
}
253
161
254
162
type CreateProfileResponse struct {
···
260
168
261
169
func (x *CreateProfileResponse) Reset() {
262
170
*x = CreateProfileResponse{}
263
-
mi := &file_profile_proto_msgTypes[3]
171
+
mi := &file_profile_proto_msgTypes[2]
264
172
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
265
173
ms.StoreMessageInfo(mi)
266
174
}
···
272
180
func (*CreateProfileResponse) ProtoMessage() {}
273
181
274
182
func (x *CreateProfileResponse) ProtoReflect() protoreflect.Message {
275
-
mi := &file_profile_proto_msgTypes[3]
183
+
mi := &file_profile_proto_msgTypes[2]
276
184
if x != nil {
277
185
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
278
186
if ms.LoadMessageInfo() == nil {
···
285
193
286
194
// Deprecated: Use CreateProfileResponse.ProtoReflect.Descriptor instead.
287
195
func (*CreateProfileResponse) Descriptor() ([]byte, []int) {
288
-
return file_profile_proto_rawDescGZIP(), []int{3}
196
+
return file_profile_proto_rawDescGZIP(), []int{2}
289
197
}
290
198
291
199
func (x *CreateProfileResponse) GetError() string {
···
304
212
305
213
func (x *DeleteProfileRequest) Reset() {
306
214
*x = DeleteProfileRequest{}
307
-
mi := &file_profile_proto_msgTypes[4]
215
+
mi := &file_profile_proto_msgTypes[3]
308
216
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
309
217
ms.StoreMessageInfo(mi)
310
218
}
···
316
224
func (*DeleteProfileRequest) ProtoMessage() {}
317
225
318
226
func (x *DeleteProfileRequest) ProtoReflect() protoreflect.Message {
319
-
mi := &file_profile_proto_msgTypes[4]
227
+
mi := &file_profile_proto_msgTypes[3]
320
228
if x != nil {
321
229
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
322
230
if ms.LoadMessageInfo() == nil {
···
329
237
330
238
// Deprecated: Use DeleteProfileRequest.ProtoReflect.Descriptor instead.
331
239
func (*DeleteProfileRequest) Descriptor() ([]byte, []int) {
332
-
return file_profile_proto_rawDescGZIP(), []int{4}
240
+
return file_profile_proto_rawDescGZIP(), []int{3}
333
241
}
334
242
335
243
func (x *DeleteProfileRequest) GetDid() string {
···
348
256
349
257
func (x *DeleteProfileResponse) Reset() {
350
258
*x = DeleteProfileResponse{}
351
-
mi := &file_profile_proto_msgTypes[5]
259
+
mi := &file_profile_proto_msgTypes[4]
352
260
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
353
261
ms.StoreMessageInfo(mi)
354
262
}
···
360
268
func (*DeleteProfileResponse) ProtoMessage() {}
361
269
362
270
func (x *DeleteProfileResponse) ProtoReflect() protoreflect.Message {
363
-
mi := &file_profile_proto_msgTypes[5]
271
+
mi := &file_profile_proto_msgTypes[4]
364
272
if x != nil {
365
273
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
366
274
if ms.LoadMessageInfo() == nil {
···
373
281
374
282
// Deprecated: Use DeleteProfileResponse.ProtoReflect.Descriptor instead.
375
283
func (*DeleteProfileResponse) Descriptor() ([]byte, []int) {
284
+
return file_profile_proto_rawDescGZIP(), []int{4}
285
+
}
286
+
287
+
func (x *DeleteProfileResponse) GetError() string {
288
+
if x != nil && x.Error != nil {
289
+
return *x.Error
290
+
}
291
+
return ""
292
+
}
293
+
294
+
type GetProfileRequest struct {
295
+
state protoimpl.MessageState `protogen:"open.v1"`
296
+
Did string `protobuf:"bytes,1,opt,name=did,proto3" json:"did,omitempty"`
297
+
unknownFields protoimpl.UnknownFields
298
+
sizeCache protoimpl.SizeCache
299
+
}
300
+
301
+
func (x *GetProfileRequest) Reset() {
302
+
*x = GetProfileRequest{}
303
+
mi := &file_profile_proto_msgTypes[5]
304
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
305
+
ms.StoreMessageInfo(mi)
306
+
}
307
+
308
+
func (x *GetProfileRequest) String() string {
309
+
return protoimpl.X.MessageStringOf(x)
310
+
}
311
+
312
+
func (*GetProfileRequest) ProtoMessage() {}
313
+
314
+
func (x *GetProfileRequest) ProtoReflect() protoreflect.Message {
315
+
mi := &file_profile_proto_msgTypes[5]
316
+
if x != nil {
317
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
318
+
if ms.LoadMessageInfo() == nil {
319
+
ms.StoreMessageInfo(mi)
320
+
}
321
+
return ms
322
+
}
323
+
return mi.MessageOf(x)
324
+
}
325
+
326
+
// Deprecated: Use GetProfileRequest.ProtoReflect.Descriptor instead.
327
+
func (*GetProfileRequest) Descriptor() ([]byte, []int) {
376
328
return file_profile_proto_rawDescGZIP(), []int{5}
377
329
}
378
330
379
-
func (x *DeleteProfileResponse) GetError() string {
331
+
func (x *GetProfileRequest) GetDid() string {
332
+
if x != nil {
333
+
return x.Did
334
+
}
335
+
return ""
336
+
}
337
+
338
+
type GetProfileResponse struct {
339
+
state protoimpl.MessageState `protogen:"open.v1"`
340
+
Error *string `protobuf:"bytes,1,opt,name=error,proto3,oneof" json:"error,omitempty"`
341
+
Profile *Profile `protobuf:"bytes,2,opt,name=profile,proto3,oneof" json:"profile,omitempty"`
342
+
unknownFields protoimpl.UnknownFields
343
+
sizeCache protoimpl.SizeCache
344
+
}
345
+
346
+
func (x *GetProfileResponse) Reset() {
347
+
*x = GetProfileResponse{}
348
+
mi := &file_profile_proto_msgTypes[6]
349
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
350
+
ms.StoreMessageInfo(mi)
351
+
}
352
+
353
+
func (x *GetProfileResponse) String() string {
354
+
return protoimpl.X.MessageStringOf(x)
355
+
}
356
+
357
+
func (*GetProfileResponse) ProtoMessage() {}
358
+
359
+
func (x *GetProfileResponse) ProtoReflect() protoreflect.Message {
360
+
mi := &file_profile_proto_msgTypes[6]
361
+
if x != nil {
362
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
363
+
if ms.LoadMessageInfo() == nil {
364
+
ms.StoreMessageInfo(mi)
365
+
}
366
+
return ms
367
+
}
368
+
return mi.MessageOf(x)
369
+
}
370
+
371
+
// Deprecated: Use GetProfileResponse.ProtoReflect.Descriptor instead.
372
+
func (*GetProfileResponse) Descriptor() ([]byte, []int) {
373
+
return file_profile_proto_rawDescGZIP(), []int{6}
374
+
}
375
+
376
+
func (x *GetProfileResponse) GetError() string {
377
+
if x != nil && x.Error != nil {
378
+
return *x.Error
379
+
}
380
+
return ""
381
+
}
382
+
383
+
func (x *GetProfileResponse) GetProfile() *Profile {
384
+
if x != nil {
385
+
return x.Profile
386
+
}
387
+
return nil
388
+
}
389
+
390
+
type GetProfilesRequest struct {
391
+
state protoimpl.MessageState `protogen:"open.v1"`
392
+
Dids []string `protobuf:"bytes,1,rep,name=dids,proto3" json:"dids,omitempty"`
393
+
unknownFields protoimpl.UnknownFields
394
+
sizeCache protoimpl.SizeCache
395
+
}
396
+
397
+
func (x *GetProfilesRequest) Reset() {
398
+
*x = GetProfilesRequest{}
399
+
mi := &file_profile_proto_msgTypes[7]
400
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
401
+
ms.StoreMessageInfo(mi)
402
+
}
403
+
404
+
func (x *GetProfilesRequest) String() string {
405
+
return protoimpl.X.MessageStringOf(x)
406
+
}
407
+
408
+
func (*GetProfilesRequest) ProtoMessage() {}
409
+
410
+
func (x *GetProfilesRequest) ProtoReflect() protoreflect.Message {
411
+
mi := &file_profile_proto_msgTypes[7]
412
+
if x != nil {
413
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
414
+
if ms.LoadMessageInfo() == nil {
415
+
ms.StoreMessageInfo(mi)
416
+
}
417
+
return ms
418
+
}
419
+
return mi.MessageOf(x)
420
+
}
421
+
422
+
// Deprecated: Use GetProfilesRequest.ProtoReflect.Descriptor instead.
423
+
func (*GetProfilesRequest) Descriptor() ([]byte, []int) {
424
+
return file_profile_proto_rawDescGZIP(), []int{7}
425
+
}
426
+
427
+
func (x *GetProfilesRequest) GetDids() []string {
428
+
if x != nil {
429
+
return x.Dids
430
+
}
431
+
return nil
432
+
}
433
+
434
+
type GetProfilesResponse struct {
435
+
state protoimpl.MessageState `protogen:"open.v1"`
436
+
Error *string `protobuf:"bytes,1,opt,name=error,proto3,oneof" json:"error,omitempty"`
437
+
Profiles []*Profile `protobuf:"bytes,2,rep,name=profiles,proto3" json:"profiles,omitempty"`
438
+
unknownFields protoimpl.UnknownFields
439
+
sizeCache protoimpl.SizeCache
440
+
}
441
+
442
+
func (x *GetProfilesResponse) Reset() {
443
+
*x = GetProfilesResponse{}
444
+
mi := &file_profile_proto_msgTypes[8]
445
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
446
+
ms.StoreMessageInfo(mi)
447
+
}
448
+
449
+
func (x *GetProfilesResponse) String() string {
450
+
return protoimpl.X.MessageStringOf(x)
451
+
}
452
+
453
+
func (*GetProfilesResponse) ProtoMessage() {}
454
+
455
+
func (x *GetProfilesResponse) ProtoReflect() protoreflect.Message {
456
+
mi := &file_profile_proto_msgTypes[8]
457
+
if x != nil {
458
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
459
+
if ms.LoadMessageInfo() == nil {
460
+
ms.StoreMessageInfo(mi)
461
+
}
462
+
return ms
463
+
}
464
+
return mi.MessageOf(x)
465
+
}
466
+
467
+
// Deprecated: Use GetProfilesResponse.ProtoReflect.Descriptor instead.
468
+
func (*GetProfilesResponse) Descriptor() ([]byte, []int) {
469
+
return file_profile_proto_rawDescGZIP(), []int{8}
470
+
}
471
+
472
+
func (x *GetProfilesResponse) GetError() string {
380
473
if x != nil && x.Error != nil {
381
474
return *x.Error
382
475
}
383
476
return ""
384
477
}
385
478
479
+
func (x *GetProfilesResponse) GetProfiles() []*Profile {
480
+
if x != nil {
481
+
return x.Profiles
482
+
}
483
+
return nil
484
+
}
485
+
386
486
var File_profile_proto protoreflect.FileDescriptor
387
487
388
488
const file_profile_proto_rawDesc = "" +
389
489
"\n" +
390
-
"\rprofile.proto\x12\rvyletdatabase\x1a\x1bbuf/validate/validate.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"-\n" +
391
-
"\x11GetProfileRequest\x12\x18\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" +
490
+
"\rprofile.proto\x12\rvyletdatabase\x1a\x1bbuf/validate/validate.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\xdf\x02\n" +
491
+
"\aProfile\x12\x18\n" +
492
+
"\x03did\x18\x01 \x01(\tB\x06\xbaH\x03\xc8\x01\x01R\x03did\x12&\n" +
493
+
"\fdisplay_name\x18\x02 \x01(\tH\x00R\vdisplayName\x88\x01\x01\x12%\n" +
494
+
"\vdescription\x18\x03 \x01(\tH\x01R\vdescription\x88\x01\x01\x12\x1f\n" +
495
+
"\bpronouns\x18\x04 \x01(\tH\x02R\bpronouns\x88\x01\x01\x12\x1b\n" +
496
+
"\x06avatar\x18\x05 \x01(\tH\x03R\x06avatar\x88\x01\x01\x129\n" +
400
497
"\n" +
401
-
"created_at\x18\a \x01(\v2\x1a.google.protobuf.TimestampH\x05R\tcreatedAt\x88\x01\x01\x129\n" +
498
+
"created_at\x18\x06 \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAt\x129\n" +
402
499
"\n" +
403
-
"indexed_at\x18\b \x01(\v2\x1a.google.protobuf.TimestampR\tindexedAtB\b\n" +
404
-
"\x06_errorB\x0f\n" +
500
+
"indexed_at\x18\a \x01(\v2\x1a.google.protobuf.TimestampR\tindexedAtB\x0f\n" +
405
501
"\r_display_nameB\x0e\n" +
406
502
"\f_descriptionB\v\n" +
407
503
"\t_pronounsB\t\n" +
408
-
"\a_avatarB\r\n" +
409
-
"\v_created_at\"\xa9\x02\n" +
410
-
"\x14CreateProfileRequest\x12\x18\n" +
411
-
"\x03did\x18\x01 \x01(\tB\x06\xbaH\x03\xc8\x01\x01R\x03did\x12\"\n" +
412
-
"\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" +
504
+
"\a_avatar\"H\n" +
505
+
"\x14CreateProfileRequest\x120\n" +
506
+
"\aprofile\x18\x01 \x01(\v2\x16.vyletdatabase.ProfileR\aprofile\"<\n" +
423
507
"\x15CreateProfileResponse\x12\x19\n" +
424
508
"\x05error\x18\x01 \x01(\tH\x00R\x05error\x88\x01\x01B\b\n" +
425
509
"\x06_error\"0\n" +
···
427
511
"\x03did\x18\x01 \x01(\tB\x06\xbaH\x03\xc8\x01\x01R\x03did\"<\n" +
428
512
"\x15DeleteProfileResponse\x12\x19\n" +
429
513
"\x05error\x18\x01 \x01(\tH\x00R\x05error\x88\x01\x01B\b\n" +
430
-
"\x06_error2\x9b\x02\n" +
431
-
"\x0eProfileService\x12Q\n" +
514
+
"\x06_error\"-\n" +
515
+
"\x11GetProfileRequest\x12\x18\n" +
516
+
"\x03did\x18\x01 \x01(\tB\x06\xbaH\x03\xc8\x01\x01R\x03did\"|\n" +
517
+
"\x12GetProfileResponse\x12\x19\n" +
518
+
"\x05error\x18\x01 \x01(\tH\x00R\x05error\x88\x01\x01\x125\n" +
519
+
"\aprofile\x18\x02 \x01(\v2\x16.vyletdatabase.ProfileH\x01R\aprofile\x88\x01\x01B\b\n" +
520
+
"\x06_errorB\n" +
432
521
"\n" +
433
-
"GetProfile\x12 .vyletdatabase.GetProfileRequest\x1a!.vyletdatabase.GetProfileResponse\x12Z\n" +
434
-
"\rDeleteProfile\x12#.vyletdatabase.DeleteProfileRequest\x1a$.vyletdatabase.DeleteProfileResponse\x12Z\n" +
435
-
"\rCreateProfile\x12#.vyletdatabase.CreateProfileRequest\x1a$.vyletdatabase.CreateProfileResponseB\x87\x01\n" +
522
+
"\b_profile\"0\n" +
523
+
"\x12GetProfilesRequest\x12\x1a\n" +
524
+
"\x04dids\x18\x01 \x03(\tB\x06\xbaH\x03\xc8\x01\x01R\x04dids\"n\n" +
525
+
"\x13GetProfilesResponse\x12\x19\n" +
526
+
"\x05error\x18\x01 \x01(\tH\x00R\x05error\x88\x01\x01\x122\n" +
527
+
"\bprofiles\x18\x02 \x03(\v2\x16.vyletdatabase.ProfileR\bprofilesB\b\n" +
528
+
"\x06_error2\xcd\x03\n" +
529
+
"\x0eProfileService\x12Z\n" +
530
+
"\rCreateProfile\x12#.vyletdatabase.CreateProfileRequest\x1a$.vyletdatabase.CreateProfileResponse\x12Z\n" +
531
+
"\rUpdateProfile\x12#.vyletdatabase.CreateProfileRequest\x1a$.vyletdatabase.CreateProfileResponse\x12Z\n" +
532
+
"\rDeleteProfile\x12#.vyletdatabase.DeleteProfileRequest\x1a$.vyletdatabase.DeleteProfileResponse\x12Q\n" +
533
+
"\n" +
534
+
"GetProfile\x12 .vyletdatabase.GetProfileRequest\x1a!.vyletdatabase.GetProfileResponse\x12T\n" +
535
+
"\vGetProfiles\x12!.vyletdatabase.GetProfilesRequest\x1a\".vyletdatabase.GetProfilesResponseB\x87\x01\n" +
436
536
"\x11com.vyletdatabaseB\fProfileProtoP\x01Z\x10./;vyletdatabase\xa2\x02\x03VXX\xaa\x02\rVyletdatabase\xca\x02\rVyletdatabase\xe2\x02\x19Vyletdatabase\\GPBMetadata\xea\x02\rVyletdatabaseb\x06proto3"
437
537
438
538
var (
···
447
547
return file_profile_proto_rawDescData
448
548
}
449
549
450
-
var file_profile_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
550
+
var file_profile_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
451
551
var file_profile_proto_goTypes = []any{
452
-
(*GetProfileRequest)(nil), // 0: vyletdatabase.GetProfileRequest
453
-
(*GetProfileResponse)(nil), // 1: vyletdatabase.GetProfileResponse
454
-
(*CreateProfileRequest)(nil), // 2: vyletdatabase.CreateProfileRequest
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
552
+
(*Profile)(nil), // 0: vyletdatabase.Profile
553
+
(*CreateProfileRequest)(nil), // 1: vyletdatabase.CreateProfileRequest
554
+
(*CreateProfileResponse)(nil), // 2: vyletdatabase.CreateProfileResponse
555
+
(*DeleteProfileRequest)(nil), // 3: vyletdatabase.DeleteProfileRequest
556
+
(*DeleteProfileResponse)(nil), // 4: vyletdatabase.DeleteProfileResponse
557
+
(*GetProfileRequest)(nil), // 5: vyletdatabase.GetProfileRequest
558
+
(*GetProfileResponse)(nil), // 6: vyletdatabase.GetProfileResponse
559
+
(*GetProfilesRequest)(nil), // 7: vyletdatabase.GetProfilesRequest
560
+
(*GetProfilesResponse)(nil), // 8: vyletdatabase.GetProfilesResponse
561
+
(*timestamppb.Timestamp)(nil), // 9: google.protobuf.Timestamp
459
562
}
460
563
var file_profile_proto_depIdxs = []int32{
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
564
+
9, // 0: vyletdatabase.Profile.created_at:type_name -> google.protobuf.Timestamp
565
+
9, // 1: vyletdatabase.Profile.indexed_at:type_name -> google.protobuf.Timestamp
566
+
0, // 2: vyletdatabase.CreateProfileRequest.profile:type_name -> vyletdatabase.Profile
567
+
0, // 3: vyletdatabase.GetProfileResponse.profile:type_name -> vyletdatabase.Profile
568
+
0, // 4: vyletdatabase.GetProfilesResponse.profiles:type_name -> vyletdatabase.Profile
569
+
1, // 5: vyletdatabase.ProfileService.CreateProfile:input_type -> vyletdatabase.CreateProfileRequest
570
+
1, // 6: vyletdatabase.ProfileService.UpdateProfile:input_type -> vyletdatabase.CreateProfileRequest
571
+
3, // 7: vyletdatabase.ProfileService.DeleteProfile:input_type -> vyletdatabase.DeleteProfileRequest
572
+
5, // 8: vyletdatabase.ProfileService.GetProfile:input_type -> vyletdatabase.GetProfileRequest
573
+
7, // 9: vyletdatabase.ProfileService.GetProfiles:input_type -> vyletdatabase.GetProfilesRequest
574
+
2, // 10: vyletdatabase.ProfileService.CreateProfile:output_type -> vyletdatabase.CreateProfileResponse
575
+
2, // 11: vyletdatabase.ProfileService.UpdateProfile:output_type -> vyletdatabase.CreateProfileResponse
576
+
4, // 12: vyletdatabase.ProfileService.DeleteProfile:output_type -> vyletdatabase.DeleteProfileResponse
577
+
6, // 13: vyletdatabase.ProfileService.GetProfile:output_type -> vyletdatabase.GetProfileResponse
578
+
8, // 14: vyletdatabase.ProfileService.GetProfiles:output_type -> vyletdatabase.GetProfilesResponse
579
+
10, // [10:15] is the sub-list for method output_type
580
+
5, // [5:10] is the sub-list for method input_type
581
+
5, // [5:5] is the sub-list for extension type_name
582
+
5, // [5:5] is the sub-list for extension extendee
583
+
0, // [0:5] is the sub-list for field type_name
474
584
}
475
585
476
586
func init() { file_profile_proto_init() }
···
478
588
if File_profile_proto != nil {
479
589
return
480
590
}
481
-
file_profile_proto_msgTypes[1].OneofWrappers = []any{}
591
+
file_profile_proto_msgTypes[0].OneofWrappers = []any{}
482
592
file_profile_proto_msgTypes[2].OneofWrappers = []any{}
483
-
file_profile_proto_msgTypes[3].OneofWrappers = []any{}
484
-
file_profile_proto_msgTypes[5].OneofWrappers = []any{}
593
+
file_profile_proto_msgTypes[4].OneofWrappers = []any{}
594
+
file_profile_proto_msgTypes[6].OneofWrappers = []any{}
595
+
file_profile_proto_msgTypes[8].OneofWrappers = []any{}
485
596
type x struct{}
486
597
out := protoimpl.TypeBuilder{
487
598
File: protoimpl.DescBuilder{
488
599
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
489
600
RawDescriptor: unsafe.Slice(unsafe.StringData(file_profile_proto_rawDesc), len(file_profile_proto_rawDesc)),
490
601
NumEnums: 0,
491
-
NumMessages: 6,
602
+
NumMessages: 9,
492
603
NumExtensions: 0,
493
604
NumServices: 1,
494
605
},
+31
-21
database/proto/profile.proto
+31
-21
database/proto/profile.proto
···
8
8
import "google/protobuf/timestamp.proto";
9
9
10
10
service ProfileService {
11
+
rpc CreateProfile(CreateProfileRequest) returns (CreateProfileResponse);
12
+
rpc UpdateProfile(CreateProfileRequest) returns (CreateProfileResponse);
13
+
rpc DeleteProfile(DeleteProfileRequest) returns (DeleteProfileResponse);
14
+
11
15
rpc GetProfile(GetProfileRequest) returns (GetProfileResponse);
12
-
rpc DeleteProfile(DeleteProfileRequest) returns (DeleteProfileResponse);
13
-
rpc CreateProfile(CreateProfileRequest) returns (CreateProfileResponse);
16
+
rpc GetProfiles(GetProfilesRequest) returns (GetProfilesResponse);
14
17
}
15
18
16
-
message GetProfileRequest {
19
+
message Profile {
17
20
string did = 1 [
18
21
(buf.validate.field).required = true
19
22
];
23
+
optional string display_name = 2;
24
+
optional string description = 3;
25
+
optional string pronouns = 4;
26
+
optional string avatar = 5;
27
+
google.protobuf.Timestamp created_at = 6;
28
+
google.protobuf.Timestamp indexed_at = 7;
20
29
}
21
30
22
-
message GetProfileResponse {
31
+
message CreateProfileRequest {
32
+
Profile profile = 1;
33
+
}
34
+
35
+
message CreateProfileResponse {
23
36
optional string error = 1;
37
+
}
24
38
25
-
string did = 2 [
39
+
message DeleteProfileRequest {
40
+
string did = 1 [
26
41
(buf.validate.field).required = true
27
42
];
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;
43
+
}
44
+
45
+
message DeleteProfileResponse {
46
+
optional string error = 1;
34
47
}
35
48
36
-
message CreateProfileRequest {
49
+
message GetProfileRequest {
37
50
string did = 1 [
38
51
(buf.validate.field).required = true
39
52
];
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;
45
53
}
46
54
47
-
message CreateProfileResponse {
55
+
message GetProfileResponse {
48
56
optional string error = 1;
57
+
optional Profile profile = 2;
49
58
}
50
59
51
-
message DeleteProfileRequest {
52
-
string did = 1 [
60
+
message GetProfilesRequest {
61
+
repeated string dids = 1 [
53
62
(buf.validate.field).required = true
54
63
];
55
64
}
56
65
57
-
message DeleteProfileResponse {
66
+
message GetProfilesResponse {
58
67
optional string error = 1;
68
+
repeated Profile profiles = 2;
59
69
}
+106
-30
database/proto/profile_grpc.pb.go
+106
-30
database/proto/profile_grpc.pb.go
···
19
19
const _ = grpc.SupportPackageIsVersion9
20
20
21
21
const (
22
+
ProfileService_CreateProfile_FullMethodName = "/vyletdatabase.ProfileService/CreateProfile"
23
+
ProfileService_UpdateProfile_FullMethodName = "/vyletdatabase.ProfileService/UpdateProfile"
24
+
ProfileService_DeleteProfile_FullMethodName = "/vyletdatabase.ProfileService/DeleteProfile"
22
25
ProfileService_GetProfile_FullMethodName = "/vyletdatabase.ProfileService/GetProfile"
23
-
ProfileService_DeleteProfile_FullMethodName = "/vyletdatabase.ProfileService/DeleteProfile"
24
-
ProfileService_CreateProfile_FullMethodName = "/vyletdatabase.ProfileService/CreateProfile"
26
+
ProfileService_GetProfiles_FullMethodName = "/vyletdatabase.ProfileService/GetProfiles"
25
27
)
26
28
27
29
// ProfileServiceClient is the client API for ProfileService service.
28
30
//
29
31
// 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.
30
32
type ProfileServiceClient interface {
33
+
CreateProfile(ctx context.Context, in *CreateProfileRequest, opts ...grpc.CallOption) (*CreateProfileResponse, error)
34
+
UpdateProfile(ctx context.Context, in *CreateProfileRequest, opts ...grpc.CallOption) (*CreateProfileResponse, error)
35
+
DeleteProfile(ctx context.Context, in *DeleteProfileRequest, opts ...grpc.CallOption) (*DeleteProfileResponse, error)
31
36
GetProfile(ctx context.Context, in *GetProfileRequest, opts ...grpc.CallOption) (*GetProfileResponse, error)
32
-
DeleteProfile(ctx context.Context, in *DeleteProfileRequest, opts ...grpc.CallOption) (*DeleteProfileResponse, error)
33
-
CreateProfile(ctx context.Context, in *CreateProfileRequest, opts ...grpc.CallOption) (*CreateProfileResponse, error)
37
+
GetProfiles(ctx context.Context, in *GetProfilesRequest, opts ...grpc.CallOption) (*GetProfilesResponse, error)
34
38
}
35
39
36
40
type profileServiceClient struct {
···
41
45
return &profileServiceClient{cc}
42
46
}
43
47
44
-
func (c *profileServiceClient) GetProfile(ctx context.Context, in *GetProfileRequest, opts ...grpc.CallOption) (*GetProfileResponse, error) {
48
+
func (c *profileServiceClient) CreateProfile(ctx context.Context, in *CreateProfileRequest, opts ...grpc.CallOption) (*CreateProfileResponse, error) {
45
49
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
46
-
out := new(GetProfileResponse)
47
-
err := c.cc.Invoke(ctx, ProfileService_GetProfile_FullMethodName, in, out, cOpts...)
50
+
out := new(CreateProfileResponse)
51
+
err := c.cc.Invoke(ctx, ProfileService_CreateProfile_FullMethodName, in, out, cOpts...)
52
+
if err != nil {
53
+
return nil, err
54
+
}
55
+
return out, nil
56
+
}
57
+
58
+
func (c *profileServiceClient) UpdateProfile(ctx context.Context, in *CreateProfileRequest, opts ...grpc.CallOption) (*CreateProfileResponse, error) {
59
+
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
60
+
out := new(CreateProfileResponse)
61
+
err := c.cc.Invoke(ctx, ProfileService_UpdateProfile_FullMethodName, in, out, cOpts...)
48
62
if err != nil {
49
63
return nil, err
50
64
}
···
61
75
return out, nil
62
76
}
63
77
64
-
func (c *profileServiceClient) CreateProfile(ctx context.Context, in *CreateProfileRequest, opts ...grpc.CallOption) (*CreateProfileResponse, error) {
78
+
func (c *profileServiceClient) GetProfile(ctx context.Context, in *GetProfileRequest, opts ...grpc.CallOption) (*GetProfileResponse, error) {
65
79
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
66
-
out := new(CreateProfileResponse)
67
-
err := c.cc.Invoke(ctx, ProfileService_CreateProfile_FullMethodName, in, out, cOpts...)
80
+
out := new(GetProfileResponse)
81
+
err := c.cc.Invoke(ctx, ProfileService_GetProfile_FullMethodName, in, out, cOpts...)
82
+
if err != nil {
83
+
return nil, err
84
+
}
85
+
return out, nil
86
+
}
87
+
88
+
func (c *profileServiceClient) GetProfiles(ctx context.Context, in *GetProfilesRequest, opts ...grpc.CallOption) (*GetProfilesResponse, error) {
89
+
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
90
+
out := new(GetProfilesResponse)
91
+
err := c.cc.Invoke(ctx, ProfileService_GetProfiles_FullMethodName, in, out, cOpts...)
68
92
if err != nil {
69
93
return nil, err
70
94
}
···
75
99
// All implementations must embed UnimplementedProfileServiceServer
76
100
// for forward compatibility.
77
101
type ProfileServiceServer interface {
102
+
CreateProfile(context.Context, *CreateProfileRequest) (*CreateProfileResponse, error)
103
+
UpdateProfile(context.Context, *CreateProfileRequest) (*CreateProfileResponse, error)
104
+
DeleteProfile(context.Context, *DeleteProfileRequest) (*DeleteProfileResponse, error)
78
105
GetProfile(context.Context, *GetProfileRequest) (*GetProfileResponse, error)
79
-
DeleteProfile(context.Context, *DeleteProfileRequest) (*DeleteProfileResponse, error)
80
-
CreateProfile(context.Context, *CreateProfileRequest) (*CreateProfileResponse, error)
106
+
GetProfiles(context.Context, *GetProfilesRequest) (*GetProfilesResponse, error)
81
107
mustEmbedUnimplementedProfileServiceServer()
82
108
}
83
109
···
88
114
// pointer dereference when methods are called.
89
115
type UnimplementedProfileServiceServer struct{}
90
116
91
-
func (UnimplementedProfileServiceServer) GetProfile(context.Context, *GetProfileRequest) (*GetProfileResponse, error) {
92
-
return nil, status.Error(codes.Unimplemented, "method GetProfile not implemented")
117
+
func (UnimplementedProfileServiceServer) CreateProfile(context.Context, *CreateProfileRequest) (*CreateProfileResponse, error) {
118
+
return nil, status.Error(codes.Unimplemented, "method CreateProfile not implemented")
119
+
}
120
+
func (UnimplementedProfileServiceServer) UpdateProfile(context.Context, *CreateProfileRequest) (*CreateProfileResponse, error) {
121
+
return nil, status.Error(codes.Unimplemented, "method UpdateProfile not implemented")
93
122
}
94
123
func (UnimplementedProfileServiceServer) DeleteProfile(context.Context, *DeleteProfileRequest) (*DeleteProfileResponse, error) {
95
124
return nil, status.Error(codes.Unimplemented, "method DeleteProfile not implemented")
96
125
}
97
-
func (UnimplementedProfileServiceServer) CreateProfile(context.Context, *CreateProfileRequest) (*CreateProfileResponse, error) {
98
-
return nil, status.Error(codes.Unimplemented, "method CreateProfile not implemented")
126
+
func (UnimplementedProfileServiceServer) GetProfile(context.Context, *GetProfileRequest) (*GetProfileResponse, error) {
127
+
return nil, status.Error(codes.Unimplemented, "method GetProfile not implemented")
128
+
}
129
+
func (UnimplementedProfileServiceServer) GetProfiles(context.Context, *GetProfilesRequest) (*GetProfilesResponse, error) {
130
+
return nil, status.Error(codes.Unimplemented, "method GetProfiles not implemented")
99
131
}
100
132
func (UnimplementedProfileServiceServer) mustEmbedUnimplementedProfileServiceServer() {}
101
133
func (UnimplementedProfileServiceServer) testEmbeddedByValue() {}
···
118
150
s.RegisterService(&ProfileService_ServiceDesc, srv)
119
151
}
120
152
121
-
func _ProfileService_GetProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
122
-
in := new(GetProfileRequest)
153
+
func _ProfileService_CreateProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
154
+
in := new(CreateProfileRequest)
123
155
if err := dec(in); err != nil {
124
156
return nil, err
125
157
}
126
158
if interceptor == nil {
127
-
return srv.(ProfileServiceServer).GetProfile(ctx, in)
159
+
return srv.(ProfileServiceServer).CreateProfile(ctx, in)
128
160
}
129
161
info := &grpc.UnaryServerInfo{
130
162
Server: srv,
131
-
FullMethod: ProfileService_GetProfile_FullMethodName,
163
+
FullMethod: ProfileService_CreateProfile_FullMethodName,
132
164
}
133
165
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
134
-
return srv.(ProfileServiceServer).GetProfile(ctx, req.(*GetProfileRequest))
166
+
return srv.(ProfileServiceServer).CreateProfile(ctx, req.(*CreateProfileRequest))
167
+
}
168
+
return interceptor(ctx, in, info, handler)
169
+
}
170
+
171
+
func _ProfileService_UpdateProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
172
+
in := new(CreateProfileRequest)
173
+
if err := dec(in); err != nil {
174
+
return nil, err
175
+
}
176
+
if interceptor == nil {
177
+
return srv.(ProfileServiceServer).UpdateProfile(ctx, in)
178
+
}
179
+
info := &grpc.UnaryServerInfo{
180
+
Server: srv,
181
+
FullMethod: ProfileService_UpdateProfile_FullMethodName,
182
+
}
183
+
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
184
+
return srv.(ProfileServiceServer).UpdateProfile(ctx, req.(*CreateProfileRequest))
135
185
}
136
186
return interceptor(ctx, in, info, handler)
137
187
}
···
154
204
return interceptor(ctx, in, info, handler)
155
205
}
156
206
157
-
func _ProfileService_CreateProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
158
-
in := new(CreateProfileRequest)
207
+
func _ProfileService_GetProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
208
+
in := new(GetProfileRequest)
159
209
if err := dec(in); err != nil {
160
210
return nil, err
161
211
}
162
212
if interceptor == nil {
163
-
return srv.(ProfileServiceServer).CreateProfile(ctx, in)
213
+
return srv.(ProfileServiceServer).GetProfile(ctx, in)
164
214
}
165
215
info := &grpc.UnaryServerInfo{
166
216
Server: srv,
167
-
FullMethod: ProfileService_CreateProfile_FullMethodName,
217
+
FullMethod: ProfileService_GetProfile_FullMethodName,
168
218
}
169
219
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
170
-
return srv.(ProfileServiceServer).CreateProfile(ctx, req.(*CreateProfileRequest))
220
+
return srv.(ProfileServiceServer).GetProfile(ctx, req.(*GetProfileRequest))
221
+
}
222
+
return interceptor(ctx, in, info, handler)
223
+
}
224
+
225
+
func _ProfileService_GetProfiles_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
226
+
in := new(GetProfilesRequest)
227
+
if err := dec(in); err != nil {
228
+
return nil, err
229
+
}
230
+
if interceptor == nil {
231
+
return srv.(ProfileServiceServer).GetProfiles(ctx, in)
232
+
}
233
+
info := &grpc.UnaryServerInfo{
234
+
Server: srv,
235
+
FullMethod: ProfileService_GetProfiles_FullMethodName,
236
+
}
237
+
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
238
+
return srv.(ProfileServiceServer).GetProfiles(ctx, req.(*GetProfilesRequest))
171
239
}
172
240
return interceptor(ctx, in, info, handler)
173
241
}
···
180
248
HandlerType: (*ProfileServiceServer)(nil),
181
249
Methods: []grpc.MethodDesc{
182
250
{
183
-
MethodName: "GetProfile",
184
-
Handler: _ProfileService_GetProfile_Handler,
251
+
MethodName: "CreateProfile",
252
+
Handler: _ProfileService_CreateProfile_Handler,
253
+
},
254
+
{
255
+
MethodName: "UpdateProfile",
256
+
Handler: _ProfileService_UpdateProfile_Handler,
185
257
},
186
258
{
187
259
MethodName: "DeleteProfile",
188
260
Handler: _ProfileService_DeleteProfile_Handler,
189
261
},
190
262
{
191
-
MethodName: "CreateProfile",
192
-
Handler: _ProfileService_CreateProfile_Handler,
263
+
MethodName: "GetProfile",
264
+
Handler: _ProfileService_GetProfile_Handler,
265
+
},
266
+
{
267
+
MethodName: "GetProfiles",
268
+
Handler: _ProfileService_GetProfiles_Handler,
193
269
},
194
270
},
195
271
Streams: []grpc.StreamDesc{},
+103
database/server/post.go
+103
database/server/post.go
···
1
+
package server
2
+
3
+
import (
4
+
"context"
5
+
6
+
vyletdatabase "github.com/vylet-app/go/database/proto"
7
+
)
8
+
9
+
func (s *Server) CreatePost(ctx context.Context, req *vyletdatabase.CreatePostRequest) (*vyletdatabase.CreatePostResponse, error) {
10
+
// logger := s.logger.With("name", "CreateProfile")
11
+
// now := time.Now().UTC()
12
+
//
13
+
// if err := s.cqlSession.Query(
14
+
// `
15
+
// INSERT INTO profiles
16
+
// (did, display_name, description, pronouns, avatar, created_at, indexed_at, updated_at)
17
+
// VALUES
18
+
// (?, ?, ?, ?, ?, ?, ?, ?)
19
+
// `,
20
+
// req.Profile.Did,
21
+
// req.Profile.DisplayName,
22
+
// req.Profile.Description,
23
+
// req.Profile.Pronouns,
24
+
// req.Profile.Avatar,
25
+
// req.Profile.CreatedAt.AsTime(),
26
+
// now,
27
+
// now,
28
+
// ).WithContext(ctx).Exec(); err != nil {
29
+
// logger.Error("failed to create profile", "did", req.Profile.Did, "err", err)
30
+
// return &vyletdatabase.CreateProfileResponse{
31
+
// Error: helpers.ToStringPtr(err.Error()),
32
+
// }, nil
33
+
// }
34
+
35
+
return &vyletdatabase.CreatePostResponse{}, nil
36
+
}
37
+
38
+
func (s *Server) DeletePost(ctx context.Context, req *vyletdatabase.DeletePostRequest) (*vyletdatabase.DeletePostResponse, error) {
39
+
// logger := s.logger.With("name", "DeleteProfile")
40
+
//
41
+
// if err := s.cqlSession.Query(
42
+
// `
43
+
// DELETE FROM profiles
44
+
// WHERE
45
+
// did = ?
46
+
// `,
47
+
// req.Did,
48
+
// ).WithContext(ctx).Exec(); err != nil {
49
+
// logger.Error("failed to delete profile", "did", req.Did, "err", err)
50
+
// return &vyletdatabase.DeleteProfileResponse{
51
+
// Error: helpers.ToStringPtr(err.Error()),
52
+
// }, nil
53
+
// }
54
+
55
+
return &vyletdatabase.DeletePostResponse{}, nil
56
+
}
57
+
58
+
func (s *Server) GetPost(ctx context.Context, req *vyletdatabase.GetPostRequest) (*vyletdatabase.GetPostResponse, error) {
59
+
// logger := s.logger.With("name", "GetProfile")
60
+
//
61
+
// resp := &vyletdatabase.GetProfileResponse{
62
+
// Profile: &vyletdatabase.Profile{},
63
+
// }
64
+
// var createdAt, indexedAt time.Time
65
+
//
66
+
// if err := s.cqlSession.Query(
67
+
// `SELECT
68
+
// did,
69
+
// display_name,
70
+
// description,
71
+
// pronouns,
72
+
// avatar,
73
+
// created_at,
74
+
// indexed_at
75
+
// FROM profiles
76
+
// WHERE
77
+
// did = ?
78
+
// `,
79
+
// req.Did,
80
+
// ).WithContext(ctx).Scan(
81
+
// &resp.Profile.Did,
82
+
// &resp.Profile.DisplayName,
83
+
// &resp.Profile.Description,
84
+
// &resp.Profile.Pronouns,
85
+
// &resp.Profile.Avatar,
86
+
// &createdAt,
87
+
// &indexedAt,
88
+
// ); err != nil {
89
+
// logger.Error("failed to get profile", "did", req.Did, "err", err)
90
+
// return &vyletdatabase.GetProfileResponse{
91
+
// Error: helpers.ToStringPtr(err.Error()),
92
+
// }, nil
93
+
// }
94
+
//
95
+
// resp.Profile.CreatedAt = timestamppb.New(createdAt)
96
+
// resp.Profile.IndexedAt = timestamppb.New(indexedAt)
97
+
98
+
return nil, nil
99
+
}
100
+
101
+
func (s *Server) GetPosts(ctx context.Context, req *vyletdatabase.GetPostsRequest) (*vyletdatabase.GetPostsResponse, error) {
102
+
return nil, nil
103
+
}
+126
-38
database/server/profile.go
+126
-38
database/server/profile.go
···
11
11
12
12
func (s *Server) CreateProfile(ctx context.Context, req *vyletdatabase.CreateProfileRequest) (*vyletdatabase.CreateProfileResponse, error) {
13
13
logger := s.logger.With("name", "CreateProfile")
14
-
15
-
var createdAt string
16
-
if req.CreatedAt != nil {
17
-
createdAt = *req.CreatedAt
18
-
}
19
-
20
14
now := time.Now().UTC()
21
-
22
-
createdAtTime, err := time.Parse(time.RFC3339Nano, createdAt)
23
-
if err != nil {
24
-
createdAtTime = now
25
-
}
26
15
27
16
if err := s.cqlSession.Query(
28
17
`
···
31
20
VALUES
32
21
(?, ?, ?, ?, ?, ?, ?, ?)
33
22
`,
34
-
req.Did,
35
-
req.DisplayName,
36
-
req.Description,
37
-
req.Pronouns,
38
-
req.Avatar,
39
-
createdAtTime,
23
+
req.Profile.Did,
24
+
req.Profile.DisplayName,
25
+
req.Profile.Description,
26
+
req.Profile.Pronouns,
27
+
req.Profile.Avatar,
28
+
req.Profile.CreatedAt.AsTime(),
40
29
now,
41
30
now,
42
31
).WithContext(ctx).Exec(); err != nil {
43
-
logger.Error("failed to create profile", "did", req.Did, "err", err)
32
+
logger.Error("failed to create profile", "did", req.Profile.Did, "err", err)
44
33
return &vyletdatabase.CreateProfileResponse{
45
34
Error: helpers.ToStringPtr(err.Error()),
46
35
}, nil
···
49
38
return &vyletdatabase.CreateProfileResponse{}, nil
50
39
}
51
40
41
+
func (s *Server) UpdateProfile(ctx context.Context, req *vyletdatabase.CreateProfileRequest) (*vyletdatabase.CreateProfileResponse, error) {
42
+
logger := s.logger.With("name", "UpdateProfile")
43
+
44
+
now := time.Now().UTC()
45
+
46
+
if err := s.cqlSession.Query(
47
+
`
48
+
UPDATE profiles
49
+
SET
50
+
display_name = ?,
51
+
description = ?,
52
+
pronouns = ?,
53
+
avatar = ?,
54
+
updated_at = ?
55
+
WHERE
56
+
did = ?
57
+
`,
58
+
req.Profile.DisplayName,
59
+
req.Profile.Description,
60
+
req.Profile.Pronouns,
61
+
req.Profile.Avatar,
62
+
now,
63
+
req.Profile.Did,
64
+
).WithContext(ctx).Exec(); err != nil {
65
+
logger.Error("failed to create profile", "did", req.Profile.Did, "err", err)
66
+
return &vyletdatabase.CreateProfileResponse{
67
+
Error: helpers.ToStringPtr(err.Error()),
68
+
}, nil
69
+
}
70
+
71
+
return &vyletdatabase.CreateProfileResponse{}, nil
72
+
}
73
+
74
+
func (s *Server) DeleteProfile(ctx context.Context, req *vyletdatabase.DeleteProfileRequest) (*vyletdatabase.DeleteProfileResponse, error) {
75
+
logger := s.logger.With("name", "DeleteProfile")
76
+
77
+
if err := s.cqlSession.Query(
78
+
`
79
+
DELETE FROM profiles
80
+
WHERE
81
+
did = ?
82
+
`,
83
+
req.Did,
84
+
).WithContext(ctx).Exec(); err != nil {
85
+
logger.Error("failed to delete profile", "did", req.Did, "err", err)
86
+
return &vyletdatabase.DeleteProfileResponse{
87
+
Error: helpers.ToStringPtr(err.Error()),
88
+
}, nil
89
+
}
90
+
91
+
return &vyletdatabase.DeleteProfileResponse{}, nil
92
+
}
93
+
52
94
func (s *Server) GetProfile(ctx context.Context, req *vyletdatabase.GetProfileRequest) (*vyletdatabase.GetProfileResponse, error) {
53
95
logger := s.logger.With("name", "GetProfile")
54
96
55
-
resp := &vyletdatabase.GetProfileResponse{}
97
+
resp := &vyletdatabase.GetProfileResponse{
98
+
Profile: &vyletdatabase.Profile{},
99
+
}
56
100
var createdAt, indexedAt time.Time
57
101
58
102
if err := s.cqlSession.Query(
59
103
`SELECT
60
-
did, display_name, description, pronouns, avatar, created_at, indexed_at
104
+
did,
105
+
display_name,
106
+
description,
107
+
pronouns,
108
+
avatar,
109
+
created_at,
110
+
indexed_at
61
111
FROM profiles
62
-
WHERE did = ?
112
+
WHERE
113
+
did = ?
63
114
`,
64
115
req.Did,
65
116
).WithContext(ctx).Scan(
66
-
&resp.Did,
67
-
&resp.DisplayName,
68
-
&resp.Description,
69
-
&resp.Pronouns,
70
-
&resp.Avatar,
117
+
&resp.Profile.Did,
118
+
&resp.Profile.DisplayName,
119
+
&resp.Profile.Description,
120
+
&resp.Profile.Pronouns,
121
+
&resp.Profile.Avatar,
71
122
&createdAt,
72
123
&indexedAt,
73
124
); err != nil {
···
77
128
}, nil
78
129
}
79
130
80
-
resp.CreatedAt = timestamppb.New(createdAt)
81
-
resp.IndexedAt = timestamppb.New(indexedAt)
131
+
resp.Profile.CreatedAt = timestamppb.New(createdAt)
132
+
resp.Profile.IndexedAt = timestamppb.New(indexedAt)
82
133
83
134
return resp, nil
84
135
}
85
136
86
-
func (s *Server) DeleteProfile(ctx context.Context, req *vyletdatabase.DeleteProfileRequest) (*vyletdatabase.DeleteProfileResponse, error) {
87
-
logger := s.logger.With("name", "DeleteProfile")
137
+
func (s *Server) GetProfiles(ctx context.Context, req *vyletdatabase.GetProfilesRequest) (*vyletdatabase.GetProfilesResponse, error) {
138
+
logger := s.logger.With("name", "GetProfiles")
88
139
89
-
if err := s.cqlSession.Query(
90
-
`
91
-
DELETE FROM profiles WHERE did = ?
140
+
resp := &vyletdatabase.GetProfilesResponse{
141
+
Profiles: make([]*vyletdatabase.Profile, 0, len(req.Dids)),
142
+
}
143
+
144
+
iter := s.cqlSession.Query(
145
+
`SELECT
146
+
did,
147
+
display_name,
148
+
description,
149
+
pronouns,
150
+
avatar,
151
+
created_at,
152
+
indexed_at
153
+
FROM profiles
154
+
WHERE
155
+
did IN ?
92
156
`,
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{
157
+
req.Dids,
158
+
).WithContext(ctx).Iter()
159
+
160
+
var createdAt, indexedAt time.Time
161
+
for {
162
+
profile := &vyletdatabase.Profile{}
163
+
164
+
if !iter.Scan(
165
+
&profile.Did,
166
+
&profile.DisplayName,
167
+
&profile.Description,
168
+
&profile.Pronouns,
169
+
&profile.Avatar,
170
+
&createdAt,
171
+
&indexedAt,
172
+
) {
173
+
break
174
+
}
175
+
176
+
profile.CreatedAt = timestamppb.New(createdAt)
177
+
profile.IndexedAt = timestamppb.New(indexedAt)
178
+
179
+
resp.Profiles = append(resp.Profiles, profile)
180
+
}
181
+
182
+
if err := iter.Close(); err != nil {
183
+
logger.Error("failed to get profiles", "dids", req.Dids, "err", err)
184
+
return &vyletdatabase.GetProfilesResponse{
97
185
Error: helpers.ToStringPtr(err.Error()),
98
186
}, nil
99
187
}
100
188
101
-
return &vyletdatabase.DeleteProfileResponse{}, nil
189
+
return resp, nil
102
190
}
+2
database/server/server.go
+2
database/server/server.go
···
31
31
32
32
type Server struct {
33
33
vyletdatabase.UnimplementedProfileServiceServer
34
+
vyletdatabase.UnimplementedPostServiceServer
34
35
35
36
logger *slog.Logger
36
37
···
155
156
156
157
func (s *Server) registerServices() {
157
158
vyletdatabase.RegisterProfileServiceServer(s.grpcServer, s)
159
+
vyletdatabase.RegisterPostServiceServer(s.grpcServer, s)
158
160
reflection.Register(s.grpcServer)
159
161
}
160
162
+29
generated/vylet/actorgetProfiles.go
+29
generated/vylet/actorgetProfiles.go
···
1
+
// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
2
+
3
+
// Lexicon schema: app.vylet.actor.getProfiles
4
+
5
+
package vylet
6
+
7
+
import (
8
+
"context"
9
+
10
+
lexutil "github.com/bluesky-social/indigo/lex/util"
11
+
)
12
+
13
+
// ActorGetProfiles_Output is the output of a app.vylet.actor.getProfiles call.
14
+
type ActorGetProfiles_Output struct {
15
+
Profiles []*ActorDefs_ProfileView `json:"profiles" cborgen:"profiles"`
16
+
}
17
+
18
+
// ActorGetProfiles calls the XRPC method "app.vylet.actor.getProfiles".
19
+
func ActorGetProfiles(ctx context.Context, c lexutil.LexClient, dids []string) (*ActorGetProfiles_Output, error) {
20
+
var out ActorGetProfiles_Output
21
+
22
+
params := map[string]interface{}{}
23
+
params["dids"] = dids
24
+
if err := c.LexDo(ctx, lexutil.Query, "", "app.vylet.actor.getProfiles", params, nil, &out); err != nil {
25
+
return nil, err
26
+
}
27
+
28
+
return &out, nil
29
+
}
+1
-1
generated/vylet/actorprofile.go
+1
-1
generated/vylet/actorprofile.go
···
16
16
LexiconTypeID string `json:"$type" cborgen:"$type,const=app.vylet.actor.profile"`
17
17
// avatar: Small image to be displayed next to posts from account.
18
18
Avatar *lexutil.LexBlob `json:"avatar,omitempty" cborgen:"avatar,omitempty"`
19
-
CreatedAt *string `json:"createdAt,omitempty" cborgen:"createdAt,omitempty"`
19
+
CreatedAt string `json:"createdAt" cborgen:"createdAt"`
20
20
// description: Free-form profile description text.
21
21
Description *string `json:"description,omitempty" cborgen:"description,omitempty"`
22
22
DisplayName *string `json:"displayName,omitempty" cborgen:"displayName,omitempty"`
+19
-42
generated/vylet/cbor_gen.go
+19
-42
generated/vylet/cbor_gen.go
···
33
33
fieldCount--
34
34
}
35
35
36
-
if t.CreatedAt == nil {
37
-
fieldCount--
38
-
}
39
-
40
36
if t.Description == nil {
41
37
fieldCount--
42
38
}
···
124
120
}
125
121
126
122
// t.CreatedAt (string) (string)
127
-
if t.CreatedAt != nil {
123
+
if len("createdAt") > 1000000 {
124
+
return xerrors.Errorf("Value in field \"createdAt\" was too long")
125
+
}
128
126
129
-
if len("createdAt") > 1000000 {
130
-
return xerrors.Errorf("Value in field \"createdAt\" was too long")
131
-
}
127
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil {
128
+
return err
129
+
}
130
+
if _, err := cw.WriteString(string("createdAt")); err != nil {
131
+
return err
132
+
}
132
133
133
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil {
134
-
return err
135
-
}
136
-
if _, err := cw.WriteString(string("createdAt")); err != nil {
137
-
return err
138
-
}
134
+
if len(t.CreatedAt) > 1000000 {
135
+
return xerrors.Errorf("Value in field t.CreatedAt was too long")
136
+
}
139
137
140
-
if t.CreatedAt == nil {
141
-
if _, err := cw.Write(cbg.CborNull); err != nil {
142
-
return err
143
-
}
144
-
} else {
145
-
if len(*t.CreatedAt) > 1000000 {
146
-
return xerrors.Errorf("Value in field t.CreatedAt was too long")
147
-
}
148
-
149
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.CreatedAt))); err != nil {
150
-
return err
151
-
}
152
-
if _, err := cw.WriteString(string(*t.CreatedAt)); err != nil {
153
-
return err
154
-
}
155
-
}
138
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil {
139
+
return err
140
+
}
141
+
if _, err := cw.WriteString(string(t.CreatedAt)); err != nil {
142
+
return err
156
143
}
157
144
158
145
// t.Description (string) (string)
···
318
305
case "createdAt":
319
306
320
307
{
321
-
b, err := cr.ReadByte()
308
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
322
309
if err != nil {
323
310
return err
324
311
}
325
-
if b != cbg.CborNull[0] {
326
-
if err := cr.UnreadByte(); err != nil {
327
-
return err
328
-
}
329
312
330
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
331
-
if err != nil {
332
-
return err
333
-
}
334
-
335
-
t.CreatedAt = (*string)(&sval)
336
-
}
313
+
t.CreatedAt = string(sval)
337
314
}
338
315
// t.Description (string) (string)
339
316
case "description":
+39
-8
indexer/actorprofile.go
+39
-8
indexer/actorprofile.go
···
4
4
"context"
5
5
"encoding/json"
6
6
"fmt"
7
+
"time"
7
8
8
9
vyletkafka "github.com/vylet-app/go/bus/proto"
9
10
vyletdatabase "github.com/vylet-app/go/database/proto"
10
11
"github.com/vylet-app/go/generated/vylet"
11
12
"github.com/vylet-app/go/internal/helpers"
13
+
"google.golang.org/protobuf/types/known/timestamppb"
12
14
)
13
15
14
16
func (s *Server) handleActorProfile(ctx context.Context, evt *vyletkafka.FirehoseEvent) error {
15
17
var rec vylet.ActorProfile
16
18
op := evt.Commit
17
-
18
19
switch op.Operation {
19
20
case vyletkafka.CommitOperation_COMMIT_OPERATION_CREATE:
20
21
if err := json.Unmarshal(op.Record, &rec); err != nil {
21
22
return fmt.Errorf("failed to unmarshal profile record: %w", err)
22
23
}
23
24
25
+
createdAtTime, err := time.Parse(time.RFC3339Nano, rec.CreatedAt)
26
+
if err != nil {
27
+
return fmt.Errorf("failed to parse time in record: %w", err)
28
+
}
29
+
24
30
req := vyletdatabase.CreateProfileRequest{
25
-
Did: evt.Did,
26
-
DisplayName: rec.DisplayName,
27
-
Description: rec.Description,
28
-
Pronouns: rec.Pronouns,
29
-
CreatedAt: rec.CreatedAt,
31
+
Profile: &vyletdatabase.Profile{
32
+
Did: evt.Did,
33
+
DisplayName: rec.DisplayName,
34
+
Description: rec.Description,
35
+
Pronouns: rec.Pronouns,
36
+
CreatedAt: timestamppb.New(createdAtTime),
37
+
},
30
38
}
31
39
32
40
if rec.Avatar != nil {
33
-
req.Avatar = helpers.ToStringPtr(rec.Avatar.Ref.String())
41
+
req.Profile.Avatar = helpers.ToStringPtr(rec.Avatar.Ref.String())
34
42
}
35
43
36
44
resp, err := s.db.Profile.CreateProfile(ctx, &req)
···
41
49
return fmt.Errorf("error creating profile: %s", *resp.Error)
42
50
}
43
51
case vyletkafka.CommitOperation_COMMIT_OPERATION_UPDATE:
44
-
return fmt.Errorf("unhandled operation")
52
+
if err := json.Unmarshal(op.Record, &rec); err != nil {
53
+
return fmt.Errorf("failed to unmarshal profile record: %w", err)
54
+
}
55
+
56
+
req := vyletdatabase.CreateProfileRequest{
57
+
Profile: &vyletdatabase.Profile{
58
+
Did: evt.Did,
59
+
DisplayName: rec.DisplayName,
60
+
Description: rec.Description,
61
+
Pronouns: rec.Pronouns,
62
+
},
63
+
}
64
+
65
+
if rec.Avatar != nil {
66
+
req.Profile.Avatar = helpers.ToStringPtr(rec.Avatar.Ref.String())
67
+
}
68
+
69
+
resp, err := s.db.Profile.UpdateProfile(ctx, &req)
70
+
if err != nil {
71
+
return fmt.Errorf("failed to create update profile request: %w", err)
72
+
}
73
+
if resp.Error != nil {
74
+
return fmt.Errorf("error updating profile: %w", err)
75
+
}
45
76
case vyletkafka.CommitOperation_COMMIT_OPERATION_DELETE:
46
77
resp, err := s.db.Profile.DeleteProfile(ctx, &vyletdatabase.DeleteProfileRequest{
47
78
Did: evt.Did,
+86
indexer/feedpost.go
+86
indexer/feedpost.go
···
1
+
package indexer
2
+
3
+
import (
4
+
"context"
5
+
"encoding/json"
6
+
"fmt"
7
+
"time"
8
+
9
+
vyletkafka "github.com/vylet-app/go/bus/proto"
10
+
vyletdatabase "github.com/vylet-app/go/database/proto"
11
+
"github.com/vylet-app/go/generated/vylet"
12
+
"google.golang.org/protobuf/types/known/timestamppb"
13
+
)
14
+
15
+
func (s *Server) handleFeedPost(ctx context.Context, evt *vyletkafka.FirehoseEvent) error {
16
+
var rec vylet.FeedPost
17
+
op := evt.Commit
18
+
uri := firehoseEventToUri(evt)
19
+
switch op.Operation {
20
+
case vyletkafka.CommitOperation_COMMIT_OPERATION_CREATE:
21
+
if err := json.Unmarshal(op.Record, &rec); err != nil {
22
+
return fmt.Errorf("failed to unmarshal post record: %w", err)
23
+
}
24
+
25
+
createdAtTime, err := time.Parse(time.RFC3339Nano, rec.CreatedAt)
26
+
if err != nil {
27
+
return fmt.Errorf("failed to parse time from record: %w", err)
28
+
}
29
+
30
+
var images []*vyletdatabase.Image
31
+
if rec.Media == nil || rec.Media.MediaImages == nil || len(rec.Media.MediaImages.Images) == 0 {
32
+
return fmt.Errorf("invalid post, missing or empty images")
33
+
}
34
+
35
+
for _, img := range rec.Media.MediaImages.Images {
36
+
dbimg := &vyletdatabase.Image{
37
+
Cid: img.Image.Ref.String(),
38
+
Alt: &img.Alt,
39
+
}
40
+
if img.AspectRatio != nil {
41
+
dbimg.Width = &img.AspectRatio.Width
42
+
dbimg.Height = &img.AspectRatio.Height
43
+
}
44
+
images = append(images, dbimg)
45
+
}
46
+
47
+
req := vyletdatabase.CreatePostRequest{
48
+
Post: &vyletdatabase.Post{
49
+
Uri: uri,
50
+
Images: images,
51
+
Caption: rec.Caption,
52
+
CreatedAt: timestamppb.New(createdAtTime),
53
+
},
54
+
}
55
+
56
+
if rec.Facets != nil {
57
+
b, err := json.Marshal(rec.Facets)
58
+
if err != nil {
59
+
return fmt.Errorf("failed to marshal facets: %w", err)
60
+
}
61
+
req.Post.Facets = b
62
+
}
63
+
64
+
resp, err := s.db.Post.CreatePost(ctx, &req)
65
+
if err != nil {
66
+
return fmt.Errorf("failed to create create post request: %w", err)
67
+
}
68
+
if resp.Error != nil {
69
+
return fmt.Errorf("error creating post: %s", *resp.Error)
70
+
}
71
+
case vyletkafka.CommitOperation_COMMIT_OPERATION_UPDATE:
72
+
return fmt.Errorf("unsupported post update event")
73
+
case vyletkafka.CommitOperation_COMMIT_OPERATION_DELETE:
74
+
resp, err := s.db.Post.DeletePost(ctx, &vyletdatabase.DeletePostRequest{
75
+
Uri: uri,
76
+
})
77
+
if err != nil {
78
+
return fmt.Errorf("failed to create delete post request: %w", err)
79
+
}
80
+
if resp.Error != nil {
81
+
return fmt.Errorf("error deleting post %s", *resp.Error)
82
+
}
83
+
}
84
+
85
+
return nil
86
+
}
+11
indexer/helpers.go
+11
indexer/helpers.go