EXPERIMENTAL: this endpoint is experimental and is subject to change.
(rw http.ResponseWriter, r *http.Request)
| 3285 | |
| 3286 | // EXPERIMENTAL: this endpoint is experimental and is subject to change. |
| 3287 | func (api *API) deleteChatQueuedMessage(rw http.ResponseWriter, r *http.Request) { |
| 3288 | ctx := r.Context() |
| 3289 | chat := httpmw.ChatParam(r) |
| 3290 | chatID := chat.ID |
| 3291 | |
| 3292 | if !api.Authorize(r, policy.ActionUpdate, chat.RBACObject()) { |
| 3293 | httpapi.ResourceNotFound(rw) |
| 3294 | return |
| 3295 | } |
| 3296 | |
| 3297 | queuedMessageIDStr := chi.URLParam(r, "queuedMessage") |
| 3298 | queuedMessageID, err := strconv.ParseInt(queuedMessageIDStr, 10, 64) |
| 3299 | if err != nil { |
| 3300 | httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{ |
| 3301 | Message: "Invalid queued message ID.", |
| 3302 | Detail: err.Error(), |
| 3303 | }) |
| 3304 | return |
| 3305 | } |
| 3306 | |
| 3307 | if api.chatDaemon != nil { |
| 3308 | err = api.chatDaemon.DeleteQueued(ctx, chatID, queuedMessageID) |
| 3309 | } else { |
| 3310 | err = api.Database.DeleteChatQueuedMessage(ctx, database.DeleteChatQueuedMessageParams{ |
| 3311 | ID: queuedMessageID, |
| 3312 | ChatID: chatID, |
| 3313 | }) |
| 3314 | } |
| 3315 | if err != nil { |
| 3316 | httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{ |
| 3317 | Message: "Failed to delete queued message.", |
| 3318 | Detail: err.Error(), |
| 3319 | }) |
| 3320 | return |
| 3321 | } |
| 3322 | |
| 3323 | rw.WriteHeader(http.StatusNoContent) |
| 3324 | } |
| 3325 | |
| 3326 | // EXPERIMENTAL: this endpoint is experimental and is subject to change. |
| 3327 | func (api *API) promoteChatQueuedMessage(rw http.ResponseWriter, r *http.Request) { |
no test coverage detected