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

Method userNotificationPreferences

coderd/notifications.go:248–268  ·  view source on GitHub ↗

@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)

Source from the content-addressed store, hash-verified

246// @Success 200 {array} codersdk.NotificationPreference
247// @Router /api/v2/users/{user}/notifications/preferences [get]
248func (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

Callers

nothing calls this directly

Calls 7

UserParamFunction · 0.92
WriteFunction · 0.92
NamedMethod · 0.80
ContextMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected