summaryrefslogtreecommitdiffstats
path: root/app/channel.go
diff options
context:
space:
mode:
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) {