MM-21357: Use typed constant for channel types (#17928)

* MM-21357: Use typed constant for channel types

https://mattermost.atlassian.net/browse/MM-21357

```release-note
- Introduced a new type ChannelType for all channel types.
- Updated the Client4.UpdateChannelPrivacy method to ChannelType.
```

* Address review comments

```release-note
NONE
```

* telemetry fix

```release-note
NONE
```
Этот коммит содержится в:
Agniva De Sarker
2021-07-20 12:45:26 +05:30
коммит произвёл Claudio Costa
родитель 4968657651
Коммит da7d71ccf7
37 изменённых файлов: 114 добавлений и 101 удалений

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

@@ -1043,7 +1043,7 @@ func (s SqlChannelStore) getAllChannelsQuery(opts store.ChannelSearchOpts, forCo
query := s.getQueryBuilder().
Select(selectStr).
From("Channels AS c").
Where(sq.Eq{"c.Type": []string{model.ChannelTypePrivate, model.ChannelTypeOpen}})
Where(sq.Eq{"c.Type": []model.ChannelType{model.ChannelTypePrivate, model.ChannelTypeOpen}})
if !forCount {
query = query.Join("Teams ON Teams.Id = c.TeamId")
@@ -2376,7 +2376,7 @@ func (s SqlChannelStore) GetForPost(postId string) (*model.Channel, error) {
return channel, nil
}
func (s SqlChannelStore) AnalyticsTypeCount(teamId string, channelType string) (int64, error) {
func (s SqlChannelStore) AnalyticsTypeCount(teamId string, channelType model.ChannelType) (int64, error) {
query := "SELECT COUNT(Id) AS Value FROM Channels WHERE Type = :ChannelType"
if teamId != "" {

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

@@ -378,11 +378,11 @@ func (s SqlChannelStore) completePopulatingCategoryChannelsT(db dbSelecter, cate
var channelTypeFilter sq.Sqlizer
if category.Type == model.SidebarCategoryDirectMessages {
// any DM/GM channels that aren't in any category should be returned as part of the Direct Messages category
channelTypeFilter = sq.Eq{"Channels.Type": []string{model.ChannelTypeDirect, model.ChannelTypeGroup}}
channelTypeFilter = sq.Eq{"Channels.Type": []model.ChannelType{model.ChannelTypeDirect, model.ChannelTypeGroup}}
} else if category.Type == model.SidebarCategoryChannels {
// any public/private channels that are on the current team and aren't in any category should be returned as part of the Channels category
channelTypeFilter = sq.And{
sq.Eq{"Channels.Type": []string{model.ChannelTypeOpen, model.ChannelTypePrivate}},
sq.Eq{"Channels.Type": []model.ChannelType{model.ChannelTypeOpen, model.ChannelTypePrivate}},
sq.Eq{"Channels.TeamId": category.TeamId},
}
}

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

@@ -215,7 +215,7 @@ func checkTeamsChannelsIntegrity(ss *SqlStore) model.IntegrityCheckResult {
parentIdAttr: "TeamId",
childName: "Channels",
childIdAttr: "Id",
filter: sq.NotEq{"CT.Type": []string{model.ChannelTypeDirect, model.ChannelTypeGroup}},
filter: sq.NotEq{"CT.Type": []model.ChannelType{model.ChannelTypeDirect, model.ChannelTypeGroup}},
})
res2 := checkParentChildIntegrity(ss, relationalCheckConfig{
parentName: "Teams",
@@ -223,7 +223,7 @@ func checkTeamsChannelsIntegrity(ss *SqlStore) model.IntegrityCheckResult {
childName: "Channels",
childIdAttr: "Id",
canParentIdBeEmpty: true,
filter: sq.Eq{"CT.Type": []string{model.ChannelTypeDirect, model.ChannelTypeGroup}},
filter: sq.Eq{"CT.Type": []model.ChannelType{model.ChannelTypeDirect, model.ChannelTypeGroup}},
})
data1 := res1.Data.(model.RelationalIntegrityCheckData)
data2 := res2.Data.(model.RelationalIntegrityCheckData)