mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add server flag to disable user custom quiet hours (#11124)
This commit is contained in:
Generated
+7
@@ -11353,6 +11353,9 @@ const docTemplate = `{
|
||||
"codersdk.UserQuietHoursScheduleConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"allow_user_custom": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"default_schedule": {
|
||||
"type": "string"
|
||||
}
|
||||
@@ -11377,6 +11380,10 @@ const docTemplate = `{
|
||||
"description": "raw format from the cron expression, UTC if unspecified",
|
||||
"type": "string"
|
||||
},
|
||||
"user_can_set": {
|
||||
"description": "UserCanSet is true if the user is allowed to set their own quiet hours\nschedule. If false, the user cannot set a custom schedule and the default\nschedule will always be used.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"user_set": {
|
||||
"description": "UserSet is true if the user has set their own quiet hours schedule. If\nfalse, the user is using the default schedule.",
|
||||
"type": "boolean"
|
||||
|
||||
Generated
+7
@@ -10292,6 +10292,9 @@
|
||||
"codersdk.UserQuietHoursScheduleConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"allow_user_custom": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"default_schedule": {
|
||||
"type": "string"
|
||||
}
|
||||
@@ -10316,6 +10319,10 @@
|
||||
"description": "raw format from the cron expression, UTC if unspecified",
|
||||
"type": "string"
|
||||
},
|
||||
"user_can_set": {
|
||||
"description": "UserCanSet is true if the user is allowed to set their own quiet hours\nschedule. If false, the user cannot set a custom schedule and the default\nschedule will always be used.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"user_set": {
|
||||
"description": "UserSet is true if the user has set their own quiet hours schedule. If\nfalse, the user is using the default schedule.",
|
||||
"type": "boolean"
|
||||
|
||||
+14
-8
@@ -4,11 +4,14 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/coder/coder/v2/coderd/database"
|
||||
"github.com/coder/coder/v2/coderd/schedule/cron"
|
||||
)
|
||||
|
||||
var ErrUserCannotSetQuietHoursSchedule = xerrors.New("user cannot set custom quiet hours schedule due to deployment configuration")
|
||||
|
||||
type UserQuietHoursScheduleOptions struct {
|
||||
// Schedule is the cron schedule to use for quiet hours windows for all
|
||||
// workspaces owned by the user.
|
||||
@@ -19,7 +22,13 @@ type UserQuietHoursScheduleOptions struct {
|
||||
// entitled or disabled instance-wide, this value will be nil to denote that
|
||||
// quiet hours windows should not be used.
|
||||
Schedule *cron.Schedule
|
||||
UserSet bool
|
||||
// UserSet is true if the user has set a custom schedule, false if the
|
||||
// default schedule is being used.
|
||||
UserSet bool
|
||||
// UserCanSet is true if the user is allowed to set a custom schedule. If
|
||||
// false, the user cannot set a custom schedule and the default schedule
|
||||
// will always be used.
|
||||
UserCanSet bool
|
||||
}
|
||||
|
||||
type UserQuietHoursScheduleStore interface {
|
||||
@@ -47,15 +56,12 @@ func NewAGPLUserQuietHoursScheduleStore() UserQuietHoursScheduleStore {
|
||||
func (*agplUserQuietHoursScheduleStore) Get(_ context.Context, _ database.Store, _ uuid.UUID) (UserQuietHoursScheduleOptions, error) {
|
||||
// User quiet hours windows are not supported in AGPL.
|
||||
return UserQuietHoursScheduleOptions{
|
||||
Schedule: nil,
|
||||
UserSet: false,
|
||||
Schedule: nil,
|
||||
UserSet: false,
|
||||
UserCanSet: false,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (*agplUserQuietHoursScheduleStore) Set(_ context.Context, _ database.Store, _ uuid.UUID, _ string) (UserQuietHoursScheduleOptions, error) {
|
||||
// User quiet hours windows are not supported in AGPL.
|
||||
return UserQuietHoursScheduleOptions{
|
||||
Schedule: nil,
|
||||
UserSet: false,
|
||||
}, nil
|
||||
return UserQuietHoursScheduleOptions{}, ErrUserCannotSetQuietHoursSchedule
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user