@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)
| 29 | // @Success 200 {object} codersdk.NotificationsSettings |
| 30 | // @Router /api/v2/notifications/settings [get] |
| 31 | func (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 |
nothing calls this directly
no test coverage detected