Commit 78a97741 authored by Chris's avatar Chris Committed by GitHub

add model.NewX funcs for builtin types (#7692)

* add model.NewX funcs for builtin types

* whoops, forgot to add the new file
parent 08b7b1c4
......@@ -307,8 +307,7 @@ func testCreatePostWithOutgoingHook(
}
resp := &model.OutgoingWebhookResponse{}
resp.Text = new(string)
*resp.Text = "some test text"
resp.Text = model.NewString("some test text")
resp.Username = "testusername"
resp.IconURL = "http://www.mattermost.org/wp-content/uploads/2016/04/icon.png"
resp.Props = map[string]interface{}{"someprop": "somevalue"}
......
......@@ -400,8 +400,7 @@ func saveIsPinnedPost(c *Context, w http.ResponseWriter, r *http.Request, isPinn
}
patch := &model.PostPatch{}
patch.IsPinned = new(bool)
*patch.IsPinned = isPinned
patch.IsPinned = model.NewBool(isPinned)
_, err := c.App.PatchPost(c.Params.PostId, patch)
if err != nil {
......
......@@ -561,16 +561,13 @@ func TestPatchPost(t *testing.T) {
patch := &model.PostPatch{}
patch.IsPinned = new(bool)
*patch.IsPinned = false
patch.Message = new(string)
*patch.Message = "#otherhashtag other message"
patch.IsPinned = model.NewBool(false)
patch.Message = model.NewString("#otherhashtag other message")
patch.Props = new(model.StringInterface)
*patch.Props = model.StringInterface{"channel_header": "new_header"}
patch.FileIds = new(model.StringArray)
*patch.FileIds = model.StringArray{"file1", "otherfile2", "otherfile3"}
patch.HasReactions = new(bool)
*patch.HasReactions = false
patch.HasReactions = model.NewBool(false)
rpost, resp := Client.PatchPost(post.Id, patch)
CheckNoError(t, resp)
......
......@@ -398,16 +398,11 @@ func TestPatchTeam(t *testing.T) {
patch := &model.TeamPatch{}
patch.DisplayName = new(string)
*patch.DisplayName = "Other name"
patch.Description = new(string)
*patch.Description = "Other description"
patch.CompanyName = new(string)
*patch.CompanyName = "Other company name"
patch.InviteId = new(string)
*patch.InviteId = "inviteid1"
patch.AllowOpenInvite = new(bool)
*patch.AllowOpenInvite = true
patch.DisplayName = model.NewString("Other name")
patch.Description = model.NewString("Other description")
patch.CompanyName = model.NewString("Other company name")
patch.InviteId = model.NewString("inviteid1")
patch.AllowOpenInvite = model.NewBool(true)
rteam, resp := Client.PatchTeam(team.Id, patch)
CheckNoError(t, resp)
......
......@@ -990,12 +990,9 @@ func TestPatchUser(t *testing.T) {
patch := &model.UserPatch{}
patch.Nickname = new(string)
*patch.Nickname = "Joram Wilander"
patch.FirstName = new(string)
*patch.FirstName = "Joram"
patch.LastName = new(string)
*patch.LastName = "Wilander"
patch.Nickname = model.NewString("Joram Wilander")
patch.FirstName = model.NewString("Joram")
patch.LastName = model.NewString("Wilander")
patch.Position = new(string)
patch.NotifyProps = model.StringMap{}
patch.NotifyProps["comment"] = "somethingrandom"
......@@ -1023,8 +1020,7 @@ func TestPatchUser(t *testing.T) {
t.Fatal("NotifyProps did not update properly")
}
patch.Username = new(string)
*patch.Username = th.BasicUser2.Username
patch.Username = model.NewString(th.BasicUser2.Username)
_, resp = Client.PatchUser(user.Id, patch)
CheckBadRequestStatus(t, resp)
......@@ -1051,8 +1047,7 @@ func TestPatchUser(t *testing.T) {
session.IsOAuth = true
app.AddSessionToCache(session)
patch.Email = new(string)
*patch.Email = GenerateTestEmail()
patch.Email = model.NewString(GenerateTestEmail())
_, resp = Client.PatchUser(user.Id, patch)
CheckForbiddenStatus(t, resp)
......
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package model
func NewBool(b bool) *bool { return &b }
func NewInt(n int) *int { return &n }
func NewInt64(n int64) *int64 { return &n }
func NewString(s string) *string { return &s }
......@@ -589,13 +589,11 @@ func ConfigFromJson(data io.Reader) *Config {
func (o *Config) SetDefaults() {
if o.SqlSettings.DriverName == nil {
o.SqlSettings.DriverName = new(string)
*o.SqlSettings.DriverName = DATABASE_DRIVER_MYSQL
o.SqlSettings.DriverName = NewString(DATABASE_DRIVER_MYSQL)
}
if o.SqlSettings.DataSource == nil {
o.SqlSettings.DataSource = new(string)
*o.SqlSettings.DataSource = SQL_SETTINGS_DEFAULT_DATA_SOURCE
o.SqlSettings.DataSource = NewString(SQL_SETTINGS_DEFAULT_DATA_SOURCE)
}
if len(o.SqlSettings.AtRestEncryptKey) == 0 {
......@@ -603,23 +601,19 @@ func (o *Config) SetDefaults() {
}
if o.SqlSettings.MaxIdleConns == nil {
o.SqlSettings.MaxIdleConns = new(int)
*o.SqlSettings.MaxIdleConns = 20
o.SqlSettings.MaxIdleConns = NewInt(20)
}
if o.SqlSettings.MaxOpenConns == nil {
o.SqlSettings.MaxOpenConns = new(int)
*o.SqlSettings.MaxOpenConns = 300
o.SqlSettings.MaxOpenConns = NewInt(300)
}
if o.SqlSettings.QueryTimeout == nil {
o.SqlSettings.QueryTimeout = new(int)
*o.SqlSettings.QueryTimeout = 30
o.SqlSettings.QueryTimeout = NewInt(30)
}
if o.FileSettings.DriverName == nil {
o.FileSettings.DriverName = new(string)
*o.FileSettings.DriverName = IMAGE_DRIVER_LOCAL
o.FileSettings.DriverName = NewString(IMAGE_DRIVER_LOCAL)
}
if o.FileSettings.AmazonS3Endpoint == "" {
......@@ -628,8 +622,7 @@ func (o *Config) SetDefaults() {
}
if o.FileSettings.AmazonS3SSL == nil {
o.FileSettings.AmazonS3SSL = new(bool)
*o.FileSettings.AmazonS3SSL = true // Secure by default.
o.FileSettings.AmazonS3SSL = NewBool(true) // Secure by default.
}
if o.FileSettings.AmazonS3SignV2 == nil {
......@@ -638,38 +631,31 @@ func (o *Config) SetDefaults() {
}
if o.FileSettings.AmazonS3SSE == nil {
o.FileSettings.AmazonS3SSE = new(bool)
*o.FileSettings.AmazonS3SSE = false // Not Encrypted by default.
o.FileSettings.AmazonS3SSE = NewBool(false) // Not Encrypted by default.
}
if o.FileSettings.AmazonS3Trace == nil {
o.FileSettings.AmazonS3Trace = new(bool)
*o.FileSettings.AmazonS3Trace = false
o.FileSettings.AmazonS3Trace = NewBool(false)
}
if o.FileSettings.EnableFileAttachments == nil {
o.FileSettings.EnableFileAttachments = new(bool)
*o.FileSettings.EnableFileAttachments = true
o.FileSettings.EnableFileAttachments = NewBool(true)
}
if o.FileSettings.EnableMobileUpload == nil {
o.FileSettings.EnableMobileUpload = new(bool)
*o.FileSettings.EnableMobileUpload = true
o.FileSettings.EnableMobileUpload = NewBool(true)
}
if o.FileSettings.EnableMobileDownload == nil {
o.FileSettings.EnableMobileDownload = new(bool)
*o.FileSettings.EnableMobileDownload = true
o.FileSettings.EnableMobileDownload = NewBool(true)
}
if o.FileSettings.MaxFileSize == nil {
o.FileSettings.MaxFileSize = new(int64)
*o.FileSettings.MaxFileSize = 52428800 // 50 MB
o.FileSettings.MaxFileSize = NewInt64(52428800) // 50 MB
}
if o.FileSettings.PublicLinkSalt == nil || len(*o.FileSettings.PublicLinkSalt) == 0 {
o.FileSettings.PublicLinkSalt = new(string)
*o.FileSettings.PublicLinkSalt = NewRandomString(32)
o.FileSettings.PublicLinkSalt = NewString(NewRandomString(32))
}
if o.FileSettings.InitialFont == "" {
......@@ -686,43 +672,35 @@ func (o *Config) SetDefaults() {
}
if o.ServiceSettings.SiteURL == nil {
o.ServiceSettings.SiteURL = new(string)
*o.ServiceSettings.SiteURL = SERVICE_SETTINGS_DEFAULT_SITE_URL
o.ServiceSettings.SiteURL = NewString(SERVICE_SETTINGS_DEFAULT_SITE_URL)
}
if o.ServiceSettings.LicenseFileLocation == nil {
o.ServiceSettings.LicenseFileLocation = new(string)
*o.ServiceSettings.LicenseFileLocation = ""
o.ServiceSettings.LicenseFileLocation = NewString("")
}
if o.ServiceSettings.ListenAddress == nil {
o.ServiceSettings.ListenAddress = new(string)
*o.ServiceSettings.ListenAddress = SERVICE_SETTINGS_DEFAULT_LISTEN_AND_ADDRESS
o.ServiceSettings.ListenAddress = NewString(SERVICE_SETTINGS_DEFAULT_LISTEN_AND_ADDRESS)
}
if o.ServiceSettings.EnableAPIv3 == nil {
o.ServiceSettings.EnableAPIv3 = new(bool)
*o.ServiceSettings.EnableAPIv3 = true
o.ServiceSettings.EnableAPIv3 = NewBool(true)
}
if o.ServiceSettings.EnableLinkPreviews == nil {
o.ServiceSettings.EnableLinkPreviews = new(bool)
*o.ServiceSettings.EnableLinkPreviews = false
o.ServiceSettings.EnableLinkPreviews = NewBool(false)
}
if o.ServiceSettings.EnableDeveloper == nil {
o.ServiceSettings.EnableDeveloper = new(bool)
*o.ServiceSettings.EnableDeveloper = false
o.ServiceSettings.EnableDeveloper = NewBool(false)
}
if o.ServiceSettings.EnableSecurityFixAlert == nil {
o.ServiceSettings.EnableSecurityFixAlert = new(bool)
*o.ServiceSettings.EnableSecurityFixAlert = true
o.ServiceSettings.EnableSecurityFixAlert = NewBool(true)
}
if o.ServiceSettings.EnableInsecureOutgoingConnections == nil {
o.ServiceSettings.EnableInsecureOutgoingConnections = new(bool)
*o.ServiceSettings.EnableInsecureOutgoingConnections = false
o.ServiceSettings.EnableInsecureOutgoingConnections = NewBool(false)
}
if o.ServiceSettings.AllowedUntrustedInternalConnections == nil {
......@@ -730,88 +708,71 @@ func (o *Config) SetDefaults() {
}
if o.ServiceSettings.EnableMultifactorAuthentication == nil {
o.ServiceSettings.EnableMultifactorAuthentication = new(bool)
*o.ServiceSettings.EnableMultifactorAuthentication = false
o.ServiceSettings.EnableMultifactorAuthentication = NewBool(false)
}
if o.ServiceSettings.EnforceMultifactorAuthentication == nil {
o.ServiceSettings.EnforceMultifactorAuthentication = new(bool)
*o.ServiceSettings.EnforceMultifactorAuthentication = false
o.ServiceSettings.EnforceMultifactorAuthentication = NewBool(false)
}
if o.ServiceSettings.EnableUserAccessTokens == nil {
o.ServiceSettings.EnableUserAccessTokens = new(bool)
*o.ServiceSettings.EnableUserAccessTokens = false
o.ServiceSettings.EnableUserAccessTokens = NewBool(false)
}
if o.PasswordSettings.MinimumLength == nil {
o.PasswordSettings.MinimumLength = new(int)
*o.PasswordSettings.MinimumLength = PASSWORD_MINIMUM_LENGTH
o.PasswordSettings.MinimumLength = NewInt(PASSWORD_MINIMUM_LENGTH)
}
if o.PasswordSettings.Lowercase == nil {
o.PasswordSettings.Lowercase = new(bool)
*o.PasswordSettings.Lowercase = false
o.PasswordSettings.Lowercase = NewBool(false)
}
if o.PasswordSettings.Number == nil {
o.PasswordSettings.Number = new(bool)
*o.PasswordSettings.Number = false
o.PasswordSettings.Number = NewBool(false)
}
if o.PasswordSettings.Uppercase == nil {
o.PasswordSettings.Uppercase = new(bool)
*o.PasswordSettings.Uppercase = false
o.PasswordSettings.Uppercase = NewBool(false)
}
if o.PasswordSettings.Symbol == nil {
o.PasswordSettings.Symbol = new(bool)
*o.PasswordSettings.Symbol = false
o.PasswordSettings.Symbol = NewBool(false)
}
if o.TeamSettings.MaxUsersPerTeam == nil {
o.TeamSettings.MaxUsersPerTeam = new(int)
*o.TeamSettings.MaxUsersPerTeam = TEAM_SETTINGS_DEFAULT_MAX_USERS_PER_TEAM
o.TeamSettings.MaxUsersPerTeam = NewInt(TEAM_SETTINGS_DEFAULT_MAX_USERS_PER_TEAM)
}
if o.TeamSettings.EnableCustomBrand == nil {
o.TeamSettings.EnableCustomBrand = new(bool)
*o.TeamSettings.EnableCustomBrand = false
o.TeamSettings.EnableCustomBrand = NewBool(false)
}
if o.TeamSettings.CustomBrandText == nil {
o.TeamSettings.CustomBrandText = new(string)
*o.TeamSettings.CustomBrandText = TEAM_SETTINGS_DEFAULT_CUSTOM_BRAND_TEXT
o.TeamSettings.CustomBrandText = NewString(TEAM_SETTINGS_DEFAULT_CUSTOM_BRAND_TEXT)
}
if o.TeamSettings.CustomDescriptionText == nil {
o.TeamSettings.CustomDescriptionText = new(string)
*o.TeamSettings.CustomDescriptionText = TEAM_SETTINGS_DEFAULT_CUSTOM_DESCRIPTION_TEXT
o.TeamSettings.CustomDescriptionText = NewString(TEAM_SETTINGS_DEFAULT_CUSTOM_DESCRIPTION_TEXT)
}
if o.TeamSettings.EnableOpenServer == nil {
o.TeamSettings.EnableOpenServer = new(bool)
*o.TeamSettings.EnableOpenServer = false
o.TeamSettings.EnableOpenServer = NewBool(false)
}
if o.TeamSettings.RestrictDirectMessage == nil {
o.TeamSettings.RestrictDirectMessage = new(string)
*o.TeamSettings.RestrictDirectMessage = DIRECT_MESSAGE_ANY
o.TeamSettings.RestrictDirectMessage = NewString(DIRECT_MESSAGE_ANY)
}
if o.TeamSettings.RestrictTeamInvite == nil {
o.TeamSettings.RestrictTeamInvite = new(string)
*o.TeamSettings.RestrictTeamInvite = PERMISSIONS_ALL
o.TeamSettings.RestrictTeamInvite = NewString(PERMISSIONS_ALL)
}
if o.TeamSettings.RestrictPublicChannelManagement == nil {
o.TeamSettings.RestrictPublicChannelManagement = new(string)
*o.TeamSettings.RestrictPublicChannelManagement = PERMISSIONS_ALL
o.TeamSettings.RestrictPublicChannelManagement = NewString(PERMISSIONS_ALL)
}
if o.TeamSettings.RestrictPrivateChannelManagement == nil {
o.TeamSettings.RestrictPrivateChannelManagement = new(string)
*o.TeamSettings.RestrictPrivateChannelManagement = PERMISSIONS_ALL
o.TeamSettings.RestrictPrivateChannelManagement = NewString(PERMISSIONS_ALL)
}
if o.TeamSettings.RestrictPublicChannelCreation == nil {
......@@ -835,50 +796,41 @@ func (o *Config) SetDefaults() {
}
if o.TeamSettings.RestrictPublicChannelDeletion == nil {
o.TeamSettings.RestrictPublicChannelDeletion = new(string)
// If this setting does not exist, assume migration from <3.6, so use management setting as default.
*o.TeamSettings.RestrictPublicChannelDeletion = *o.TeamSettings.RestrictPublicChannelManagement
o.TeamSettings.RestrictPublicChannelDeletion = NewString(*o.TeamSettings.RestrictPublicChannelManagement)
}
if o.TeamSettings.RestrictPrivateChannelDeletion == nil {
o.TeamSettings.RestrictPrivateChannelDeletion = new(string)
// If this setting does not exist, assume migration from <3.6, so use management setting as default.
*o.TeamSettings.RestrictPrivateChannelDeletion = *o.TeamSettings.RestrictPrivateChannelManagement
o.TeamSettings.RestrictPrivateChannelDeletion = NewString(*o.TeamSettings.RestrictPrivateChannelManagement)
}
if o.TeamSettings.RestrictPrivateChannelManageMembers == nil {
o.TeamSettings.RestrictPrivateChannelManageMembers = new(string)
*o.TeamSettings.RestrictPrivateChannelManageMembers = PERMISSIONS_ALL
o.TeamSettings.RestrictPrivateChannelManageMembers = NewString(PERMISSIONS_ALL)
}
if o.TeamSettings.EnableXToLeaveChannelsFromLHS == nil {
o.TeamSettings.EnableXToLeaveChannelsFromLHS = new(bool)
*o.TeamSettings.EnableXToLeaveChannelsFromLHS = false
o.TeamSettings.EnableXToLeaveChannelsFromLHS = NewBool(false)
}
if o.TeamSettings.UserStatusAwayTimeout == nil {
o.TeamSettings.UserStatusAwayTimeout = new(int64)
*o.TeamSettings.UserStatusAwayTimeout = TEAM_SETTINGS_DEFAULT_USER_STATUS_AWAY_TIMEOUT
o.TeamSettings.UserStatusAwayTimeout = NewInt64(TEAM_SETTINGS_DEFAULT_USER_STATUS_AWAY_TIMEOUT)
}
if o.TeamSettings.MaxChannelsPerTeam == nil {
o.TeamSettings.MaxChannelsPerTeam = new(int64)
*o.TeamSettings.MaxChannelsPerTeam = 2000
o.TeamSettings.MaxChannelsPerTeam = NewInt64(2000)
}
if o.TeamSettings.MaxNotificationsPerChannel == nil {
o.TeamSettings.MaxNotificationsPerChannel = new(int64)
*o.TeamSettings.MaxNotificationsPerChannel = 1000
o.TeamSettings.MaxNotificationsPerChannel = NewInt64(1000)
}
if o.TeamSettings.EnableConfirmNotificationsToChannel == nil {
o.TeamSettings.EnableConfirmNotificationsToChannel = new(bool)
*o.TeamSettings.EnableConfirmNotificationsToChannel = true
o.TeamSettings.EnableConfirmNotificationsToChannel = NewBool(true)
}
if o.TeamSettings.ExperimentalTownSquareIsReadOnly == nil {
o.TeamSettings.ExperimentalTownSquareIsReadOnly = new(bool)
*o.TeamSettings.ExperimentalTownSquareIsReadOnly = false
o.TeamSettings.ExperimentalTownSquareIsReadOnly = NewBool(false)
}
if o.EmailSettings.EnableSignInWithEmail == nil {
......@@ -892,43 +844,35 @@ func (o *Config) SetDefaults() {
}
if o.EmailSettings.EnableSignInWithUsername == nil {
o.EmailSettings.EnableSignInWithUsername = new(bool)
*o.EmailSettings.EnableSignInWithUsername = false
o.EmailSettings.EnableSignInWithUsername = NewBool(false)
}
if o.EmailSettings.SendPushNotifications == nil {
o.EmailSettings.SendPushNotifications = new(bool)
*o.EmailSettings.SendPushNotifications = false
o.EmailSettings.SendPushNotifications = NewBool(false)
}
if o.EmailSettings.PushNotificationServer == nil {
o.EmailSettings.PushNotificationServer = new(string)
*o.EmailSettings.PushNotificationServer = ""
o.EmailSettings.PushNotificationServer = NewString("")
}
if o.EmailSettings.PushNotificationContents == nil {
o.EmailSettings.PushNotificationContents = new(string)
*o.EmailSettings.PushNotificationContents = GENERIC_NOTIFICATION
o.EmailSettings.PushNotificationContents = NewString(GENERIC_NOTIFICATION)
}
if o.EmailSettings.FeedbackOrganization == nil {
o.EmailSettings.FeedbackOrganization = new(string)
*o.EmailSettings.FeedbackOrganization = EMAIL_SETTINGS_DEFAULT_FEEDBACK_ORGANIZATION
o.EmailSettings.FeedbackOrganization = NewString(EMAIL_SETTINGS_DEFAULT_FEEDBACK_ORGANIZATION)
}
if o.EmailSettings.EnableEmailBatching == nil {
o.EmailSettings.EnableEmailBatching = new(bool)
*o.EmailSettings.EnableEmailBatching = false
o.EmailSettings.EnableEmailBatching = NewBool(false)
}
if o.EmailSettings.EmailBatchingBufferSize == nil {
o.EmailSettings.EmailBatchingBufferSize = new(int)
*o.EmailSettings.EmailBatchingBufferSize = EMAIL_BATCHING_BUFFER_SIZE
o.EmailSettings.EmailBatchingBufferSize = NewInt(EMAIL_BATCHING_BUFFER_SIZE)
}
if o.EmailSettings.EmailBatchingInterval == nil {
o.EmailSettings.EmailBatchingInterval = new(int)
*o.EmailSettings.EmailBatchingInterval = EMAIL_BATCHING_INTERVAL
o.EmailSettings.EmailBatchingInterval = NewInt(EMAIL_BATCHING_INTERVAL)
}
if o.EmailSettings.EnableSMTPAuth == nil {
......@@ -945,13 +889,11 @@ func (o *Config) SetDefaults() {
}
if o.EmailSettings.SkipServerCertificateVerification == nil {
o.EmailSettings.SkipServerCertificateVerification = new(bool)
*o.EmailSettings.SkipServerCertificateVerification = false
o.EmailSettings.SkipServerCertificateVerification = NewBool(false)
}
if o.EmailSettings.EmailNotificationContentsType == nil {
o.EmailSettings.EmailNotificationContentsType = new(string)
*o.EmailSettings.EmailNotificationContentsType = EMAIL_NOTIFICATION_CONTENTS_FULL
o.EmailSettings.EmailNotificationContentsType = NewString(EMAIL_NOTIFICATION_CONTENTS_FULL)
}
if !IsSafeLink(o.SupportSettings.TermsOfServiceLink) {
......@@ -959,8 +901,7 @@ func (o *Config) SetDefaults() {
}
if o.SupportSettings.TermsOfServiceLink == nil {
o.SupportSettings.TermsOfServiceLink = new(string)
*o.SupportSettings.TermsOfServiceLink = SUPPORT_SETTINGS_DEFAULT_TERMS_OF_SERVICE_LINK
o.SupportSettings.TermsOfServiceLink = NewString(SUPPORT_SETTINGS_DEFAULT_TERMS_OF_SERVICE_LINK)
}
if !IsSafeLink(o.SupportSettings.PrivacyPolicyLink) {
......@@ -968,8 +909,7 @@ func (o *Config) SetDefaults() {
}
if o.SupportSettings.PrivacyPolicyLink == nil {
o.SupportSettings.PrivacyPolicyLink = new(string)
*o.SupportSettings.PrivacyPolicyLink = SUPPORT_SETTINGS_DEFAULT_PRIVACY_POLICY_LINK
o.SupportSettings.PrivacyPolicyLink = NewString(SUPPORT_SETTINGS_DEFAULT_PRIVACY_POLICY_LINK)
}
if !IsSafeLink(o.SupportSettings.AboutLink) {
......@@ -977,8 +917,7 @@ func (o *Config) SetDefaults() {
}
if o.SupportSettings.AboutLink == nil {
o.SupportSettings.AboutLink = new(string)
*o.SupportSettings.AboutLink = SUPPORT_SETTINGS_DEFAULT_ABOUT_LINK
o.SupportSettings.AboutLink = NewString(SUPPORT_SETTINGS_DEFAULT_ABOUT_LINK)
}
if !IsSafeLink(o.SupportSettings.HelpLink) {
......@@ -986,8 +925,7 @@ func (o *Config) SetDefaults() {
}
if o.SupportSettings.HelpLink == nil {
o.SupportSettings.HelpLink = new(string)
*o.SupportSettings.HelpLink = SUPPORT_SETTINGS_DEFAULT_HELP_LINK
o.SupportSettings.HelpLink = NewString(SUPPORT_SETTINGS_DEFAULT_HELP_LINK)
}
if !IsSafeLink(o.SupportSettings.ReportAProblemLink) {
......@@ -995,53 +933,43 @@ func (o *Config) SetDefaults() {
}
if o.SupportSettings.ReportAProblemLink == nil {
o.SupportSettings.ReportAProblemLink = new(string)
*o.SupportSettings.ReportAProblemLink = SUPPORT_SETTINGS_DEFAULT_REPORT_A_PROBLEM_LINK
o.SupportSettings.ReportAProblemLink = NewString(SUPPORT_SETTINGS_DEFAULT_REPORT_A_PROBLEM_LINK)
}
if o.SupportSettings.SupportEmail == nil {
o.SupportSettings.SupportEmail = new(string)
*o.SupportSettings.SupportEmail = SUPPORT_SETTINGS_DEFAULT_SUPPORT_EMAIL
o.SupportSettings.SupportEmail = NewString(SUPPORT_SETTINGS_DEFAULT_SUPPORT_EMAIL)
}
if o.AnnouncementSettings.EnableBanner == nil {
o.AnnouncementSettings.EnableBanner = new(bool)
*o.AnnouncementSettings.EnableBanner = false
o.AnnouncementSettings.EnableBanner = NewBool(false)
}
if o.AnnouncementSettings.BannerText == nil {
o.AnnouncementSettings.BannerText = new(string)
*o.AnnouncementSettings.BannerText = ""
o.AnnouncementSettings.BannerText = NewString("")
}
if o.AnnouncementSettings.BannerColor == nil {
o.AnnouncementSettings.BannerColor = new(string)
*o.AnnouncementSettings.BannerColor = ANNOUNCEMENT_SETTINGS_DEFAULT_BANNER_COLOR
o.AnnouncementSettings.BannerColor = NewString(ANNOUNCEMENT_SETTINGS_DEFAULT_BANNER_COLOR)
}
if o.AnnouncementSettings.BannerTextColor == nil {
o.AnnouncementSettings.BannerTextColor = new(string)
*o.AnnouncementSettings.BannerTextColor = ANNOUNCEMENT_SETTINGS_DEFAULT_BANNER_TEXT_COLOR
o.AnnouncementSettings.BannerTextColor = NewString(ANNOUNCEMENT_SETTINGS_DEFAULT_BANNER_TEXT_COLOR)
}
if o.AnnouncementSettings.AllowBannerDismissal == nil {
o.AnnouncementSettings.AllowBannerDismissal = new(bool)
*o.AnnouncementSettings.AllowBannerDismissal = true
o.AnnouncementSettings.AllowBannerDismissal = NewBool(true)
}
if o.ThemeSettings.EnableThemeSelection == nil {
o.ThemeSettings.EnableThemeSelection = new(bool)
*o.ThemeSettings.EnableThemeSelection = true
o.ThemeSettings.EnableThemeSelection = NewBool(true)
}
if o.ThemeSettings.DefaultTheme == nil {
o.ThemeSettings.DefaultTheme = new(string)
*o.ThemeSettings.DefaultTheme = TEAM_SETTINGS_DEFAULT_TEAM_TEXT
o.ThemeSettings.DefaultTheme = NewString(TEAM_SETTINGS_DEFAULT_TEAM_TEXT)
}
if o.ThemeSettings.AllowCustomThemes == nil {
o.ThemeSettings.AllowCustomThemes = new(bool)
*o.ThemeSettings.AllowCustomThemes = true
o.ThemeSettings.AllowCustomThemes = NewBool(true)
}
if o.ThemeSettings.AllowedThemes == nil {
......@@ -1049,370 +977,297 @@ func (o *Config) SetDefaults() {
}
if o.LdapSettings.Enable == nil {
o.LdapSettings.Enable = new(bool)
*o.LdapSettings.Enable = false
o.LdapSettings.Enable = NewBool(false)
}
if o.LdapSettings.LdapServer == nil {
o.LdapSettings.LdapServer = new(string)
*o.LdapSettings.LdapServer = ""
o.LdapSettings.LdapServer = NewString("")
}
if o.LdapSettings.LdapPort == nil {
o.LdapSettings.LdapPort = new(int)
*o.LdapSettings.LdapPort = 389
o.LdapSettings.LdapPort = NewInt(389)
}
if o.LdapSettings.ConnectionSecurity == nil {
o.LdapSettings.ConnectionSecurity = new(string)
*o.LdapSettings.ConnectionSecurity = ""
o.LdapSettings.ConnectionSecurity = NewString("")
}
if o.LdapSettings.BaseDN == nil {
o.LdapSettings.BaseDN = new(string)
*o.LdapSettings.BaseDN = ""
o.LdapSettings.BaseDN = NewString("")
}
if o.LdapSettings.BindUsername == nil {
o.LdapSettings.BindUsername = new(string)
*o.LdapSettings.BindUsername = ""
o.LdapSettings.BindUsername = NewString("")
}
if o.LdapSettings.BindPassword == nil {
o.LdapSettings.BindPassword = new(string)
*o.LdapSettings.BindPassword = ""
o.LdapSettings.BindPassword = NewString("")
}
if o.LdapSettings.UserFilter == nil {
o.LdapSettings.UserFilter = new(string)
*o.LdapSettings.UserFilter = ""
o.LdapSettings.UserFilter = NewString("")
}
if o.LdapSettings.FirstNameAttribute == nil {
o.LdapSettings.FirstNameAttribute = new(string)
*o.LdapSettings.FirstNameAttribute = LDAP_SETTINGS_DEFAULT_FIRST_NAME_ATTRIBUTE
o.LdapSettings.FirstNameAttribute = NewString(LDAP_SETTINGS_DEFAULT_FIRST_NAME_ATTRIBUTE)
}
if o.LdapSettings.LastNameAttribute == nil {
o.LdapSettings.LastNameAttribute = new(string)
*o.LdapSettings.LastNameAttribute = LDAP_SETTINGS_DEFAULT_LAST_NAME_ATTRIBUTE
o.LdapSettings.LastNameAttribute = NewString(LDAP_SETTINGS_DEFAULT_LAST_NAME_ATTRIBUTE)
}
if o.LdapSettings.EmailAttribute == nil {
o.LdapSettings.EmailAttribute = new(string)
*o.LdapSettings.EmailAttribute = LDAP_SETTINGS_DEFAULT_EMAIL_ATTRIBUTE
o.LdapSettings.EmailAttribute = NewString(LDAP_SETTINGS_DEFAULT_EMAIL_ATTRIBUTE)
}
if o.LdapSettings.UsernameAttribute == nil {
o.LdapSettings.UsernameAttribute = new(string)
*o.LdapSettings.UsernameAttribute = LDAP_SETTINGS_DEFAULT_USERNAME_ATTRIBUTE
o.LdapSettings.UsernameAttribute = NewString(LDAP_SETTINGS_DEFAULT_USERNAME_ATTRIBUTE)
}
if o.LdapSettings.NicknameAttribute == nil {
o.LdapSettings.NicknameAttribute = new(string)
*o.LdapSettings.NicknameAttribute = LDAP_SETTINGS_DEFAULT_NICKNAME_ATTRIBUTE
o.LdapSettings.NicknameAttribute = NewString(LDAP_SETTINGS_DEFAULT_NICKNAME_ATTRIBUTE)
}
if o.LdapSettings.IdAttribute == nil {