forked from keybase/client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
home.go
548 lines (485 loc) · 15 KB
/
home.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
// Auto-generated by avdl-compiler v1.3.25 (https://github.com/keybase/node-avdl-compiler)
// Input file: avdl/keybase1/home.avdl
package keybase1
import (
"errors"
"github.com/keybase/go-framed-msgpack-rpc/rpc"
context "golang.org/x/net/context"
)
type HomeScreenItemID string
func (o HomeScreenItemID) DeepCopy() HomeScreenItemID {
return o
}
type HomeScreenItemType int
const (
HomeScreenItemType_TODO HomeScreenItemType = 1
HomeScreenItemType_PEOPLE HomeScreenItemType = 2
)
func (o HomeScreenItemType) DeepCopy() HomeScreenItemType { return o }
var HomeScreenItemTypeMap = map[string]HomeScreenItemType{
"TODO": 1,
"PEOPLE": 2,
}
var HomeScreenItemTypeRevMap = map[HomeScreenItemType]string{
1: "TODO",
2: "PEOPLE",
}
func (e HomeScreenItemType) String() string {
if v, ok := HomeScreenItemTypeRevMap[e]; ok {
return v
}
return ""
}
type HomeScreenItemData struct {
T__ HomeScreenItemType `codec:"t" json:"t"`
Todo__ *HomeScreenTodo `codec:"todo,omitempty" json:"todo,omitempty"`
People__ *HomeScreenPeopleNotification `codec:"people,omitempty" json:"people,omitempty"`
}
func (o *HomeScreenItemData) T() (ret HomeScreenItemType, err error) {
switch o.T__ {
case HomeScreenItemType_TODO:
if o.Todo__ == nil {
err = errors.New("unexpected nil value for Todo__")
return ret, err
}
case HomeScreenItemType_PEOPLE:
if o.People__ == nil {
err = errors.New("unexpected nil value for People__")
return ret, err
}
}
return o.T__, nil
}
func (o HomeScreenItemData) Todo() (res HomeScreenTodo) {
if o.T__ != HomeScreenItemType_TODO {
panic("wrong case accessed")
}
if o.Todo__ == nil {
return
}
return *o.Todo__
}
func (o HomeScreenItemData) People() (res HomeScreenPeopleNotification) {
if o.T__ != HomeScreenItemType_PEOPLE {
panic("wrong case accessed")
}
if o.People__ == nil {
return
}
return *o.People__
}
func NewHomeScreenItemDataWithTodo(v HomeScreenTodo) HomeScreenItemData {
return HomeScreenItemData{
T__: HomeScreenItemType_TODO,
Todo__: &v,
}
}
func NewHomeScreenItemDataWithPeople(v HomeScreenPeopleNotification) HomeScreenItemData {
return HomeScreenItemData{
T__: HomeScreenItemType_PEOPLE,
People__: &v,
}
}
func (o HomeScreenItemData) DeepCopy() HomeScreenItemData {
return HomeScreenItemData{
T__: o.T__.DeepCopy(),
Todo__: (func(x *HomeScreenTodo) *HomeScreenTodo {
if x == nil {
return nil
}
tmp := (*x).DeepCopy()
return &tmp
})(o.Todo__),
People__: (func(x *HomeScreenPeopleNotification) *HomeScreenPeopleNotification {
if x == nil {
return nil
}
tmp := (*x).DeepCopy()
return &tmp
})(o.People__),
}
}
type HomeScreenTodoType int
const (
HomeScreenTodoType_NONE HomeScreenTodoType = 0
HomeScreenTodoType_BIO HomeScreenTodoType = 1
HomeScreenTodoType_PROOF HomeScreenTodoType = 2
HomeScreenTodoType_DEVICE HomeScreenTodoType = 3
HomeScreenTodoType_FOLLOW HomeScreenTodoType = 4
HomeScreenTodoType_CHAT HomeScreenTodoType = 5
HomeScreenTodoType_PAPERKEY HomeScreenTodoType = 6
HomeScreenTodoType_TEAM HomeScreenTodoType = 7
HomeScreenTodoType_FOLDER HomeScreenTodoType = 8
HomeScreenTodoType_GIT_REPO HomeScreenTodoType = 9
HomeScreenTodoType_TEAM_SHOWCASE HomeScreenTodoType = 10
HomeScreenTodoType_AVATAR_USER HomeScreenTodoType = 11
HomeScreenTodoType_AVATAR_TEAM HomeScreenTodoType = 12
)
func (o HomeScreenTodoType) DeepCopy() HomeScreenTodoType { return o }
var HomeScreenTodoTypeMap = map[string]HomeScreenTodoType{
"NONE": 0,
"BIO": 1,
"PROOF": 2,
"DEVICE": 3,
"FOLLOW": 4,
"CHAT": 5,
"PAPERKEY": 6,
"TEAM": 7,
"FOLDER": 8,
"GIT_REPO": 9,
"TEAM_SHOWCASE": 10,
"AVATAR_USER": 11,
"AVATAR_TEAM": 12,
}
var HomeScreenTodoTypeRevMap = map[HomeScreenTodoType]string{
0: "NONE",
1: "BIO",
2: "PROOF",
3: "DEVICE",
4: "FOLLOW",
5: "CHAT",
6: "PAPERKEY",
7: "TEAM",
8: "FOLDER",
9: "GIT_REPO",
10: "TEAM_SHOWCASE",
11: "AVATAR_USER",
12: "AVATAR_TEAM",
}
func (e HomeScreenTodoType) String() string {
if v, ok := HomeScreenTodoTypeRevMap[e]; ok {
return v
}
return ""
}
type HomeScreenTodo struct {
T__ HomeScreenTodoType `codec:"t" json:"t"`
}
func (o *HomeScreenTodo) T() (ret HomeScreenTodoType, err error) {
switch o.T__ {
}
return o.T__, nil
}
func NewHomeScreenTodoDefault(t HomeScreenTodoType) HomeScreenTodo {
return HomeScreenTodo{
T__: t,
}
}
func (o HomeScreenTodo) DeepCopy() HomeScreenTodo {
return HomeScreenTodo{
T__: o.T__.DeepCopy(),
}
}
type HomeScreenPeopleNotificationType int
const (
HomeScreenPeopleNotificationType_FOLLOWED HomeScreenPeopleNotificationType = 1
HomeScreenPeopleNotificationType_FOLLOWED_MULTI HomeScreenPeopleNotificationType = 2
)
func (o HomeScreenPeopleNotificationType) DeepCopy() HomeScreenPeopleNotificationType { return o }
var HomeScreenPeopleNotificationTypeMap = map[string]HomeScreenPeopleNotificationType{
"FOLLOWED": 1,
"FOLLOWED_MULTI": 2,
}
var HomeScreenPeopleNotificationTypeRevMap = map[HomeScreenPeopleNotificationType]string{
1: "FOLLOWED",
2: "FOLLOWED_MULTI",
}
func (e HomeScreenPeopleNotificationType) String() string {
if v, ok := HomeScreenPeopleNotificationTypeRevMap[e]; ok {
return v
}
return ""
}
type HomeScreenPeopleNotificationFollowed struct {
FollowTime Time `codec:"followTime" json:"followTime"`
FollowedBack bool `codec:"followedBack" json:"followedBack"`
User UserSummary `codec:"user" json:"user"`
}
func (o HomeScreenPeopleNotificationFollowed) DeepCopy() HomeScreenPeopleNotificationFollowed {
return HomeScreenPeopleNotificationFollowed{
FollowTime: o.FollowTime.DeepCopy(),
FollowedBack: o.FollowedBack,
User: o.User.DeepCopy(),
}
}
type HomeScreenPeopleNotificationFollowedMulti struct {
Followers []HomeScreenPeopleNotificationFollowed `codec:"followers" json:"followers"`
NumOthers int `codec:"numOthers" json:"numOthers"`
}
func (o HomeScreenPeopleNotificationFollowedMulti) DeepCopy() HomeScreenPeopleNotificationFollowedMulti {
return HomeScreenPeopleNotificationFollowedMulti{
Followers: (func(x []HomeScreenPeopleNotificationFollowed) []HomeScreenPeopleNotificationFollowed {
if x == nil {
return nil
}
ret := make([]HomeScreenPeopleNotificationFollowed, len(x))
for i, v := range x {
vCopy := v.DeepCopy()
ret[i] = vCopy
}
return ret
})(o.Followers),
NumOthers: o.NumOthers,
}
}
type HomeScreenPeopleNotification struct {
T__ HomeScreenPeopleNotificationType `codec:"t" json:"t"`
Followed__ *HomeScreenPeopleNotificationFollowed `codec:"followed,omitempty" json:"followed,omitempty"`
FollowedMulti__ *HomeScreenPeopleNotificationFollowedMulti `codec:"followedMulti,omitempty" json:"followedMulti,omitempty"`
}
func (o *HomeScreenPeopleNotification) T() (ret HomeScreenPeopleNotificationType, err error) {
switch o.T__ {
case HomeScreenPeopleNotificationType_FOLLOWED:
if o.Followed__ == nil {
err = errors.New("unexpected nil value for Followed__")
return ret, err
}
case HomeScreenPeopleNotificationType_FOLLOWED_MULTI:
if o.FollowedMulti__ == nil {
err = errors.New("unexpected nil value for FollowedMulti__")
return ret, err
}
}
return o.T__, nil
}
func (o HomeScreenPeopleNotification) Followed() (res HomeScreenPeopleNotificationFollowed) {
if o.T__ != HomeScreenPeopleNotificationType_FOLLOWED {
panic("wrong case accessed")
}
if o.Followed__ == nil {
return
}
return *o.Followed__
}
func (o HomeScreenPeopleNotification) FollowedMulti() (res HomeScreenPeopleNotificationFollowedMulti) {
if o.T__ != HomeScreenPeopleNotificationType_FOLLOWED_MULTI {
panic("wrong case accessed")
}
if o.FollowedMulti__ == nil {
return
}
return *o.FollowedMulti__
}
func NewHomeScreenPeopleNotificationWithFollowed(v HomeScreenPeopleNotificationFollowed) HomeScreenPeopleNotification {
return HomeScreenPeopleNotification{
T__: HomeScreenPeopleNotificationType_FOLLOWED,
Followed__: &v,
}
}
func NewHomeScreenPeopleNotificationWithFollowedMulti(v HomeScreenPeopleNotificationFollowedMulti) HomeScreenPeopleNotification {
return HomeScreenPeopleNotification{
T__: HomeScreenPeopleNotificationType_FOLLOWED_MULTI,
FollowedMulti__: &v,
}
}
func (o HomeScreenPeopleNotification) DeepCopy() HomeScreenPeopleNotification {
return HomeScreenPeopleNotification{
T__: o.T__.DeepCopy(),
Followed__: (func(x *HomeScreenPeopleNotificationFollowed) *HomeScreenPeopleNotificationFollowed {
if x == nil {
return nil
}
tmp := (*x).DeepCopy()
return &tmp
})(o.Followed__),
FollowedMulti__: (func(x *HomeScreenPeopleNotificationFollowedMulti) *HomeScreenPeopleNotificationFollowedMulti {
if x == nil {
return nil
}
tmp := (*x).DeepCopy()
return &tmp
})(o.FollowedMulti__),
}
}
type HomeScreenItem struct {
Badged bool `codec:"badged" json:"badged"`
Data HomeScreenItemData `codec:"data" json:"data"`
}
func (o HomeScreenItem) DeepCopy() HomeScreenItem {
return HomeScreenItem{
Badged: o.Badged,
Data: o.Data.DeepCopy(),
}
}
type Pics struct {
Square40 string `codec:"square40" json:"square_40"`
Square200 string `codec:"square200" json:"square_200"`
Square360 string `codec:"square360" json:"square_360"`
}
func (o Pics) DeepCopy() Pics {
return Pics{
Square40: o.Square40,
Square200: o.Square200,
Square360: o.Square360,
}
}
type HomeUserSummary struct {
Uid UID `codec:"uid" json:"uid"`
Username string `codec:"username" json:"username"`
Bio string `codec:"bio" json:"bio"`
FullName string `codec:"fullName" json:"full_name"`
Pics *Pics `codec:"pics,omitempty" json:"pics,omitempty"`
}
func (o HomeUserSummary) DeepCopy() HomeUserSummary {
return HomeUserSummary{
Uid: o.Uid.DeepCopy(),
Username: o.Username,
Bio: o.Bio,
FullName: o.FullName,
Pics: (func(x *Pics) *Pics {
if x == nil {
return nil
}
tmp := (*x).DeepCopy()
return &tmp
})(o.Pics),
}
}
type HomeScreen struct {
LastViewed Time `codec:"lastViewed" json:"lastViewed"`
Version int `codec:"version" json:"version"`
Visits int `codec:"visits" json:"visits"`
Items []HomeScreenItem `codec:"items" json:"items"`
FollowSuggestions []HomeUserSummary `codec:"followSuggestions" json:"followSuggestions"`
}
func (o HomeScreen) DeepCopy() HomeScreen {
return HomeScreen{
LastViewed: o.LastViewed.DeepCopy(),
Version: o.Version,
Visits: o.Visits,
Items: (func(x []HomeScreenItem) []HomeScreenItem {
if x == nil {
return nil
}
ret := make([]HomeScreenItem, len(x))
for i, v := range x {
vCopy := v.DeepCopy()
ret[i] = vCopy
}
return ret
})(o.Items),
FollowSuggestions: (func(x []HomeUserSummary) []HomeUserSummary {
if x == nil {
return nil
}
ret := make([]HomeUserSummary, len(x))
for i, v := range x {
vCopy := v.DeepCopy()
ret[i] = vCopy
}
return ret
})(o.FollowSuggestions),
}
}
type HomeGetScreenArg struct {
MarkViewed bool `codec:"markViewed" json:"markViewed"`
NumFollowSuggestionsWanted int `codec:"numFollowSuggestionsWanted" json:"numFollowSuggestionsWanted"`
}
type HomeSkipTodoTypeArg struct {
T HomeScreenTodoType `codec:"t" json:"t"`
}
type HomeActionTakenArg struct {
}
type HomeMarkViewedArg struct {
}
type HomeInterface interface {
// HomeGetScreen returns the home screen for the current user.
// If `markViewed` is specified, the server will mark this version of the
// home screen "viewed", potentially updating some badges.
// `numFollowSuggestionsWanted` controls the number of people to return.
// If not specified, it will default to `0`, so no people. If `-1` is specified,
// the default number will be returned (10). Otherwise, the caller should
// specify.
HomeGetScreen(context.Context, HomeGetScreenArg) (HomeScreen, error)
HomeSkipTodoType(context.Context, HomeScreenTodoType) error
HomeActionTaken(context.Context) error
HomeMarkViewed(context.Context) error
}
func HomeProtocol(i HomeInterface) rpc.Protocol {
return rpc.Protocol{
Name: "keybase.1.home",
Methods: map[string]rpc.ServeHandlerDescription{
"homeGetScreen": {
MakeArg: func() interface{} {
var ret [1]HomeGetScreenArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[1]HomeGetScreenArg)
if !ok {
err = rpc.NewTypeError((*[1]HomeGetScreenArg)(nil), args)
return
}
ret, err = i.HomeGetScreen(ctx, typedArgs[0])
return
},
MethodType: rpc.MethodCall,
},
"homeSkipTodoType": {
MakeArg: func() interface{} {
var ret [1]HomeSkipTodoTypeArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[1]HomeSkipTodoTypeArg)
if !ok {
err = rpc.NewTypeError((*[1]HomeSkipTodoTypeArg)(nil), args)
return
}
err = i.HomeSkipTodoType(ctx, typedArgs[0].T)
return
},
MethodType: rpc.MethodCall,
},
"homeActionTaken": {
MakeArg: func() interface{} {
var ret [1]HomeActionTakenArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
err = i.HomeActionTaken(ctx)
return
},
MethodType: rpc.MethodCall,
},
"homeMarkViewed": {
MakeArg: func() interface{} {
var ret [1]HomeMarkViewedArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
err = i.HomeMarkViewed(ctx)
return
},
MethodType: rpc.MethodCall,
},
},
}
}
type HomeClient struct {
Cli rpc.GenericClient
}
// HomeGetScreen returns the home screen for the current user.
// If `markViewed` is specified, the server will mark this version of the
// home screen "viewed", potentially updating some badges.
// `numFollowSuggestionsWanted` controls the number of people to return.
// If not specified, it will default to `0`, so no people. If `-1` is specified,
// the default number will be returned (10). Otherwise, the caller should
// specify.
func (c HomeClient) HomeGetScreen(ctx context.Context, __arg HomeGetScreenArg) (res HomeScreen, err error) {
err = c.Cli.Call(ctx, "keybase.1.home.homeGetScreen", []interface{}{__arg}, &res)
return
}
func (c HomeClient) HomeSkipTodoType(ctx context.Context, t HomeScreenTodoType) (err error) {
__arg := HomeSkipTodoTypeArg{T: t}
err = c.Cli.Call(ctx, "keybase.1.home.homeSkipTodoType", []interface{}{__arg}, nil)
return
}
func (c HomeClient) HomeActionTaken(ctx context.Context) (err error) {
err = c.Cli.Call(ctx, "keybase.1.home.homeActionTaken", []interface{}{HomeActionTakenArg{}}, nil)
return
}
func (c HomeClient) HomeMarkViewed(ctx context.Context) (err error) {
err = c.Cli.Call(ctx, "keybase.1.home.homeMarkViewed", []interface{}{HomeMarkViewedArg{}}, nil)
return
}