summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-12-06 10:49:34 -0500
committerGitHub <noreply@github.com>2016-12-06 10:49:34 -0500
commit026553e4f87bfc647a5c03129752e30fc523fa07 (patch)
treed5403c760151c0fa26fc6d020f7f4326ea9d6f8a /store
parentdcf11a14d8363c79ab62aefca46834d6daa615ab (diff)
downloadchat-026553e4f87bfc647a5c03129752e30fc523fa07.tar.gz
chat-026553e4f87bfc647a5c03129752e30fc523fa07.tar.bz2
chat-026553e4f87bfc647a5c03129752e30fc523fa07.zip
Improving command line interface (#4689)
Diffstat (limited to 'store')
-rw-r--r--store/sql_channel_store.go17
-rw-r--r--store/store.go3
2 files changed, 18 insertions, 2 deletions
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go
index 89fb8c409..e6b7b80bf 100644
--- a/store/sql_channel_store.go
+++ b/store/sql_channel_store.go
@@ -502,14 +502,29 @@ func (s SqlChannelStore) GetTeamChannels(teamId string) StoreChannel {
}
func (s SqlChannelStore) GetByName(teamId string, name string) StoreChannel {
+ return s.getByName(teamId, name, false)
+}
+
+func (s SqlChannelStore) GetByNameIncludeDeleted(teamId string, name string) StoreChannel {
+ return s.getByName(teamId, name, true)
+}
+
+func (s SqlChannelStore) getByName(teamId string, name string, includeDeleted bool) StoreChannel {
storeChannel := make(StoreChannel, 1)
+ var query string
+ if includeDeleted {
+ query = "SELECT * FROM Channels WHERE (TeamId = :TeamId OR TeamId = '') AND Name = :Name"
+ } else {
+ query = "SELECT * FROM Channels WHERE (TeamId = :TeamId OR TeamId = '') AND Name = :Name AND DeleteAt = 0"
+ }
+
go func() {
result := StoreResult{}
channel := model.Channel{}
- if err := s.GetReplica().SelectOne(&channel, "SELECT * FROM Channels WHERE (TeamId = :TeamId OR TeamId = '') AND Name = :Name AND DeleteAt = 0", map[string]interface{}{"TeamId": teamId, "Name": name}); err != nil {
+ if err := s.GetReplica().SelectOne(&channel, query, map[string]interface{}{"TeamId": teamId, "Name": name}); err != nil {
if err == sql.ErrNoRows {
result.Err = model.NewLocAppError("SqlChannelStore.GetByName", MISSING_CHANNEL_ERROR, nil, "teamId="+teamId+", "+"name="+name+", "+err.Error())
} else {
diff --git a/store/store.go b/store/store.go
index 7602be8f4..0f9b20ed8 100644
--- a/store/store.go
+++ b/store/store.go
@@ -89,7 +89,8 @@ type ChannelStore interface {
Delete(channelId string, time int64) StoreChannel
SetDeleteAt(channelId string, deleteAt int64, updateAt int64) StoreChannel
PermanentDeleteByTeam(teamId string) StoreChannel
- GetByName(team_id string, domain string) StoreChannel
+ GetByName(team_id string, name string) StoreChannel
+ GetByNameIncludeDeleted(team_id string, name string) StoreChannel
GetChannels(teamId string, userId string) StoreChannel
GetMoreChannels(teamId string, userId string, offset int, limit int) StoreChannel
GetChannelCounts(teamId string, userId string) StoreChannel