OSF: Used model.NewPointer everywhere (#27838)

```release-note
NONE
```
Этот коммит содержится в:
Agniva De Sarker
2024-08-06 09:15:00 +05:30
коммит произвёл GitHub
родитель f290745496
Коммит c3ed07e679
148 изменённых файлов: 2341 добавлений и 2338 удалений

Просмотреть файл

@@ -22,14 +22,14 @@ func makeTestAtmosCamoProxy() *ImageProxy {
configService := &testutils.StaticConfigService{
Cfg: &model.Config{
ServiceSettings: model.ServiceSettings{
SiteURL: model.NewString("https://mattermost.example.com"),
AllowedUntrustedInternalConnections: model.NewString("127.0.0.1"),
SiteURL: model.NewPointer("https://mattermost.example.com"),
AllowedUntrustedInternalConnections: model.NewPointer("127.0.0.1"),
},
ImageProxySettings: model.ImageProxySettings{
Enable: model.NewBool(true),
ImageProxyType: model.NewString(model.ImageProxyTypeAtmosCamo),
RemoteImageProxyURL: model.NewString("http://images.example.com"),
RemoteImageProxyOptions: model.NewString("7e5f3fab20b94782b43cdb022a66985ef28ba355df2c5d5da3c9a05e4b697bac"),
Enable: model.NewPointer(true),
ImageProxyType: model.NewPointer(model.ImageProxyTypeAtmosCamo),
RemoteImageProxyURL: model.NewPointer("http://images.example.com"),
RemoteImageProxyOptions: model.NewPointer("7e5f3fab20b94782b43cdb022a66985ef28ba355df2c5d5da3c9a05e4b697bac"),
},
},
}

Просмотреть файл

@@ -125,14 +125,14 @@ func TestOnConfigChange(t *testing.T) {
require.Equal(t, "https://mattermost.example.com", proxy.backend.(*AtmosCamoBackend).siteURL.String())
newConfig := proxy.ConfigService.Config().Clone()
newConfig.ImageProxySettings.ImageProxyType = model.NewString(model.ImageProxyTypeLocal)
newConfig.ImageProxySettings.ImageProxyType = model.NewPointer(model.ImageProxyTypeLocal)
proxy.ConfigService.(*testutils.StaticConfigService).UpdateConfig(newConfig)
require.Equal(t, "https://mattermost.example.com", proxy.backend.(*LocalBackend).baseURL.String())
newConfig = proxy.ConfigService.Config().Clone()
newConfig.ImageProxySettings.ImageProxyType = model.NewString(model.ImageProxyTypeAtmosCamo)
newConfig.ImageProxySettings.ImageProxyType = model.NewPointer(model.ImageProxyTypeAtmosCamo)
proxy.ConfigService.(*testutils.StaticConfigService).UpdateConfig(newConfig)
@@ -146,7 +146,7 @@ func TestOnConfigChange(t *testing.T) {
require.Equal(t, "https://mattermost.example.com", proxy.backend.(*LocalBackend).baseURL.String())
newConfig := proxy.ConfigService.Config().Clone()
newConfig.ServiceSettings.SiteURL = model.NewString("https://new.example.com")
newConfig.ServiceSettings.SiteURL = model.NewPointer("https://new.example.com")
proxy.ConfigService.(*testutils.StaticConfigService).UpdateConfig(newConfig)
@@ -161,7 +161,7 @@ func TestOnConfigChange(t *testing.T) {
require.Equal(t, "https://mattermost.example.com", proxy.backend.(*AtmosCamoBackend).siteURL.String())
newConfig := proxy.ConfigService.Config().Clone()
newConfig.ServiceSettings.SiteURL = model.NewString("https://new.example.com")
newConfig.ServiceSettings.SiteURL = model.NewPointer("https://new.example.com")
proxy.ConfigService.(*testutils.StaticConfigService).UpdateConfig(newConfig)
@@ -176,8 +176,8 @@ func TestOnConfigChange(t *testing.T) {
// require.Equal(t, "7e5f3fab20b94782b43cdb022a66985ef28ba355df2c5d5da3c9a05e4b697bac", proxy.backend.(*AtmosCamoBackend).remoteOptions)
newConfig := proxy.ConfigService.Config().Clone()
newConfig.ImageProxySettings.RemoteImageProxyURL = model.NewString("https://new.example.com")
newConfig.ImageProxySettings.RemoteImageProxyOptions = model.NewString("some other random hash")
newConfig.ImageProxySettings.RemoteImageProxyURL = model.NewPointer("https://new.example.com")
newConfig.ImageProxySettings.RemoteImageProxyOptions = model.NewPointer("some other random hash")
proxy.ConfigService.(*testutils.StaticConfigService).UpdateConfig(newConfig)

Просмотреть файл

@@ -22,12 +22,12 @@ func makeTestLocalProxy() *ImageProxy {
configService := &testutils.StaticConfigService{
Cfg: &model.Config{
ServiceSettings: model.ServiceSettings{
SiteURL: model.NewString("https://mattermost.example.com"),
AllowedUntrustedInternalConnections: model.NewString("127.0.0.1"),
SiteURL: model.NewPointer("https://mattermost.example.com"),
AllowedUntrustedInternalConnections: model.NewPointer("127.0.0.1"),
},
ImageProxySettings: model.ImageProxySettings{
Enable: model.NewBool(true),
ImageProxyType: model.NewString(model.ImageProxyTypeLocal),
Enable: model.NewPointer(true),
ImageProxyType: model.NewPointer(model.ImageProxyTypeLocal),
},
},
}

Просмотреть файл

@@ -95,7 +95,7 @@ func TestService_sendProfileImageToRemote(t *testing.T) {
user := &model.User{
Id: model.NewId(),
RemoteId: model.NewString(rc.RemoteId),
RemoteId: model.NewPointer(rc.RemoteId),
}
provider := testImageProvider{}

Просмотреть файл

@@ -62,11 +62,11 @@ func (s *BleveEngineTestSuite) setupStore() {
cfg := &model.Config{}
cfg.SetDefaults()
cfg.BleveSettings.EnableIndexing = model.NewBool(true)
cfg.BleveSettings.EnableSearching = model.NewBool(true)
cfg.BleveSettings.EnableAutocomplete = model.NewBool(true)
cfg.BleveSettings.IndexDir = model.NewString(s.IndexDir)
cfg.SqlSettings.DisableDatabaseSearch = model.NewBool(true)
cfg.BleveSettings.EnableIndexing = model.NewPointer(true)
cfg.BleveSettings.EnableSearching = model.NewPointer(true)
cfg.BleveSettings.EnableAutocomplete = model.NewPointer(true)
cfg.BleveSettings.IndexDir = model.NewPointer(s.IndexDir)
cfg.SqlSettings.DisableDatabaseSearch = model.NewPointer(true)
s.SearchEngine = searchengine.NewBroker(cfg)
s.Store = searchlayer.NewSearchLayer(&testlib.TestStore{Store: s.SQLStore}, s.SearchEngine, cfg)

Просмотреть файл

@@ -43,8 +43,8 @@ func TestBleveIndexer(t *testing.T) {
cfg := &model.Config{
BleveSettings: model.BleveSettings{
EnableIndexing: model.NewBool(true),
IndexDir: model.NewString(tempDir),
EnableIndexing: model.NewPointer(true),
IndexDir: model.NewPointer(tempDir),
},
}

Просмотреть файл

@@ -276,7 +276,7 @@ func (scs *Service) handleChannelCreation(invite channelInviteMsg, rc *model.Rem
Header: invite.Header,
Purpose: invite.Purpose,
CreatorId: rc.CreatorId,
Shared: model.NewBool(true),
Shared: model.NewPointer(true),
}
// check user perms?

Просмотреть файл

@@ -93,8 +93,8 @@ func TestOnReceiveChannelInvite(t *testing.T) {
createPostPermission := model.ChannelModeratedPermissionsMap[model.PermissionCreatePost.Id]
createReactionPermission := model.ChannelModeratedPermissionsMap[model.PermissionAddReaction.Id]
updateMap := model.ChannelModeratedRolesPatch{
Guests: model.NewBool(false),
Members: model.NewBool(false),
Guests: model.NewPointer(false),
Members: model.NewPointer(false),
}
mockApp.On("CreateChannelWithUser", mockTypeReqContext, mockTypeChannel, mockTypeString).Return(channel, nil)
@@ -175,7 +175,7 @@ func TestOnReceiveChannelInvite(t *testing.T) {
{"two remotes", &model.User{Id: model.NewId(), RemoteId: &testRemoteID}, &model.User{Id: model.NewId(), RemoteId: &testRemoteID}, true, false},
{"two locals", &model.User{Id: model.NewId()}, &model.User{Id: model.NewId()}, true, false},
{"can't see", &model.User{Id: model.NewId(), RemoteId: &testRemoteID}, &model.User{Id: model.NewId()}, false, false},
{"invalid remoteid", &model.User{Id: model.NewId(), RemoteId: model.NewString("bogus")}, &model.User{Id: model.NewId()}, true, false},
{"invalid remoteid", &model.User{Id: model.NewId(), RemoteId: model.NewPointer("bogus")}, &model.User{Id: model.NewId()}, true, false},
}
for _, tc := range testCases {

Просмотреть файл

@@ -220,8 +220,8 @@ func (scs *Service) makeChannelReadOnly(channel *model.Channel) *model.AppError
createPostPermission := model.ChannelModeratedPermissionsMap[model.PermissionCreatePost.Id]
createReactionPermission := model.ChannelModeratedPermissionsMap[model.PermissionAddReaction.Id]
updateMap := model.ChannelModeratedRolesPatch{
Guests: model.NewBool(false),
Members: model.NewBool(false),
Guests: model.NewPointer(false),
Members: model.NewPointer(false),
}
readonlyChannelModerations := []*model.ChannelModerationPatch{

Просмотреть файл

@@ -194,7 +194,7 @@ func (scs *Service) upsertSyncUser(c request.CTX, user *model.User, channel *mod
var userSaved *model.User
if euser == nil {
// new user. Make sure the remoteID is correct and insert the record
user.RemoteId = model.NewString(rc.RemoteId)
user.RemoteId = model.NewPointer(rc.RemoteId)
if userSaved, err = scs.insertSyncUser(c, user, channel, rc); err != nil {
return nil, err
}
@@ -353,7 +353,7 @@ func (scs *Service) updateSyncUser(rctx request.CTX, patch *model.UserPatch, use
func (scs *Service) upsertSyncPost(post *model.Post, targetChannel *model.Channel, rc *model.RemoteCluster) (*model.Post, error) {
var appErr *model.AppError
post.RemoteId = model.NewString(rc.RemoteId)
post.RemoteId = model.NewPointer(rc.RemoteId)
rctx := request.EmptyContext(scs.server.Log())
rpost, err := scs.server.GetStore().Post().GetSingle(rctx, post.Id, true)
@@ -450,7 +450,7 @@ func (scs *Service) upsertSyncReaction(reaction *model.Reaction, targetChannel *
if user.GetRemoteID() != rc.RemoteId {
return nil, fmt.Errorf("reaction sync failed: %w", ErrRemoteIDMismatch)
}
reaction.RemoteId = model.NewString(rc.RemoteId)
reaction.RemoteId = model.NewPointer(rc.RemoteId)
savedReaction, appErr = scs.app.SaveReactionForPost(request.EmptyContext(scs.server.Log()), reaction)
} else {
// make sure the reaction being deleted is owned by the remote

Просмотреть файл

@@ -713,8 +713,8 @@ func TestNewExportFileBackendSettingsFromConfig(t *testing.T) {
}
actual := NewExportFileBackendSettingsFromConfig(&model.FileSettings{
ExportDriverName: model.NewString(driverLocal),
ExportDirectory: model.NewString("directory"),
ExportDriverName: model.NewPointer(driverLocal),
ExportDirectory: model.NewPointer("directory"),
}, enableComplianceFeature, skipVerify)
require.Equal(t, expected, actual)
@@ -744,20 +744,20 @@ func TestNewExportFileBackendSettingsFromConfig(t *testing.T) {
}
actual := NewExportFileBackendSettingsFromConfig(&model.FileSettings{
ExportDriverName: model.NewString(driverS3),
ExportAmazonS3AccessKeyId: model.NewString("minioaccesskey"),
ExportAmazonS3SecretAccessKey: model.NewString("miniosecretkey"),
ExportAmazonS3Bucket: model.NewString("mattermost-test"),
ExportAmazonS3Region: model.NewString("region"),
ExportAmazonS3Endpoint: model.NewString("s3.example.com"),
ExportAmazonS3PathPrefix: model.NewString("prefix"),
ExportAmazonS3SSL: model.NewBool(true),
ExportAmazonS3SignV2: model.NewBool(true),
ExportAmazonS3SSE: model.NewBool(true),
ExportAmazonS3Trace: model.NewBool(true),
ExportAmazonS3RequestTimeoutMilliseconds: model.NewInt64(1000),
ExportAmazonS3PresignExpiresSeconds: model.NewInt64(60000),
ExportAmazonS3UploadPartSizeBytes: model.NewInt64(model.FileSettingsDefaultS3ExportUploadPartSizeBytes),
ExportDriverName: model.NewPointer(driverS3),
ExportAmazonS3AccessKeyId: model.NewPointer("minioaccesskey"),
ExportAmazonS3SecretAccessKey: model.NewPointer("miniosecretkey"),
ExportAmazonS3Bucket: model.NewPointer("mattermost-test"),
ExportAmazonS3Region: model.NewPointer("region"),
ExportAmazonS3Endpoint: model.NewPointer("s3.example.com"),
ExportAmazonS3PathPrefix: model.NewPointer("prefix"),
ExportAmazonS3SSL: model.NewPointer(true),
ExportAmazonS3SignV2: model.NewPointer(true),
ExportAmazonS3SSE: model.NewPointer(true),
ExportAmazonS3Trace: model.NewPointer(true),
ExportAmazonS3RequestTimeoutMilliseconds: model.NewPointer(int64(1000)),
ExportAmazonS3PresignExpiresSeconds: model.NewPointer(int64(60000)),
ExportAmazonS3UploadPartSizeBytes: model.NewPointer(int64(model.FileSettingsDefaultS3ExportUploadPartSizeBytes)),
}, enableComplianceFeature, skipVerify)
require.Equal(t, expected, actual)
@@ -787,20 +787,20 @@ func TestNewExportFileBackendSettingsFromConfig(t *testing.T) {
}
actual := NewExportFileBackendSettingsFromConfig(&model.FileSettings{
ExportDriverName: model.NewString(driverS3),
ExportAmazonS3AccessKeyId: model.NewString("minioaccesskey"),
ExportAmazonS3SecretAccessKey: model.NewString("miniosecretkey"),
ExportAmazonS3Bucket: model.NewString("mattermost-test"),
ExportAmazonS3Region: model.NewString("region"),
ExportAmazonS3Endpoint: model.NewString("s3.example.com"),
ExportAmazonS3PathPrefix: model.NewString("prefix"),
ExportAmazonS3SSL: model.NewBool(true),
ExportAmazonS3SignV2: model.NewBool(true),
ExportAmazonS3SSE: model.NewBool(true),
ExportAmazonS3Trace: model.NewBool(true),
ExportAmazonS3RequestTimeoutMilliseconds: model.NewInt64(1000),
ExportAmazonS3PresignExpiresSeconds: model.NewInt64(60000),
ExportAmazonS3UploadPartSizeBytes: model.NewInt64(model.FileSettingsDefaultS3ExportUploadPartSizeBytes),
ExportDriverName: model.NewPointer(driverS3),
ExportAmazonS3AccessKeyId: model.NewPointer("minioaccesskey"),
ExportAmazonS3SecretAccessKey: model.NewPointer("miniosecretkey"),
ExportAmazonS3Bucket: model.NewPointer("mattermost-test"),
ExportAmazonS3Region: model.NewPointer("region"),
ExportAmazonS3Endpoint: model.NewPointer("s3.example.com"),
ExportAmazonS3PathPrefix: model.NewPointer("prefix"),
ExportAmazonS3SSL: model.NewPointer(true),
ExportAmazonS3SignV2: model.NewPointer(true),
ExportAmazonS3SSE: model.NewPointer(true),
ExportAmazonS3Trace: model.NewPointer(true),
ExportAmazonS3RequestTimeoutMilliseconds: model.NewPointer(int64(1000)),
ExportAmazonS3PresignExpiresSeconds: model.NewPointer(int64(60000)),
ExportAmazonS3UploadPartSizeBytes: model.NewPointer(int64(model.FileSettingsDefaultS3ExportUploadPartSizeBytes)),
}, enableComplianceFeature, skipVerify)
require.Equal(t, expected, actual)