replyGetDel is a response to a get[what=del] request: load a list of deleted message ids, send them to a session as {meta} response goes to a single session rather than all sessions in a topic
(sess *Session, asUid types.Uid, req *MsgGetOpts, msg *ClientComMessage)
| 3129 | // a session as {meta} |
| 3130 | // response goes to a single session rather than all sessions in a topic |
| 3131 | func (t *Topic) replyGetDel(sess *Session, asUid types.Uid, req *MsgGetOpts, msg *ClientComMessage) error { |
| 3132 | now := types.TimeNow() |
| 3133 | toriginal := t.original(asUid) |
| 3134 | |
| 3135 | id := msg.Id |
| 3136 | incomingReqTs := msg.Timestamp |
| 3137 | |
| 3138 | if req != nil && (req.IfModifiedSince != nil || req.User != "" || req.Topic != "") { |
| 3139 | sess.queueOut(ErrMalformedReply(msg, now)) |
| 3140 | return errors.New("invalid MsgGetOpts query") |
| 3141 | } |
| 3142 | |
| 3143 | // Check if the user has permission to read the topic data and the request is valid. |
| 3144 | if userData := t.perUser[asUid]; (userData.modeGiven & userData.modeWant).IsReader() { |
| 3145 | ranges, delID, err := store.Messages.GetDeleted(t.name, asUid, msgOpts2storeOpts(req)) |
| 3146 | if err != nil { |
| 3147 | sess.queueOut(ErrUnknownReply(msg, now)) |
| 3148 | return err |
| 3149 | } |
| 3150 | |
| 3151 | if len(ranges) > 0 { |
| 3152 | sess.queueOut(&ServerComMessage{ |
| 3153 | Meta: &MsgServerMeta{ |
| 3154 | Id: id, |
| 3155 | Topic: toriginal, |
| 3156 | Del: &MsgDelValues{ |
| 3157 | DelId: delID, |
| 3158 | DelSeq: rangeDeserialize(ranges), |
| 3159 | }, |
| 3160 | Timestamp: &now, |
| 3161 | }, |
| 3162 | }) |
| 3163 | return nil |
| 3164 | } |
| 3165 | } |
| 3166 | |
| 3167 | sess.queueOut(NoContentParams(id, toriginal, now, incomingReqTs, map[string]string{"what": "del"})) |
| 3168 | |
| 3169 | return nil |
| 3170 | } |
| 3171 | |
| 3172 | // replyDelMsg deletes (soft or hard) messages in response to del.msg packet. |
| 3173 | func (t *Topic) replyDelMsg(sess *Session, asUid types.Uid, asChan bool, msg *ClientComMessage) error { |
no test coverage detected