summaryrefslogtreecommitdiffstats
path: root/app/channel.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-05-03 11:52:36 -0400
committerCorey Hulen <corey@hulen.com>2017-05-03 08:52:36 -0700
commit88a328421fbfc2db2a1747da955deea68e86da2a (patch)
tree132bb987bd2c3f392d5537cdde821dce5ec8e823 /app/channel.go
parent63b84ce2dad5f5f9cd291dc85c529f56c3aa6d4b (diff)
downloadchat-88a328421fbfc2db2a1747da955deea68e86da2a.tar.gz
chat-88a328421fbfc2db2a1747da955deea68e86da2a.tar.bz2
chat-88a328421fbfc2db2a1747da955deea68e86da2a.zip
Update channel patch to post the correct system messages (#6290)
Diffstat (limited to 'app/channel.go')
-rw-r--r--app/channel.go31
1 files changed, 29 insertions, 2 deletions
diff --git a/app/channel.go b/app/channel.go
index 0d9cb5a94..ee53ace45 100644
--- a/app/channel.go
+++ b/app/channel.go
@@ -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) {