diff options
-rw-r--r-- | i18n/en.json | 4 | ||||
-rw-r--r-- | store/sqlstore/channel_store.go | 5 | ||||
-rw-r--r-- | store/storetest/channel_store.go | 6 |
3 files changed, 15 insertions, 0 deletions
diff --git a/i18n/en.json b/i18n/en.json index a0733827a..5345fa0cf 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -5007,6 +5007,10 @@ "translation": "We couldn't update the channel" }, { + "id": "store.sql_channel.update.archived_channel.app_error", + "translation": "You can not modify an archived channel" + }, + { "id": "store.sql_channel.update.exists.app_error", "translation": "A channel with that handle already exists" }, diff --git a/store/sqlstore/channel_store.go b/store/sqlstore/channel_store.go index 6d0c7353f..fba37d7cb 100644 --- a/store/sqlstore/channel_store.go +++ b/store/sqlstore/channel_store.go @@ -463,6 +463,11 @@ func (s SqlChannelStore) Update(channel *model.Channel) store.StoreChannel { return store.Do(func(result *store.StoreResult) { channel.PreUpdate() + if channel.DeleteAt != 0 { + result.Err = model.NewAppError("SqlChannelStore.Update", "store.sql_channel.update.archived_channel.app_error", nil, "", http.StatusBadRequest) + return + } + if result.Err = channel.IsValid(); result.Err != nil { return } diff --git a/store/storetest/channel_store.go b/store/storetest/channel_store.go index e2f91e0c9..c827a4226 100644 --- a/store/storetest/channel_store.go +++ b/store/storetest/channel_store.go @@ -220,6 +220,12 @@ func testChannelStoreUpdate(t *testing.T, ss store.Store) { t.Fatal(err) } + o1.DeleteAt = 100 + if err := (<-ss.Channel().Update(&o1)).Err; err == nil { + t.Fatal("Update should have failed because channel is archived") + } + + o1.DeleteAt = 0 o1.Id = "missing" if err := (<-ss.Channel().Update(&o1)).Err; err == nil { t.Fatal("Update should have failed because of missing key") |