summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2015-11-16 15:26:09 -0500
committerHarrison Healey <harrisonmhealey@gmail.com>2015-11-16 15:26:09 -0500
commit51f59ec869415e6a4c8eeff0e29d14854f1ad434 (patch)
tree54cda34559e7dd2b053311d329c216c0d8505d51 /api
parent48d2f86b90b3e0b02cb28f3e8b6e4d454f9cb869 (diff)
parent1874a16666cdcf65b11f2d0f03d50d6b880e15f7 (diff)
downloadchat-51f59ec869415e6a4c8eeff0e29d14854f1ad434.tar.gz
chat-51f59ec869415e6a4c8eeff0e29d14854f1ad434.tar.bz2
chat-51f59ec869415e6a4c8eeff0e29d14854f1ad434.zip
Merge pull request #1437 from rgarmsen2295/plt-1086
PLT-1086 Enables the ability to rename the default channel (Town Square)
Diffstat (limited to 'api')
-rw-r--r--api/channel.go8
-rw-r--r--api/channel_test.go3
2 files changed, 7 insertions, 4 deletions
diff --git a/api/channel.go b/api/channel.go
index 75ca9680d..99640e71a 100644
--- a/api/channel.go
+++ b/api/channel.go
@@ -205,9 +205,11 @@ func updateChannel(c *Context, w http.ResponseWriter, r *http.Request) {
}
if oldChannel.Name == model.DEFAULT_CHANNEL {
- c.Err = model.NewAppError("updateChannel", "Cannot update the default channel "+model.DEFAULT_CHANNEL, "")
- c.Err.StatusCode = http.StatusForbidden
- return
+ if (len(channel.Name) > 0 && channel.Name != oldChannel.Name) || (len(channel.Type) > 0 && channel.Type != oldChannel.Type) {
+ c.Err = model.NewAppError("updateChannel", "Tried to perform an invalid update of the default channel "+model.DEFAULT_CHANNEL, "")
+ c.Err.StatusCode = http.StatusForbidden
+ return
+ }
}
oldChannel.Header = channel.Header
diff --git a/api/channel_test.go b/api/channel_test.go
index faed387dd..e7e1f4eb0 100644
--- a/api/channel_test.go
+++ b/api/channel_test.go
@@ -215,8 +215,9 @@ func TestUpdateChannel(t *testing.T) {
for _, c := range data.Channels {
if c.Name == model.DEFAULT_CHANNEL {
c.Header = "new header"
+ c.Name = "pseudo-square"
if _, err := Client.UpdateChannel(c); err == nil {
- t.Fatal("should have errored on updating default channel")
+ t.Fatal("should have errored on updating default channel name")
}
break
}