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

Method getChatACL

coderd/exp_chats_acl.go:39–78  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

37//
38//nolint:revive // get-return: revive assumes get* must be a getter, but this is an HTTP handler.
39func (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//

Callers 2

api.test.tsFile · 0.80
chatACLFunction · 0.80

Calls 12

allowChatSharingMethod · 0.95
chatACLUsersMethod · 0.95
chatACLGroupsMethod · 0.95
ChatParamFunction · 0.92
WriteFunction · 0.92
IsNotAuthorizedErrorFunction · 0.92
ResourceNotFoundFunction · 0.92
InternalServerErrorFunction · 0.92
IsSubChatMethod · 0.80
ContextMethod · 0.65
GetChatACLByIDMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected