diff options
author | George Goldberg <george@gberg.me> | 2017-10-04 19:08:59 +0100 |
---|---|---|
committer | Chris <ccbrown112@gmail.com> | 2017-10-04 11:08:59 -0700 |
commit | f3fc6d11fa11c9b8c73554c79ca55470073bb098 (patch) | |
tree | 1c0fa5181315bf2da312f7c832ae16f360d43d16 /store/sqlstore/command_store.go | |
parent | e16bdf8d1d4d2972be4e89cbc9c4dbef134895ba (diff) | |
download | chat-f3fc6d11fa11c9b8c73554c79ca55470073bb098.tar.gz chat-f3fc6d11fa11c9b8c73554c79ca55470073bb098.tar.bz2 chat-f3fc6d11fa11c9b8c73554c79ca55470073bb098.zip |
PLT-7218: CLI to move slash commands between teams. (#7574)
Diffstat (limited to 'store/sqlstore/command_store.go')
-rw-r--r-- | store/sqlstore/command_store.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/store/sqlstore/command_store.go b/store/sqlstore/command_store.go index f156daab1..8284f889b 100644 --- a/store/sqlstore/command_store.go +++ b/store/sqlstore/command_store.go @@ -119,6 +119,27 @@ func (s SqlCommandStore) GetByTeam(teamId string) store.StoreChannel { return storeChannel } +func (s SqlCommandStore) GetByTrigger(teamId string, trigger string) store.StoreChannel { + storeChannel := make(store.StoreChannel, 1) + + go func() { + result := store.StoreResult{} + + var command model.Command + + if err := s.GetReplica().SelectOne(&command, "SELECT * FROM Commands WHERE TeamId = :TeamId AND `Trigger` = :Trigger AND DeleteAt = 0", map[string]interface{}{"TeamId": teamId, "Trigger": trigger}); err != nil { + result.Err = model.NewAppError("SqlCommandStore.GetByTrigger", "store.sql_command.get_by_trigger.app_error", nil, "teamId="+teamId+", trigger="+trigger+", err="+err.Error(), http.StatusInternalServerError) + } + + result.Data = &command + + storeChannel <- result + close(storeChannel) + }() + + return storeChannel +} + func (s SqlCommandStore) Delete(commandId string, time int64) store.StoreChannel { storeChannel := make(store.StoreChannel, 1) |