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

Method getUserChatDebugLogging

coderd/exp_chats.go:5215–5251  ·  view source on GitHub ↗

EXPERIMENTAL: this endpoint is experimental and is subject to change. nolint:revive // get-return: revive assumes get* must be a getter, but this is an HTTP handler.

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

Source from the content-addressed store, hash-verified

5213//
5214//nolint:revive // get-return: revive assumes get* must be a getter, but this is an HTTP handler.
5215func (api *API) getUserChatDebugLogging(rw http.ResponseWriter, r *http.Request) {
5216 ctx := r.Context()
5217 apiKey := httpmw.APIKey(r)
5218
5219 forcedByDeployment := api.deploymentChatDebugLoggingEnabled()
5220 allowUsers := false
5221 if !forcedByDeployment {
5222 enabled, err := api.Database.GetChatDebugLoggingAllowUsers(ctx)
5223 if err != nil && !errors.Is(err, sql.ErrNoRows) {
5224 httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
5225 Message: "Internal error fetching chat debug logging setting.",
5226 Detail: err.Error(),
5227 })
5228 return
5229 }
5230 allowUsers = err == nil && enabled
5231 }
5232
5233 debugEnabled := forcedByDeployment
5234 if allowUsers {
5235 enabled, err := api.Database.GetUserChatDebugLoggingEnabled(ctx, apiKey.UserID)
5236 if err != nil && !errors.Is(err, sql.ErrNoRows) {
5237 httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
5238 Message: "Internal error fetching user chat debug logging setting.",
5239 Detail: err.Error(),
5240 })
5241 return
5242 }
5243 debugEnabled = err == nil && enabled
5244 }
5245
5246 httpapi.Write(ctx, rw, http.StatusOK, codersdk.UserChatDebugLoggingSettings{
5247 DebugLoggingEnabled: debugEnabled,
5248 UserToggleAllowed: !forcedByDeployment && allowUsers,
5249 ForcedByDeployment: forcedByDeployment,
5250 })
5251}
5252
5253// EXPERIMENTAL: this endpoint is experimental and is subject to change.
5254func (api *API) putUserChatDebugLogging(rw http.ResponseWriter, r *http.Request) {

Callers 1

userChatDebugLoggingFunction · 0.80

Calls 8

APIKeyFunction · 0.92
WriteFunction · 0.92
ContextMethod · 0.65
IsMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected