Update channel patch to post the correct system messages (#6290)

Этот коммит содержится в:
Joram Wilander
2017-05-03 11:52:36 -04:00
коммит произвёл Corey Hulen
родитель 63b84ce2da
Коммит 88a328421f
2 изменённых файлов: 30 добавлений и 3 удалений

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

@@ -170,7 +170,7 @@ func patchChannel(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
if rchannel, err := app.PatchChannel(oldChannel, patch); err != nil {
if rchannel, err := app.PatchChannel(oldChannel, patch, c.Session.UserId); err != nil {
c.Err = err
return
} else {

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

@@ -281,9 +281,36 @@ func UpdateChannel(channel *model.Channel) (*model.Channel, *model.AppError) {
}
}
func PatchChannel(channel *model.Channel, patch *model.ChannelPatch) (*model.Channel, *model.AppError) {
func PatchChannel(channel *model.Channel, patch *model.ChannelPatch, userId string) (*model.Channel, *model.AppError) {
oldChannelDisplayName := channel.DisplayName
oldChannelHeader := channel.Header
oldChannelPurpose := channel.Purpose
channel.Patch(patch)
return UpdateChannel(channel)
channel, err := UpdateChannel(channel)
if err != nil {
return nil, err
}
if oldChannelDisplayName != channel.DisplayName {
if err := PostUpdateChannelDisplayNameMessage(userId, channel.Id, channel.TeamId, oldChannelDisplayName, channel.DisplayName); err != nil {
l4g.Error(err.Error())
}
}
if channel.Header != oldChannelHeader {
if err := PostUpdateChannelHeaderMessage(userId, channel.Id, channel.TeamId, oldChannelHeader, channel.Header); err != nil {
l4g.Error(err.Error())
}
}
if channel.Purpose != oldChannelPurpose {
if err := PostUpdateChannelPurposeMessage(userId, channel.Id, channel.TeamId, oldChannelPurpose, channel.Purpose); err != nil {
l4g.Error(err.Error())
}
}
return channel, err
}
func UpdateChannelMemberRoles(channelId string, userId string, newRoles string) (*model.ChannelMember, *model.AppError) {