replySetDesc updates topic metadata, saves it to DB, replies to the caller as {ctrl} message, generates {pres} update if necessary.
(sess *Session, asUid types.Uid, asChan bool, authLevel auth.Level, msg *ClientComMessage)
| 2202 | // replySetDesc updates topic metadata, saves it to DB, replies to the caller as {ctrl} message, |
| 2203 | // generates {pres} update if necessary. |
| 2204 | func (t *Topic) replySetDesc(sess *Session, asUid types.Uid, asChan bool, |
| 2205 | authLevel auth.Level, msg *ClientComMessage) error { |
| 2206 | now := types.TimeNow() |
| 2207 | |
| 2208 | assignAccess := func(upd map[string]any, mode *MsgDefaultAcsMode) error { |
| 2209 | if mode == nil { |
| 2210 | return nil |
| 2211 | } |
| 2212 | if auth, anon, err := parseTopicAccess(mode, types.ModeUnset, types.ModeUnset); err != nil { |
| 2213 | return err |
| 2214 | } else if auth.IsOwner() || anon.IsOwner() { |
| 2215 | return errors.New("default 'owner' access is not permitted") |
| 2216 | } else { |
| 2217 | access := types.DefaultAccess{Auth: t.accessAuth, Anon: t.accessAnon} |
| 2218 | if auth != types.ModeUnset { |
| 2219 | if t.cat == types.TopicCatMe { |
| 2220 | auth &= types.ModeCAuth |
| 2221 | if auth != types.ModeNone { |
| 2222 | // This is the default access mode for P2P topics. |
| 2223 | // It must be either an N or must include an A permission. |
| 2224 | auth |= types.ModeApprove |
| 2225 | } |
| 2226 | } |
| 2227 | access.Auth = auth |
| 2228 | } |
| 2229 | if anon != types.ModeUnset { |
| 2230 | if t.cat == types.TopicCatMe { |
| 2231 | anon &= globals.typesModeCP2P |
| 2232 | if anon != types.ModeNone { |
| 2233 | anon |= types.ModeApprove |
| 2234 | } |
| 2235 | } |
| 2236 | access.Anon = anon |
| 2237 | } |
| 2238 | if access.Auth != t.accessAuth || access.Anon != t.accessAnon { |
| 2239 | upd["Access"] = access |
| 2240 | } |
| 2241 | } |
| 2242 | return nil |
| 2243 | } |
| 2244 | |
| 2245 | assignGenericValues := func(upd map[string]any, what string, dst, src any) (changed bool) { |
| 2246 | if dst, changed = mergeInterfaces(dst, src); changed { |
| 2247 | upd[what] = dst |
| 2248 | } |
| 2249 | return |
| 2250 | } |
| 2251 | |
| 2252 | // DefaultAccess and/or Public have chanegd |
| 2253 | var sendCommon bool |
| 2254 | // Private has changed |
| 2255 | var sendPriv bool |
| 2256 | var err error |
| 2257 | |
| 2258 | // Change to the main object (user or topic). |
| 2259 | core := make(map[string]any) |
| 2260 | // Change to subscription. |
| 2261 | sub := make(map[string]any) |
no test coverage detected