summaryrefslogtreecommitdiffstats
path: root/store/sql_channel_store.go
diff options
context:
space:
mode:
Diffstat (limited to 'store/sql_channel_store.go')
-rw-r--r--store/sql_channel_store.go17
1 files changed, 16 insertions, 1 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 {