github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/protocol/keybase1/notify_users.go (about)

     1  // Auto-generated to Go types and interfaces using avdl-compiler v1.4.10 (https://github.com/keybase/node-avdl-compiler)
     2  //   Input file: avdl/keybase1/notify_users.avdl
     3  
     4  package keybase1
     5  
     6  import (
     7  	"github.com/keybase/go-framed-msgpack-rpc/rpc"
     8  	context "golang.org/x/net/context"
     9  	"time"
    10  )
    11  
    12  type UserChangedArg struct {
    13  	Uid UID `codec:"uid" json:"uid"`
    14  }
    15  
    16  type WebOfTrustChangedArg struct {
    17  	Username string `codec:"username" json:"username"`
    18  }
    19  
    20  type PasswordChangedArg struct {
    21  	State PassphraseState `codec:"state" json:"state"`
    22  }
    23  
    24  type IdentifyUpdateArg struct {
    25  	OkUsernames     []string `codec:"okUsernames" json:"okUsernames"`
    26  	BrokenUsernames []string `codec:"brokenUsernames" json:"brokenUsernames"`
    27  }
    28  
    29  type NotifyUsersInterface interface {
    30  	UserChanged(context.Context, UID) error
    31  	WebOfTrustChanged(context.Context, string) error
    32  	PasswordChanged(context.Context, PassphraseState) error
    33  	IdentifyUpdate(context.Context, IdentifyUpdateArg) error
    34  }
    35  
    36  func NotifyUsersProtocol(i NotifyUsersInterface) rpc.Protocol {
    37  	return rpc.Protocol{
    38  		Name: "keybase.1.NotifyUsers",
    39  		Methods: map[string]rpc.ServeHandlerDescription{
    40  			"userChanged": {
    41  				MakeArg: func() interface{} {
    42  					var ret [1]UserChangedArg
    43  					return &ret
    44  				},
    45  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
    46  					typedArgs, ok := args.(*[1]UserChangedArg)
    47  					if !ok {
    48  						err = rpc.NewTypeError((*[1]UserChangedArg)(nil), args)
    49  						return
    50  					}
    51  					err = i.UserChanged(ctx, typedArgs[0].Uid)
    52  					return
    53  				},
    54  			},
    55  			"webOfTrustChanged": {
    56  				MakeArg: func() interface{} {
    57  					var ret [1]WebOfTrustChangedArg
    58  					return &ret
    59  				},
    60  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
    61  					typedArgs, ok := args.(*[1]WebOfTrustChangedArg)
    62  					if !ok {
    63  						err = rpc.NewTypeError((*[1]WebOfTrustChangedArg)(nil), args)
    64  						return
    65  					}
    66  					err = i.WebOfTrustChanged(ctx, typedArgs[0].Username)
    67  					return
    68  				},
    69  			},
    70  			"passwordChanged": {
    71  				MakeArg: func() interface{} {
    72  					var ret [1]PasswordChangedArg
    73  					return &ret
    74  				},
    75  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
    76  					typedArgs, ok := args.(*[1]PasswordChangedArg)
    77  					if !ok {
    78  						err = rpc.NewTypeError((*[1]PasswordChangedArg)(nil), args)
    79  						return
    80  					}
    81  					err = i.PasswordChanged(ctx, typedArgs[0].State)
    82  					return
    83  				},
    84  			},
    85  			"identifyUpdate": {
    86  				MakeArg: func() interface{} {
    87  					var ret [1]IdentifyUpdateArg
    88  					return &ret
    89  				},
    90  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
    91  					typedArgs, ok := args.(*[1]IdentifyUpdateArg)
    92  					if !ok {
    93  						err = rpc.NewTypeError((*[1]IdentifyUpdateArg)(nil), args)
    94  						return
    95  					}
    96  					err = i.IdentifyUpdate(ctx, typedArgs[0])
    97  					return
    98  				},
    99  			},
   100  		},
   101  	}
   102  }
   103  
   104  type NotifyUsersClient struct {
   105  	Cli rpc.GenericClient
   106  }
   107  
   108  func (c NotifyUsersClient) UserChanged(ctx context.Context, uid UID) (err error) {
   109  	__arg := UserChangedArg{Uid: uid}
   110  	err = c.Cli.Notify(ctx, "keybase.1.NotifyUsers.userChanged", []interface{}{__arg}, 0*time.Millisecond)
   111  	return
   112  }
   113  
   114  func (c NotifyUsersClient) WebOfTrustChanged(ctx context.Context, username string) (err error) {
   115  	__arg := WebOfTrustChangedArg{Username: username}
   116  	err = c.Cli.Notify(ctx, "keybase.1.NotifyUsers.webOfTrustChanged", []interface{}{__arg}, 0*time.Millisecond)
   117  	return
   118  }
   119  
   120  func (c NotifyUsersClient) PasswordChanged(ctx context.Context, state PassphraseState) (err error) {
   121  	__arg := PasswordChangedArg{State: state}
   122  	err = c.Cli.Notify(ctx, "keybase.1.NotifyUsers.passwordChanged", []interface{}{__arg}, 0*time.Millisecond)
   123  	return
   124  }
   125  
   126  func (c NotifyUsersClient) IdentifyUpdate(ctx context.Context, __arg IdentifyUpdateArg) (err error) {
   127  	err = c.Cli.Notify(ctx, "keybase.1.NotifyUsers.identifyUpdate", []interface{}{__arg}, 0*time.Millisecond)
   128  	return
   129  }