diff options
Diffstat (limited to 'store')
-rw-r--r-- | store/sql_channel_store.go | 17 | ||||
-rw-r--r-- | store/store.go | 3 |
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 |