MCPcopy Index your code
hub / github.com/coder/coder / deleteChatQueuedMessage

Method deleteChatQueuedMessage

coderd/exp_chats.go:3287–3324  ·  view source on GitHub ↗

EXPERIMENTAL: this endpoint is experimental and is subject to change.

(rw http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

3285
3286// EXPERIMENTAL: this endpoint is experimental and is subject to change.
3287func (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.
3327func (api *API) promoteChatQueuedMessage(rw http.ResponseWriter, r *http.Request) {

Callers 1

deleteChatQueuedMessageFunction · 0.80

Calls 10

AuthorizeMethod · 0.95
ChatParamFunction · 0.92
ResourceNotFoundFunction · 0.92
WriteFunction · 0.92
DeleteQueuedMethod · 0.80
ContextMethod · 0.65
RBACObjectMethod · 0.65
ErrorMethod · 0.45
WriteHeaderMethod · 0.45

Tested by

no test coverage detected