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

Method replySetAux

server/topic.go:3101–3126  ·  view source on GitHub ↗

replyGetAux returns topic's auxiliary set of key-value pairs.

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

Source from the content-addressed store, hash-verified

3099
3100// replyGetAux returns topic's auxiliary set of key-value pairs.
3101func (t *Topic) replySetAux(sess *Session, asUid types.Uid, msg *ClientComMessage) error {
3102 now := types.TimeNow()
3103
3104 if t.cat != types.TopicCatP2P && t.cat != types.TopicCatGrp && t.cat != types.TopicCatSlf {
3105 sess.queueOut(ErrOperationNotAllowedReply(msg, now))
3106 return errors.New("invalid topic category to assign aux")
3107 }
3108
3109 if userData := t.perUser[asUid]; !(userData.modeGiven & userData.modeWant).IsAdmin() {
3110 sess.queueOut(ErrPermissionDeniedReply(msg, now))
3111 return errors.New("aux update by non-admin")
3112 }
3113
3114 if aux, changed := mergeMaps(copyMap(t.aux), msg.Set.Aux); changed {
3115 err := store.Topics.Update(t.name, map[string]any{"Aux": aux, "UpdatedAt": now})
3116 if err == nil {
3117 t.aux = aux
3118 t.presSubsOnline("aux", "", nilPresParams, nilPresFilters, sess.sid)
3119 }
3120 sess.queueOut(decodeStoreErrorExplicitTs(err, msg.Set.Id, t.original(asUid), now, msg.Timestamp, nil))
3121 return err
3122 }
3123
3124 sess.queueOut(InfoNotModifiedReply(msg, now))
3125 return nil
3126}
3127
3128// replyGetDel is a response to a get[what=del] request: load a list of deleted message ids, send them to
3129// a session as {meta}

Callers 1

handleMetaSetMethod · 0.95

Calls 12

presSubsOnlineMethod · 0.95
originalMethod · 0.95
TimeNowFunction · 0.92
ErrPermissionDeniedReplyFunction · 0.85
mergeMapsFunction · 0.85
copyMapFunction · 0.85
InfoNotModifiedReplyFunction · 0.85
queueOutMethod · 0.80
IsAdminMethod · 0.80
UpdateMethod · 0.65

Tested by

no test coverage detected