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

Function normalizeCredentials

server/utils.go:119–136  ·  view source on GitHub ↗

Process credentials for correctness: remove duplicate and unknown methods. In case of duplicate methods only the first one satisfying valueRequired is kept. If valueRequired is true, keep only those where Value is non-empty.

(creds []MsgCredClient, valueRequired bool)

Source from the content-addressed store, hash-verified

117// In case of duplicate methods only the first one satisfying valueRequired is kept.
118// If valueRequired is true, keep only those where Value is non-empty.
119func normalizeCredentials(creds []MsgCredClient, valueRequired bool) []MsgCredClient {
120 if len(creds) == 0 {
121 return nil
122 }
123
124 index := make(map[string]*MsgCredClient)
125 for i := range creds {
126 c := &creds[i]
127 if _, ok := globals.validators[c.Method]; ok && (!valueRequired || c.Value != "") {
128 index[c.Method] = c
129 }
130 }
131 creds = make([]MsgCredClient, 0, len(index))
132 for _, c := range index {
133 creds = append(creds, *index[c.Method])
134 }
135 return creds
136}
137
138// Get a string slice with methods of credentials.
139func credentialMethods(creds []MsgCredClient) []string {

Callers 2

replyCreateUserFunction · 0.85
validatedCredsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…