MCPcopy Index your code
hub / github.com/tinode/chat / replyGetCreds

Method replyGetCreds

server/topic.go:2999–3034  ·  view source on GitHub ↗

replyGetCreds returns user's credentials such as email and phone numbers.

(sess *Session, asUid types.Uid, msg *ClientComMessage)

Source from the content-addressed store, hash-verified

2997
2998// replyGetCreds returns user's credentials such as email and phone numbers.
2999func (t *Topic) replyGetCreds(sess *Session, asUid types.Uid, msg *ClientComMessage) error {
3000 now := types.TimeNow()
3001 id := msg.Id
3002
3003 if t.cat != types.TopicCatMe {
3004 sess.queueOut(ErrOperationNotAllowedReply(msg, now))
3005 return errors.New("invalid topic category for getting credentials")
3006 }
3007
3008 screds, err := store.Users.GetAllCreds(asUid, "", false)
3009 if err != nil {
3010 sess.queueOut(decodeStoreErrorExplicitTs(err, id, msg.Original, now, msg.Timestamp, nil))
3011 return err
3012 }
3013
3014 if len(screds) > 0 {
3015 creds := make([]*MsgCredServer, len(screds))
3016 for i, sc := range screds {
3017 creds[i] = &MsgCredServer{Method: sc.Method, Value: sc.Value, Done: sc.Done}
3018 }
3019 sess.queueOut(&ServerComMessage{
3020 Meta: &MsgServerMeta{
3021 Id: id,
3022 Topic: t.original(asUid),
3023 Timestamp: &now,
3024 Cred: creds,
3025 },
3026 })
3027 return nil
3028 }
3029
3030 // Inform the requester that there are no credentials.
3031 sess.queueOut(NoContentParamsReply(msg, now, map[string]string{"what": "creds"}))
3032
3033 return nil
3034}
3035
3036// replySetCred adds or validates user credentials such as email and phone numbers.
3037func (t *Topic) replySetCred(sess *Session, asUid types.Uid, authLevel auth.Level, msg *ClientComMessage) error {

Callers 2

handleMetaGetMethod · 0.95
handleSubscriptionMethod · 0.95

Calls 7

originalMethod · 0.95
TimeNowFunction · 0.92
NoContentParamsReplyFunction · 0.85
queueOutMethod · 0.80
GetAllCredsMethod · 0.65

Tested by

no test coverage detected