EXPERIMENTAL: this endpoint is experimental and is subject to change. @Summary Get chat ACLs @ID get-chat-acls @Security CoderSessionToken @Tags Chats @Produce json @Param chat path string true "Chat ID" format(uuid) @Success 200 {object} codersdk.ChatACL @Router /api/experimental/chats/{chat}/acl
(rw http.ResponseWriter, r *http.Request)
| 37 | // |
| 38 | //nolint:revive // get-return: revive assumes get* must be a getter, but this is an HTTP handler. |
| 39 | func (api *API) getChatACL(rw http.ResponseWriter, r *http.Request) { |
| 40 | ctx := r.Context() |
| 41 | chat := httpmw.ChatParam(r) |
| 42 | |
| 43 | if !api.allowChatSharing(ctx, rw) { |
| 44 | return |
| 45 | } |
| 46 | if chat.IsSubChat() { |
| 47 | resp := codersdk.Response{Message: "Chat ACLs can only be set on root chats."} |
| 48 | if chat.RootChatID.Valid { |
| 49 | resp.Detail = "Target the root chat (id: " + chat.RootChatID.UUID.String() + ") instead." |
| 50 | } |
| 51 | httpapi.Write(ctx, rw, http.StatusBadRequest, resp) |
| 52 | return |
| 53 | } |
| 54 | |
| 55 | chatACL, err := api.Database.GetChatACLByID(ctx, chat.ID) |
| 56 | if err != nil { |
| 57 | if dbauthz.IsNotAuthorizedError(err) { |
| 58 | httpapi.ResourceNotFound(rw) |
| 59 | return |
| 60 | } |
| 61 | httpapi.InternalServerError(rw, err) |
| 62 | return |
| 63 | } |
| 64 | |
| 65 | users, ok := api.chatACLUsers(ctx, rw, chat, chatACL.Users) |
| 66 | if !ok { |
| 67 | return |
| 68 | } |
| 69 | groups, ok := api.chatACLGroups(ctx, rw, chat, chatACL.Groups) |
| 70 | if !ok { |
| 71 | return |
| 72 | } |
| 73 | |
| 74 | httpapi.Write(ctx, rw, http.StatusOK, codersdk.ChatACL{ |
| 75 | Users: users, |
| 76 | Groups: groups, |
| 77 | }) |
| 78 | } |
| 79 | |
| 80 | // EXPERIMENTAL: this endpoint is experimental and is subject to change. |
| 81 | // |
no test coverage detected