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

Method notificationsSettings

coderd/notifications.go:31–53  ·  view source on GitHub ↗

@Summary Get notifications settings @ID get-notifications-settings @Security CoderSessionToken @Produce json @Tags Notifications @Success 200 {object} codersdk.NotificationsSettings @Router /api/v2/notifications/settings [get]

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

Source from the content-addressed store, hash-verified

29// @Success 200 {object} codersdk.NotificationsSettings
30// @Router /api/v2/notifications/settings [get]
31func (api *API) notificationsSettings(rw http.ResponseWriter, r *http.Request) {
32 settingsJSON, err := api.Database.GetNotificationsSettings(r.Context())
33 if err != nil {
34 httpapi.Write(r.Context(), rw, http.StatusInternalServerError, codersdk.Response{
35 Message: "Failed to fetch current notifications settings.",
36 Detail: err.Error(),
37 })
38 return
39 }
40
41 var settings codersdk.NotificationsSettings
42 if len(settingsJSON) > 0 {
43 err = json.Unmarshal([]byte(settingsJSON), &settings)
44 if err != nil {
45 httpapi.Write(r.Context(), rw, http.StatusInternalServerError, codersdk.Response{
46 Message: "Failed to unmarshal notifications settings.",
47 Detail: err.Error(),
48 })
49 return
50 }
51 }
52 httpapi.Write(r.Context(), rw, http.StatusOK, settings)
53}
54
55// @Summary Update notifications settings
56// @ID update-notifications-settings

Callers

nothing calls this directly

Calls 5

WriteFunction · 0.92
ContextMethod · 0.65
ErrorMethod · 0.45
UnmarshalMethod · 0.45

Tested by

no test coverage detected