Migrate Channel.UserBelongsToChannels to Sync by default (#11269)
* Migrate Channel.UserBelongsToChannels to Sync by default * Address comments
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
242c4f2c66
Коммит
8853a71f0b
@@ -2134,11 +2134,7 @@ func (a *App) userBelongsToTeams(userId string, teamIds []string) (bool, *model.
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) userBelongsToChannels(userId string, channelIds []string) (bool, *model.AppError) {
|
func (a *App) userBelongsToChannels(userId string, channelIds []string) (bool, *model.AppError) {
|
||||||
result := <-a.Srv.Store.Channel().UserBelongsToChannels(userId, channelIds)
|
return a.Srv.Store.Channel().UserBelongsToChannels(userId, channelIds)
|
||||||
if result.Err != nil {
|
|
||||||
return false, result.Err
|
|
||||||
}
|
|
||||||
return result.Data.(bool), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) GetViewUsersRestrictions(userId string) (*model.ViewUsersRestrictions, *model.AppError) {
|
func (a *App) GetViewUsersRestrictions(userId string) (*model.ViewUsersRestrictions, *model.AppError) {
|
||||||
|
|||||||
@@ -2634,8 +2634,7 @@ func (s SqlChannelStore) GetChannelsBatchForIndexing(startTime, endTime int64, l
|
|||||||
return channels, nil
|
return channels, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlChannelStore) UserBelongsToChannels(userId string, channelIds []string) store.StoreChannel {
|
func (s SqlChannelStore) UserBelongsToChannels(userId string, channelIds []string) (bool, *model.AppError) {
|
||||||
return store.Do(func(result *store.StoreResult) {
|
|
||||||
query := s.getQueryBuilder().
|
query := s.getQueryBuilder().
|
||||||
Select("Count(*)").
|
Select("Count(*)").
|
||||||
From("ChannelMembers").
|
From("ChannelMembers").
|
||||||
@@ -2646,14 +2645,11 @@ func (s SqlChannelStore) UserBelongsToChannels(userId string, channelIds []strin
|
|||||||
|
|
||||||
queryString, args, err := query.ToSql()
|
queryString, args, err := query.ToSql()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
result.Err = model.NewAppError("SqlChannelStore.UserBelongsToChannels", "store.sql_channel.user_belongs_to_channels.app_error", nil, err.Error(), http.StatusInternalServerError)
|
return false, model.NewAppError("SqlChannelStore.UserBelongsToChannels", "store.sql_channel.user_belongs_to_channels.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
c, err := s.GetReplica().SelectInt(queryString, args...)
|
c, err := s.GetReplica().SelectInt(queryString, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
result.Err = model.NewAppError("SqlChannelStore.UserBelongsToChannels", "store.sql_channel.user_belongs_to_channels.app_error", nil, err.Error(), http.StatusInternalServerError)
|
return false, model.NewAppError("SqlChannelStore.UserBelongsToChannels", "store.sql_channel.user_belongs_to_channels.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
result.Data = c > 0
|
return c > 0, nil
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ type ChannelStore interface {
|
|||||||
GetChannelMembersForExport(userId string, teamId string) StoreChannel
|
GetChannelMembersForExport(userId string, teamId string) StoreChannel
|
||||||
RemoveAllDeactivatedMembers(channelId string) StoreChannel
|
RemoveAllDeactivatedMembers(channelId string) StoreChannel
|
||||||
GetChannelsBatchForIndexing(startTime, endTime int64, limit int) ([]*model.Channel, *model.AppError)
|
GetChannelsBatchForIndexing(startTime, endTime int64, limit int) ([]*model.Channel, *model.AppError)
|
||||||
UserBelongsToChannels(userId string, channelIds []string) StoreChannel
|
UserBelongsToChannels(userId string, channelIds []string) (bool, *model.AppError)
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChannelMemberHistoryStore interface {
|
type ChannelMemberHistoryStore interface {
|
||||||
|
|||||||
@@ -1240,17 +1240,24 @@ func (_m *ChannelStore) UpdateMember(member *model.ChannelMember) store.StoreCha
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UserBelongsToChannels provides a mock function with given fields: userId, channelIds
|
// UserBelongsToChannels provides a mock function with given fields: userId, channelIds
|
||||||
func (_m *ChannelStore) UserBelongsToChannels(userId string, channelIds []string) store.StoreChannel {
|
func (_m *ChannelStore) UserBelongsToChannels(userId string, channelIds []string) (bool, *model.AppError) {
|
||||||
ret := _m.Called(userId, channelIds)
|
ret := _m.Called(userId, channelIds)
|
||||||
|
|
||||||
var r0 store.StoreChannel
|
var r0 bool
|
||||||
if rf, ok := ret.Get(0).(func(string, []string) store.StoreChannel); ok {
|
if rf, ok := ret.Get(0).(func(string, []string) bool); ok {
|
||||||
r0 = rf(userId, channelIds)
|
r0 = rf(userId, channelIds)
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(0) != nil {
|
r0 = ret.Get(0).(bool)
|
||||||
r0 = ret.Get(0).(store.StoreChannel)
|
}
|
||||||
|
|
||||||
|
var r1 *model.AppError
|
||||||
|
if rf, ok := ret.Get(1).(func(string, []string) *model.AppError); ok {
|
||||||
|
r1 = rf(userId, channelIds)
|
||||||
|
} else {
|
||||||
|
if ret.Get(1) != nil {
|
||||||
|
r1 = ret.Get(1).(*model.AppError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return r0
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user