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

Method replyDelCred

server/topic.go:3309–3337  ·  view source on GitHub ↗

Delete credential

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

Source from the content-addressed store, hash-verified

3307
3308// Delete credential
3309func (t *Topic) replyDelCred(sess *Session, asUid types.Uid, authLvl auth.Level, msg *ClientComMessage) error {
3310 now := types.TimeNow()
3311 incomingReqTs := msg.Timestamp
3312 del := msg.Del
3313
3314 if t.cat != types.TopicCatMe {
3315 sess.queueOut(ErrPermissionDeniedReply(msg, now))
3316 return errors.New("del.cred: invalid topic category")
3317 }
3318 if del.Cred == nil || del.Cred.Method == "" {
3319 sess.queueOut(ErrMalformedReply(msg, now))
3320 return errors.New("del.cred: missing method")
3321 }
3322
3323 tags, err := deleteCred(asUid, authLvl, del.Cred)
3324 if tags != nil {
3325 // Check if anything has been actually removed.
3326 _, removed, _ := stringSliceDelta(t.tags, tags)
3327 if len(removed) > 0 {
3328 t.tags = tags
3329 t.presSubsOnline("tags", "", nilPresParams, nilPresFilters, "")
3330 }
3331 } else if err == nil {
3332 sess.queueOut(InfoNoActionReply(msg, now))
3333 return nil
3334 }
3335 sess.queueOut(decodeStoreErrorExplicitTs(err, del.Id, del.Topic, now, incomingReqTs, nil))
3336 return err
3337}
3338
3339// Delete subscription.
3340func (t *Topic) replyDelSub(sess *Session, asUid types.Uid, msg *ClientComMessage) error {

Callers 1

handleMetaDelMethod · 0.95

Calls 9

presSubsOnlineMethod · 0.95
TimeNowFunction · 0.92
ErrPermissionDeniedReplyFunction · 0.85
ErrMalformedReplyFunction · 0.85
deleteCredFunction · 0.85
stringSliceDeltaFunction · 0.85
InfoNoActionReplyFunction · 0.85
queueOutMethod · 0.80

Tested by

no test coverage detected