/
notify_badges.go
133 lines (119 loc) · 3.61 KB
/
notify_badges.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
// Auto-generated by avdl-compiler v1.3.20 (https://github.com/keybase/node-avdl-compiler)
// Input file: avdl/keybase1/notify_badges.avdl
package keybase1
import (
"github.com/keybase/go-framed-msgpack-rpc/rpc"
context "golang.org/x/net/context"
)
type ChatConversationID []byte
func (o ChatConversationID) DeepCopy() ChatConversationID {
return (func(x []byte) []byte {
if x == nil {
return nil
}
return append([]byte{}, x...)
})(o)
}
type BadgeState struct {
NewTlfs int `codec:"newTlfs" json:"newTlfs"`
RekeysNeeded int `codec:"rekeysNeeded" json:"rekeysNeeded"`
NewFollowers int `codec:"newFollowers" json:"newFollowers"`
InboxVers int `codec:"inboxVers" json:"inboxVers"`
Conversations []BadgeConversationInfo `codec:"conversations" json:"conversations"`
NewGitRepoGlobalUniqueIDs []string `codec:"newGitRepoGlobalUniqueIDs" json:"newGitRepoGlobalUniqueIDs"`
}
func (o BadgeState) DeepCopy() BadgeState {
return BadgeState{
NewTlfs: o.NewTlfs,
RekeysNeeded: o.RekeysNeeded,
NewFollowers: o.NewFollowers,
InboxVers: o.InboxVers,
Conversations: (func(x []BadgeConversationInfo) []BadgeConversationInfo {
if x == nil {
return nil
}
var ret []BadgeConversationInfo
for _, v := range x {
vCopy := v.DeepCopy()
ret = append(ret, vCopy)
}
return ret
})(o.Conversations),
NewGitRepoGlobalUniqueIDs: (func(x []string) []string {
if x == nil {
return nil
}
var ret []string
for _, v := range x {
vCopy := v
ret = append(ret, vCopy)
}
return ret
})(o.NewGitRepoGlobalUniqueIDs),
}
}
type BadgeConversationInfo struct {
ConvID ChatConversationID `codec:"convID" json:"convID"`
BadgeCounts map[DeviceType]int `codec:"badgeCounts" json:"badgeCounts"`
UnreadMessages int `codec:"unreadMessages" json:"unreadMessages"`
}
func (o BadgeConversationInfo) DeepCopy() BadgeConversationInfo {
return BadgeConversationInfo{
ConvID: o.ConvID.DeepCopy(),
BadgeCounts: (func(x map[DeviceType]int) map[DeviceType]int {
if x == nil {
return nil
}
ret := make(map[DeviceType]int)
for k, v := range x {
kCopy := k.DeepCopy()
vCopy := v
ret[kCopy] = vCopy
}
return ret
})(o.BadgeCounts),
UnreadMessages: o.UnreadMessages,
}
}
type BadgeStateArg struct {
BadgeState BadgeState `codec:"badgeState" json:"badgeState"`
}
func (o BadgeStateArg) DeepCopy() BadgeStateArg {
return BadgeStateArg{
BadgeState: o.BadgeState.DeepCopy(),
}
}
type NotifyBadgesInterface interface {
BadgeState(context.Context, BadgeState) error
}
func NotifyBadgesProtocol(i NotifyBadgesInterface) rpc.Protocol {
return rpc.Protocol{
Name: "keybase.1.NotifyBadges",
Methods: map[string]rpc.ServeHandlerDescription{
"badgeState": {
MakeArg: func() interface{} {
ret := make([]BadgeStateArg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]BadgeStateArg)
if !ok {
err = rpc.NewTypeError((*[]BadgeStateArg)(nil), args)
return
}
err = i.BadgeState(ctx, (*typedArgs)[0].BadgeState)
return
},
MethodType: rpc.MethodNotify,
},
},
}
}
type NotifyBadgesClient struct {
Cli rpc.GenericClient
}
func (c NotifyBadgesClient) BadgeState(ctx context.Context, badgeState BadgeState) (err error) {
__arg := BadgeStateArg{BadgeState: badgeState}
err = c.Cli.Notify(ctx, "keybase.1.NotifyBadges.badgeState", []interface{}{__arg})
return
}