/
notify_users.go
129 lines (116 loc) · 3.82 KB
/
notify_users.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
// Auto-generated to Go types and interfaces using avdl-compiler v1.4.10 (https://github.com/keybase/node-avdl-compiler)
// Input file: avdl/keybase1/notify_users.avdl
package keybase1
import (
"github.com/keybase/go-framed-msgpack-rpc/rpc"
context "golang.org/x/net/context"
"time"
)
type UserChangedArg struct {
Uid UID `codec:"uid" json:"uid"`
}
type WebOfTrustChangedArg struct {
Username string `codec:"username" json:"username"`
}
type PasswordChangedArg struct {
State PassphraseState `codec:"state" json:"state"`
}
type IdentifyUpdateArg struct {
OkUsernames []string `codec:"okUsernames" json:"okUsernames"`
BrokenUsernames []string `codec:"brokenUsernames" json:"brokenUsernames"`
}
type NotifyUsersInterface interface {
UserChanged(context.Context, UID) error
WebOfTrustChanged(context.Context, string) error
PasswordChanged(context.Context, PassphraseState) error
IdentifyUpdate(context.Context, IdentifyUpdateArg) error
}
func NotifyUsersProtocol(i NotifyUsersInterface) rpc.Protocol {
return rpc.Protocol{
Name: "keybase.1.NotifyUsers",
Methods: map[string]rpc.ServeHandlerDescription{
"userChanged": {
MakeArg: func() interface{} {
var ret [1]UserChangedArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[1]UserChangedArg)
if !ok {
err = rpc.NewTypeError((*[1]UserChangedArg)(nil), args)
return
}
err = i.UserChanged(ctx, typedArgs[0].Uid)
return
},
},
"webOfTrustChanged": {
MakeArg: func() interface{} {
var ret [1]WebOfTrustChangedArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[1]WebOfTrustChangedArg)
if !ok {
err = rpc.NewTypeError((*[1]WebOfTrustChangedArg)(nil), args)
return
}
err = i.WebOfTrustChanged(ctx, typedArgs[0].Username)
return
},
},
"passwordChanged": {
MakeArg: func() interface{} {
var ret [1]PasswordChangedArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[1]PasswordChangedArg)
if !ok {
err = rpc.NewTypeError((*[1]PasswordChangedArg)(nil), args)
return
}
err = i.PasswordChanged(ctx, typedArgs[0].State)
return
},
},
"identifyUpdate": {
MakeArg: func() interface{} {
var ret [1]IdentifyUpdateArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[1]IdentifyUpdateArg)
if !ok {
err = rpc.NewTypeError((*[1]IdentifyUpdateArg)(nil), args)
return
}
err = i.IdentifyUpdate(ctx, typedArgs[0])
return
},
},
},
}
}
type NotifyUsersClient struct {
Cli rpc.GenericClient
}
func (c NotifyUsersClient) UserChanged(ctx context.Context, uid UID) (err error) {
__arg := UserChangedArg{Uid: uid}
err = c.Cli.Notify(ctx, "keybase.1.NotifyUsers.userChanged", []interface{}{__arg}, 0*time.Millisecond)
return
}
func (c NotifyUsersClient) WebOfTrustChanged(ctx context.Context, username string) (err error) {
__arg := WebOfTrustChangedArg{Username: username}
err = c.Cli.Notify(ctx, "keybase.1.NotifyUsers.webOfTrustChanged", []interface{}{__arg}, 0*time.Millisecond)
return
}
func (c NotifyUsersClient) PasswordChanged(ctx context.Context, state PassphraseState) (err error) {
__arg := PasswordChangedArg{State: state}
err = c.Cli.Notify(ctx, "keybase.1.NotifyUsers.passwordChanged", []interface{}{__arg}, 0*time.Millisecond)
return
}
func (c NotifyUsersClient) IdentifyUpdate(ctx context.Context, __arg IdentifyUpdateArg) (err error) {
err = c.Cli.Notify(ctx, "keybase.1.NotifyUsers.identifyUpdate", []interface{}{__arg}, 0*time.Millisecond)
return
}