@Summary Get user notification preferences @ID get-user-notification-preferences @Security CoderSessionToken @Produce json @Tags Notifications @Param user path string true "User ID, name, or me" @Success 200 {array} codersdk.NotificationPreference @Router /api/v2/users/{user}/notifications/preferenc
(rw http.ResponseWriter, r *http.Request)
| 246 | // @Success 200 {array} codersdk.NotificationPreference |
| 247 | // @Router /api/v2/users/{user}/notifications/preferences [get] |
| 248 | func (api *API) userNotificationPreferences(rw http.ResponseWriter, r *http.Request) { |
| 249 | var ( |
| 250 | ctx = r.Context() |
| 251 | user = httpmw.UserParam(r) |
| 252 | logger = api.Logger.Named("notifications.preferences").With(slog.F("user_id", user.ID)) |
| 253 | ) |
| 254 | |
| 255 | prefs, err := api.Database.GetUserNotificationPreferences(ctx, user.ID) |
| 256 | if err != nil { |
| 257 | logger.Error(ctx, "failed to retrieve preferences", slog.Error(err)) |
| 258 | |
| 259 | httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{ |
| 260 | Message: "Failed to retrieve user notification preferences.", |
| 261 | Detail: err.Error(), |
| 262 | }) |
| 263 | return |
| 264 | } |
| 265 | |
| 266 | out := convertNotificationPreferences(prefs) |
| 267 | httpapi.Write(ctx, rw, http.StatusOK, out) |
| 268 | } |
| 269 | |
| 270 | // @Summary Update user notification preferences |
| 271 | // @ID update-user-notification-preferences |
nothing calls this directly
no test coverage detected