Skip to content

Commit

Permalink
Remove remaining references to model.NewXX (mattermost#28678)
Browse files Browse the repository at this point in the history
And we remove the deprecated functions to force uses
only of the new function.
```release-note
NONE
```
  • Loading branch information
agnivade authored Oct 10, 2024
1 parent 3db139f commit a258fd8
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 39 deletions.
60 changes: 30 additions & 30 deletions server/channels/app/import_functions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3350,7 +3350,7 @@ func TestImportImportDirectChannel(t *testing.T) {
dataset := generateDataset(imports.DirectChannelImportData{
Participants: []*imports.DirectChannelMemberImportData{
{
Username: model.NewString(model.NewId()),
Username: model.NewPointer(model.NewId()),
},
},
Header: ptrStr("Channel Header"),
Expand All @@ -3371,10 +3371,10 @@ func TestImportImportDirectChannel(t *testing.T) {
dataset := generateDataset(imports.DirectChannelImportData{
Participants: []*imports.DirectChannelMemberImportData{
{
Username: model.NewString(model.NewId()),
Username: model.NewPointer(model.NewId()),
},
{
Username: model.NewString(model.NewId()),
Username: model.NewPointer(model.NewId()),
},
},
})
Expand All @@ -3394,13 +3394,13 @@ func TestImportImportDirectChannel(t *testing.T) {
dataset := generateDataset(imports.DirectChannelImportData{
Participants: []*imports.DirectChannelMemberImportData{
{
Username: model.NewString(model.NewId()),
Username: model.NewPointer(model.NewId()),
},
{
Username: model.NewString(model.NewId()),
Username: model.NewPointer(model.NewId()),
},
{
Username: model.NewString(model.NewId()),
Username: model.NewPointer(model.NewId()),
},
},
})
Expand All @@ -3420,7 +3420,7 @@ func TestImportImportDirectChannel(t *testing.T) {
dataset := generateDataset(imports.DirectChannelImportData{
Participants: []*imports.DirectChannelMemberImportData{
{
Username: model.NewString(model.NewId()),
Username: model.NewPointer(model.NewId()),
},
},
})
Expand All @@ -3440,10 +3440,10 @@ func TestImportImportDirectChannel(t *testing.T) {
dataset := generateDataset(imports.DirectChannelImportData{
Participants: []*imports.DirectChannelMemberImportData{
{
Username: model.NewString(th.BasicUser.Username),
Username: model.NewPointer(th.BasicUser.Username),
},
{
Username: model.NewString(th.BasicUser2.Username),
Username: model.NewPointer(th.BasicUser2.Username),
},
},
})
Expand Down Expand Up @@ -3485,16 +3485,16 @@ func TestImportImportDirectChannel(t *testing.T) {
dataset := generateDataset(imports.DirectChannelImportData{
Participants: []*imports.DirectChannelMemberImportData{
{
Username: model.NewString(th.BasicUser.Username),
Username: model.NewPointer(th.BasicUser.Username),
},
{
Username: model.NewString(th.BasicUser2.Username),
Username: model.NewPointer(th.BasicUser2.Username),
},
{
Username: model.NewString(user3.Username),
Username: model.NewPointer(user3.Username),
},
{
Username: model.NewString(model.NewId()),
Username: model.NewPointer(model.NewId()),
},
},
})
Expand All @@ -3514,13 +3514,13 @@ func TestImportImportDirectChannel(t *testing.T) {
dataset := generateDataset(imports.DirectChannelImportData{
Participants: []*imports.DirectChannelMemberImportData{
{
Username: model.NewString(th.BasicUser.Username),
Username: model.NewPointer(th.BasicUser.Username),
},
{
Username: model.NewString(th.BasicUser2.Username),
Username: model.NewPointer(th.BasicUser2.Username),
},
{
Username: model.NewString(user3.Username),
Username: model.NewPointer(user3.Username),
},
},
})
Expand Down Expand Up @@ -3567,10 +3567,10 @@ func TestImportImportDirectChannel(t *testing.T) {
dataset := generateDataset(imports.DirectChannelImportData{
Participants: []*imports.DirectChannelMemberImportData{
{
Username: model.NewString(th.BasicUser.Username),
Username: model.NewPointer(th.BasicUser.Username),
},
{
Username: model.NewString(th.BasicUser2.Username),
Username: model.NewPointer(th.BasicUser2.Username),
},
},
})
Expand All @@ -3596,11 +3596,11 @@ func TestImportImportDirectChannel(t *testing.T) {
data := imports.DirectChannelImportData{
Participants: []*imports.DirectChannelMemberImportData{
{
Username: model.NewString(th.BasicUser.Username),
Username: model.NewPointer(th.BasicUser.Username),
LastViewedAt: ptrInt64(lastView),
},
{
Username: model.NewString(th.BasicUser2.Username),
Username: model.NewPointer(th.BasicUser2.Username),
},
},
}
Expand All @@ -3626,10 +3626,10 @@ func TestImportImportDirectChannel(t *testing.T) {
data := imports.DirectChannelImportData{
Participants: []*imports.DirectChannelMemberImportData{
{
Username: model.NewString(th.BasicUser.Username),
Username: model.NewPointer(th.BasicUser.Username),
},
{
Username: model.NewString(th.BasicUser2.Username),
Username: model.NewPointer(th.BasicUser2.Username),
},
},
ShownBy: &[]string{
Expand Down Expand Up @@ -3658,13 +3658,13 @@ func TestImportImportDirectChannel(t *testing.T) {
data := imports.DirectChannelImportData{
Participants: []*imports.DirectChannelMemberImportData{
{
Username: model.NewString(th.BasicUser.Username),
Username: model.NewPointer(th.BasicUser.Username),
},
{
Username: model.NewString(th.BasicUser2.Username),
Username: model.NewPointer(th.BasicUser2.Username),
},
{
Username: model.NewString(user3.Username),
Username: model.NewPointer(user3.Username),
},
},
ShownBy: &[]string{
Expand Down Expand Up @@ -3698,10 +3698,10 @@ func TestImportImportDirectPost(t *testing.T) {
channelData := imports.DirectChannelImportData{
Participants: []*imports.DirectChannelMemberImportData{
{
Username: model.NewString(th.BasicUser.Username),
Username: model.NewPointer(th.BasicUser.Username),
},
{
Username: model.NewString(th.BasicUser2.Username),
Username: model.NewPointer(th.BasicUser2.Username),
},
},
}
Expand Down Expand Up @@ -4161,13 +4161,13 @@ func TestImportImportDirectPost(t *testing.T) {
channelData = imports.DirectChannelImportData{
Participants: []*imports.DirectChannelMemberImportData{
{
Username: model.NewString(th.BasicUser.Username),
Username: model.NewPointer(th.BasicUser.Username),
},
{
Username: model.NewString(th.BasicUser2.Username),
Username: model.NewPointer(th.BasicUser2.Username),
},
{
Username: model.NewString(user3.Username),
Username: model.NewPointer(user3.Username),
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion server/cmd/mmctl/commands/sampledata_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ func createDirectChannel(members []string) imports.LineImportData {

for _, m := range members {
p = append(p, &imports.DirectChannelMemberImportData{
Username: model.NewString(m),
Username: model.NewPointer(m),
})
}

Expand Down
6 changes: 0 additions & 6 deletions server/public/model/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@

package model

// These functions are deprecated. Please use only NewPointer.
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 }

// NewPointer returns a pointer to the object passed.
func NewPointer[T any](t T) *T { return &t }

Expand Down
4 changes: 2 additions & 2 deletions server/public/model/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ func (s *ServiceSettings) SetDefaults(isUpdate bool) {
}

if s.EnableAPIPostDeletion == nil {
s.EnableAPIPostDeletion = NewBool(false)
s.EnableAPIPostDeletion = NewPointer(false)
}

if s.EnableAPIChannelDeletion == nil {
Expand Down Expand Up @@ -1141,7 +1141,7 @@ func (s *ExperimentalSettings) SetDefaults() {
}

if s.YoutubeReferrerPolicy == nil {
s.YoutubeReferrerPolicy = NewBool(false)
s.YoutubeReferrerPolicy = NewPointer(false)
}
}

Expand Down

0 comments on commit a258fd8

Please sign in to comment.