Merge remote-tracking branch 'origin/master' into advanced-permissions-phase-2

Этот коммит содержится в:
Martin Kraft
2018-05-15 07:45:28 -04:00
родитель 51bd710ecd a1656dffa9
Коммит f82cc7896d
29 изменённых файлов: 1307 добавлений и 909 удалений

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

@@ -466,25 +466,6 @@ func (s SqlChannelStore) Update(channel *model.Channel) store.StoreChannel {
})
}
func (s SqlChannelStore) extraUpdated(channel *model.Channel) store.StoreChannel {
return store.Do(func(result *store.StoreResult) {
channel.ExtraUpdated()
_, err := s.GetMaster().Exec(
`UPDATE
Channels
SET
ExtraUpdateAt = :Time
WHERE
Id = :Id`,
map[string]interface{}{"Id": channel.Id, "Time": channel.ExtraUpdateAt})
if err != nil {
result.Err = model.NewAppError("SqlChannelStore.extraUpdated", "store.sql_channel.extra_updated.app_error", nil, "id="+channel.Id+", "+err.Error(), http.StatusInternalServerError)
}
})
}
func (s SqlChannelStore) GetChannelUnread(channelId, userId string) store.StoreChannel {
return store.Do(func(result *store.StoreResult) {
var unreadChannel model.ChannelUnread
@@ -1313,21 +1294,9 @@ func (s SqlChannelStore) GetMemberCount(channelId string, allowFromCache bool) s
func (s SqlChannelStore) RemoveMember(channelId string, userId string) store.StoreChannel {
return store.Do(func(result *store.StoreResult) {
// Grab the channel we are saving this member to
if cr := <-s.Get(channelId, true); cr.Err != nil {
result.Err = cr.Err
} else {
channel := cr.Data.(*model.Channel)
_, err := s.GetMaster().Exec("DELETE FROM ChannelMembers WHERE ChannelId = :ChannelId AND UserId = :UserId", map[string]interface{}{"ChannelId": channelId, "UserId": userId})
if err != nil {
result.Err = model.NewAppError("SqlChannelStore.RemoveMember", "store.sql_channel.remove_member.app_error", nil, "channel_id="+channelId+", user_id="+userId+", "+err.Error(), http.StatusInternalServerError)
} else {
// If successfull record members have changed in channel
if mu := <-s.extraUpdated(channel); mu.Err != nil {
result.Err = mu.Err
}
}
_, err := s.GetMaster().Exec("DELETE FROM ChannelMembers WHERE ChannelId = :ChannelId AND UserId = :UserId", map[string]interface{}{"ChannelId": channelId, "UserId": userId})
if err != nil {
result.Err = model.NewAppError("SqlChannelStore.RemoveMember", "store.sql_channel.remove_member.app_error", nil, "channel_id="+channelId+", user_id="+userId+", "+err.Error(), http.StatusInternalServerError)
}
})
}