feat: provide default user settings for new users via config
This commit is contained in:
parent
0694314e52
commit
5a40100ac5
4 changed files with 185 additions and 1 deletions
|
@ -324,3 +324,28 @@ metrics:
|
|||
username:
|
||||
# If set to a non-empty value the /metrics endpoint will require this as a password via basic auth in combination with the username below.
|
||||
password:
|
||||
|
||||
# Provide default settings for new users. When a new user is created, these settings will automatically be set for the user. If you change them in the config file afterwards they will not be changed back for existing users.
|
||||
defaultsettings:
|
||||
# The avatar source for the user. Can be `gravatar`, `initials`, `upload` or `marble`. If you set this to `upload` you'll also need to specify `defaultsettings.avatar_file_id`.
|
||||
avatar_provider: initials
|
||||
# The id of the file used as avatar.
|
||||
avatar_file_id: 0
|
||||
# If set to true users will get task reminders via email.
|
||||
email_reminders_enabled: false
|
||||
# If set to true will allow other users to find this user when searching for parts of their name.
|
||||
discoverable_by_name: false
|
||||
# If set to true will allow other users to find this user when searching for their exact email.
|
||||
discoverable_by_email: false
|
||||
# If set to true will send an email every day with all overdue tasks at a configured time.
|
||||
overdue_tasks_reminders_enabled: true
|
||||
# When to send the overdue task reminder email.
|
||||
overdue_tasks_reminders_time: 9:00
|
||||
# The id of the default list. Make sure users actually have access to this list when setting this value.
|
||||
default_list_id: 0
|
||||
# Start of the week for the user. `0` is sunday, `1` is monday and so on.
|
||||
week_start: 0
|
||||
# The language of the user interface. Must be an ISO 639-1 language code. Will default to the browser language the user uses when signing up.
|
||||
language: <unset>
|
||||
# The time zone of each individual user. This will affect when users get reminders and overdue task emails.
|
||||
timezone: <time zone set at service.timezone>
|
||||
|
|
|
@ -1174,3 +1174,132 @@ Full path: `metrics.password`
|
|||
Environment path: `VIKUNJA_METRICS_PASSWORD`
|
||||
|
||||
|
||||
---
|
||||
|
||||
## defaultsettings
|
||||
|
||||
Provide default settings for new users. When a new user is created, these settings will automatically be set for the user. If you change them in the config file afterwards they will not be changed back for existing users.
|
||||
|
||||
|
||||
|
||||
### avatar_provider
|
||||
|
||||
The avatar source for the user. Can be `gravatar`, `initials`, `upload` or `marble`. If you set this to `upload` you'll also need to specify `defaultsettings.avatar_file_id`.
|
||||
|
||||
Default: `initials`
|
||||
|
||||
Full path: `defaultsettings.avatar_provider`
|
||||
|
||||
Environment path: `VIKUNJA_DEFAULTSETTINGS_AVATAR_PROVIDER`
|
||||
|
||||
|
||||
### avatar_file_id
|
||||
|
||||
The id of the file used as avatar.
|
||||
|
||||
Default: `0`
|
||||
|
||||
Full path: `defaultsettings.avatar_file_id`
|
||||
|
||||
Environment path: `VIKUNJA_DEFAULTSETTINGS_AVATAR_FILE_ID`
|
||||
|
||||
|
||||
### email_reminders_enabled
|
||||
|
||||
If set to true users will get task reminders via email.
|
||||
|
||||
Default: `false`
|
||||
|
||||
Full path: `defaultsettings.email_reminders_enabled`
|
||||
|
||||
Environment path: `VIKUNJA_DEFAULTSETTINGS_EMAIL_REMINDERS_ENABLED`
|
||||
|
||||
|
||||
### discoverable_by_name
|
||||
|
||||
If set to true will allow other users to find this user when searching for parts of their name.
|
||||
|
||||
Default: `false`
|
||||
|
||||
Full path: `defaultsettings.discoverable_by_name`
|
||||
|
||||
Environment path: `VIKUNJA_DEFAULTSETTINGS_DISCOVERABLE_BY_NAME`
|
||||
|
||||
|
||||
### discoverable_by_email
|
||||
|
||||
If set to true will allow other users to find this user when searching for their exact email.
|
||||
|
||||
Default: `false`
|
||||
|
||||
Full path: `defaultsettings.discoverable_by_email`
|
||||
|
||||
Environment path: `VIKUNJA_DEFAULTSETTINGS_DISCOVERABLE_BY_EMAIL`
|
||||
|
||||
|
||||
### overdue_tasks_reminders_enabled
|
||||
|
||||
If set to true will send an email every day with all overdue tasks at a configured time.
|
||||
|
||||
Default: `true`
|
||||
|
||||
Full path: `defaultsettings.overdue_tasks_reminders_enabled`
|
||||
|
||||
Environment path: `VIKUNJA_DEFAULTSETTINGS_OVERDUE_TASKS_REMINDERS_ENABLED`
|
||||
|
||||
|
||||
### overdue_tasks_reminders_time
|
||||
|
||||
When to send the overdue task reminder email.
|
||||
|
||||
Default: `9:00`
|
||||
|
||||
Full path: `defaultsettings.overdue_tasks_reminders_time`
|
||||
|
||||
Environment path: `VIKUNJA_DEFAULTSETTINGS_OVERDUE_TASKS_REMINDERS_TIME`
|
||||
|
||||
|
||||
### default_list_id
|
||||
|
||||
The id of the default list. Make sure users actually have access to this list when setting this value.
|
||||
|
||||
Default: `0`
|
||||
|
||||
Full path: `defaultsettings.default_list_id`
|
||||
|
||||
Environment path: `VIKUNJA_DEFAULTSETTINGS_DEFAULT_LIST_ID`
|
||||
|
||||
|
||||
### week_start
|
||||
|
||||
Start of the week for the user. `0` is sunday, `1` is monday and so on.
|
||||
|
||||
Default: `0`
|
||||
|
||||
Full path: `defaultsettings.week_start`
|
||||
|
||||
Environment path: `VIKUNJA_DEFAULTSETTINGS_WEEK_START`
|
||||
|
||||
|
||||
### language
|
||||
|
||||
The language of the user interface. Must be an ISO 639-1 language code. Will default to the browser language the user uses when signing up.
|
||||
|
||||
Default: `<unset>`
|
||||
|
||||
Full path: `defaultsettings.language`
|
||||
|
||||
Environment path: `VIKUNJA_DEFAULTSETTINGS_LANGUAGE`
|
||||
|
||||
|
||||
### timezone
|
||||
|
||||
The time zone of each individual user. This will affect when users get reminders and overdue task emails.
|
||||
|
||||
Default: `<time zone set at service.timezone>`
|
||||
|
||||
Full path: `defaultsettings.timezone`
|
||||
|
||||
Environment path: `VIKUNJA_DEFAULTSETTINGS_TIMEZONE`
|
||||
|
||||
|
||||
|
|
|
@ -161,6 +161,18 @@ const (
|
|||
MetricsEnabled Key = `metrics.enabled`
|
||||
MetricsUsername Key = `metrics.username`
|
||||
MetricsPassword Key = `metrics.password`
|
||||
|
||||
DefaultSettingsAvatarProvider Key = `defaultsettings.avatar_provider`
|
||||
DefaultSettingsAvatarFileID Key = `defaultsettings.avatar_file_id`
|
||||
DefaultSettingsEmailRemindersEnabled Key = `defaultsettings.email_reminders_enabled`
|
||||
DefaultSettingsDiscoverableByName Key = `defaultsettings.discoverable_by_name`
|
||||
DefaultSettingsDiscoverableByEmail Key = `defaultsettings.discoverable_by_email`
|
||||
DefaultSettingsOverdueTaskRemindersEnabled Key = `defaultsettings.overdue_tasks_reminders_enabled`
|
||||
DefaultSettingsDefaultListID Key = `defaultsettings.default_list_id`
|
||||
DefaultSettingsWeekStart Key = `defaultsettings.week_start`
|
||||
DefaultSettingsLanguage Key = `defaultsettings.language`
|
||||
DefaultSettingsTimezone Key = `defaultsettings.timezone`
|
||||
DefaultSettingsOverdueTaskRemindersTime Key = `defaultsettings.overdue_tasks_reminders_time`
|
||||
)
|
||||
|
||||
// GetString returns a string config value
|
||||
|
@ -371,6 +383,10 @@ func InitDefaultConfig() {
|
|||
KeyvalueType.setDefault("memory")
|
||||
// Metrics
|
||||
MetricsEnabled.setDefault(false)
|
||||
// Settings
|
||||
DefaultSettingsAvatarProvider.setDefault("initials")
|
||||
DefaultSettingsOverdueTaskRemindersEnabled.setDefault(true)
|
||||
DefaultSettingsOverdueTaskRemindersTime.setDefault("9:00")
|
||||
}
|
||||
|
||||
// InitConfig initializes the config, sets defaults etc.
|
||||
|
@ -438,6 +454,10 @@ func InitConfig() {
|
|||
MigrationMicrosoftTodoRedirectURL.Set(ServiceFrontendurl.GetString() + "migrate/microsoft-todo")
|
||||
}
|
||||
|
||||
if DefaultSettingsTimezone.GetString() == "" {
|
||||
DefaultSettingsTimezone.Set(ServiceTimeZone.GetString())
|
||||
}
|
||||
|
||||
if ServiceEnableMetrics.GetBool() {
|
||||
log.Println("WARNING: service.enablemetrics is deprecated and will be removed in a future release. Please use metrics.enable.")
|
||||
MetricsEnabled.Set(true)
|
||||
|
|
|
@ -54,7 +54,17 @@ func CreateUser(s *xorm.Session, user *User) (newUser *User, err error) {
|
|||
}
|
||||
|
||||
user.Status = StatusActive
|
||||
user.AvatarProvider = "initials"
|
||||
user.AvatarProvider = config.DefaultSettingsAvatarProvider.GetString()
|
||||
user.AvatarFileID = config.DefaultSettingsAvatarFileID.GetInt64()
|
||||
user.EmailRemindersEnabled = config.DefaultSettingsEmailRemindersEnabled.GetBool()
|
||||
user.DiscoverableByName = config.DefaultSettingsDiscoverableByName.GetBool()
|
||||
user.DiscoverableByEmail = config.DefaultSettingsDiscoverableByEmail.GetBool()
|
||||
user.OverdueTasksRemindersEnabled = config.DefaultSettingsOverdueTaskRemindersEnabled.GetBool()
|
||||
user.OverdueTasksRemindersTime = config.DefaultSettingsOverdueTaskRemindersTime.GetString()
|
||||
user.DefaultListID = config.DefaultSettingsDefaultListID.GetInt64()
|
||||
user.WeekStart = config.DefaultSettingsWeekStart.GetInt()
|
||||
user.Language = config.DefaultSettingsLanguage.GetString()
|
||||
user.Timezone = config.DefaultSettingsTimezone.GetString()
|
||||
|
||||
// Insert it
|
||||
_, err = s.Insert(user)
|
||||
|
|
Loading…
Reference in a new issue