diff options
author | Corey Hulen <corey@hulen.com> | 2015-07-07 23:12:08 -0800 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2015-07-07 23:12:08 -0800 |
commit | f6e8b4f310fdfee13326854acb2443f5b65d1022 (patch) | |
tree | 9415b03eb156654269171e2c124a2ab6620b85ba /store | |
parent | 817d9110b39c0b39e798f8efa83c47a22eaac0c3 (diff) | |
parent | f839b6349645ad2dc021425a806f20243d15ed0d (diff) | |
download | chat-f6e8b4f310fdfee13326854acb2443f5b65d1022.tar.gz chat-f6e8b4f310fdfee13326854acb2443f5b65d1022.tar.bz2 chat-f6e8b4f310fdfee13326854acb2443f5b65d1022.zip |
Merge pull request #143 from rgarmsen2295/mm-1416
MM-1416 Changed error message when adding a previously deleted channel to be better suited
Diffstat (limited to 'store')
-rw-r--r-- | store/sql_channel_store.go | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go index 463fce16f..d61fbcdd0 100644 --- a/store/sql_channel_store.go +++ b/store/sql_channel_store.go @@ -79,7 +79,13 @@ func (s SqlChannelStore) Save(channel *model.Channel) StoreChannel { if err := s.GetMaster().Insert(channel); err != nil { if strings.Contains(err.Error(), "Duplicate entry") && strings.Contains(err.Error(), "for key 'Name'") { - result.Err = model.NewAppError("SqlChannelStore.Save", "A channel with that name already exists", "id="+channel.Id+", "+err.Error()) + dupChannel := model.Channel{} + s.GetReplica().SelectOne(&dupChannel, "SELECT * FROM Channels WHERE TeamId=? AND Name=? AND DeleteAt > 0", channel.TeamId, channel.Name) + if (dupChannel.DeleteAt > 0) { + result.Err = model.NewAppError("SqlChannelStore.Update", "A channel with that name was previously created", "id="+channel.Id+", "+err.Error()) + } else { + result.Err = model.NewAppError("SqlChannelStore.Update", "A channel with that name already exists", "id="+channel.Id+", "+err.Error()) + } } else { result.Err = model.NewAppError("SqlChannelStore.Save", "We couldn't save the channel", "id="+channel.Id+", "+err.Error()) } @@ -111,7 +117,13 @@ func (s SqlChannelStore) Update(channel *model.Channel) StoreChannel { if count, err := s.GetMaster().Update(channel); err != nil { if strings.Contains(err.Error(), "Duplicate entry") && strings.Contains(err.Error(), "for key 'Name'") { - result.Err = model.NewAppError("SqlChannelStore.Update", "A channel with that name already exists", "id="+channel.Id+", "+err.Error()) + dupChannel := model.Channel{} + s.GetReplica().SelectOne(&dupChannel, "SELECT * FROM Channels WHERE TeamId=? AND Name=? AND DeleteAt > 0", channel.TeamId, channel.Name) + if (dupChannel.DeleteAt > 0) { + result.Err = model.NewAppError("SqlChannelStore.Update", "A channel with that name was previously created", "id="+channel.Id+", "+err.Error()) + } else { + result.Err = model.NewAppError("SqlChannelStore.Update", "A channel with that name already exists", "id="+channel.Id+", "+err.Error()) + } } else { result.Err = model.NewAppError("SqlChannelStore.Update", "We encounted an error updating the channel", "id="+channel.Id+", "+err.Error()) } |