updateAcsFromPresMsg modifies user acs in Topic's perUser struct based on the data in `pres`.
(pres *MsgServerPres)
| 286 | |
| 287 | // updateAcsFromPresMsg modifies user acs in Topic's perUser struct based on the data in `pres`. |
| 288 | func (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 | } |
no test coverage detected