MCPcopy
hub / github.com/tinode/chat / updateAcsFromPresMsg

Method updateAcsFromPresMsg

server/topic_proxy.go:288–310  ·  view source on GitHub ↗

updateAcsFromPresMsg modifies user acs in Topic's perUser struct based on the data in `pres`.

(pres *MsgServerPres)

Source from the content-addressed store, hash-verified

286
287// updateAcsFromPresMsg modifies user acs in Topic's perUser struct based on the data in `pres`.
288func (t *Topic) updateAcsFromPresMsg(pres *MsgServerPres) {
289 uid := types.ParseUserId(pres.Src)
290 if uid.IsZero() {
291 if t.cat != types.TopicCatMe {
292 logs.Warn.Printf("proxy topic[%s]: received acs change for invalid user id '%s'", t.name, pres.Src)
293 }
294 return
295 }
296
297 // If t.perUser[uid] does not exist, pud is initialized with blanks, otherwise it gets existing values.
298 pud := t.perUser[uid]
299 dacs := pres.Acs
300 if err := pud.modeWant.ApplyMutation(dacs.Want); err != nil {
301 logs.Warn.Printf("proxy topic[%s]: could not process acs change - want: %s", t.name, err)
302 return
303 }
304 if err := pud.modeGiven.ApplyMutation(dacs.Given); err != nil {
305 logs.Warn.Printf("proxy topic[%s]: could not process acs change - given: %s", t.name, err)
306 return
307 }
308 // Update existing or add new.
309 t.perUser[uid] = pud
310}

Callers 1

proxyMasterResponseMethod · 0.95

Calls 3

ParseUserIdFunction · 0.92
ApplyMutationMethod · 0.80
IsZeroMethod · 0.45

Tested by

no test coverage detected