Migrate Channel.UserBelongsToChannels to Sync by default (#11269)
* Migrate Channel.UserBelongsToChannels to Sync by default * Address comments
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
242c4f2c66
Коммит
8853a71f0b
@@ -2634,26 +2634,22 @@ func (s SqlChannelStore) GetChannelsBatchForIndexing(startTime, endTime int64, l
|
||||
return channels, nil
|
||||
}
|
||||
|
||||
func (s SqlChannelStore) UserBelongsToChannels(userId string, channelIds []string) store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
query := s.getQueryBuilder().
|
||||
Select("Count(*)").
|
||||
From("ChannelMembers").
|
||||
Where(sq.And{
|
||||
sq.Eq{"UserId": userId},
|
||||
sq.Eq{"ChannelId": channelIds},
|
||||
})
|
||||
func (s SqlChannelStore) UserBelongsToChannels(userId string, channelIds []string) (bool, *model.AppError) {
|
||||
query := s.getQueryBuilder().
|
||||
Select("Count(*)").
|
||||
From("ChannelMembers").
|
||||
Where(sq.And{
|
||||
sq.Eq{"UserId": userId},
|
||||
sq.Eq{"ChannelId": channelIds},
|
||||
})
|
||||
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
result.Err = 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...)
|
||||
if err != nil {
|
||||
result.Err = model.NewAppError("SqlChannelStore.UserBelongsToChannels", "store.sql_channel.user_belongs_to_channels.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
result.Data = c > 0
|
||||
})
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
return false, model.NewAppError("SqlChannelStore.UserBelongsToChannels", "store.sql_channel.user_belongs_to_channels.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
c, err := s.GetReplica().SelectInt(queryString, args...)
|
||||
if err != nil {
|
||||
return false, model.NewAppError("SqlChannelStore.UserBelongsToChannels", "store.sql_channel.user_belongs_to_channels.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
return c > 0, nil
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user