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

Method userQuietHoursSchedule

enterprise/coderd/users.go:47–71  ·  view source on GitHub ↗

@Summary Get user quiet hours schedule @ID get-user-quiet-hours-schedule @Security CoderSessionToken @Produce json @Tags Enterprise @Param user path string true "User ID" format(uuid) @Success 200 {array} codersdk.UserQuietHoursScheduleResponse @Router /api/v2/users/{user}/quiet-hours [get]

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

Source from the content-addressed store, hash-verified

45// @Success 200 {array} codersdk.UserQuietHoursScheduleResponse
46// @Router /api/v2/users/{user}/quiet-hours [get]
47func (api *API) userQuietHoursSchedule(rw http.ResponseWriter, r *http.Request) {
48 var (
49 ctx = r.Context()
50 user = httpmw.UserParam(r)
51 )
52
53 opts, err := (*api.UserQuietHoursScheduleStore.Load()).Get(ctx, api.Database, user.ID)
54 if err != nil {
55 httpapi.InternalServerError(rw, err)
56 return
57 }
58 if opts.Schedule == nil {
59 httpapi.ResourceNotFound(rw)
60 return
61 }
62
63 httpapi.Write(ctx, rw, http.StatusOK, codersdk.UserQuietHoursScheduleResponse{
64 RawSchedule: opts.Schedule.String(),
65 UserSet: opts.UserSet,
66 UserCanSet: opts.UserCanSet,
67 Time: opts.Schedule.TimeParsed().Format(TimeFormatHHMM),
68 Timezone: opts.Schedule.Location().String(),
69 Next: opts.Schedule.Next(time.Now().In(opts.Schedule.Location())),
70 })
71}
72
73// @Summary Update user quiet hours schedule
74// @ID update-user-quiet-hours-schedule

Callers

nothing calls this directly

Calls 12

UserParamFunction · 0.92
InternalServerErrorFunction · 0.92
ResourceNotFoundFunction · 0.92
WriteFunction · 0.92
TimeParsedMethod · 0.80
LocationMethod · 0.80
ContextMethod · 0.65
GetMethod · 0.65
FormatMethod · 0.65
NextMethod · 0.65
LoadMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected