diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-04-11 13:45:03 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-04-11 13:45:03 -0400 |
commit | 49ab8b216191749bd39694d79f687a84ad24adf0 (patch) | |
tree | 27b4966d437b15ddcd8d420b8a1afc1881455c13 /store | |
parent | 5b96ad59c502d435dbca95950c4590a575b2c5b9 (diff) | |
download | chat-49ab8b216191749bd39694d79f687a84ad24adf0.tar.gz chat-49ab8b216191749bd39694d79f687a84ad24adf0.tar.bz2 chat-49ab8b216191749bd39694d79f687a84ad24adf0.zip |
Add custom branding functionality (#2667)
Diffstat (limited to 'store')
-rw-r--r-- | store/sql_system_store.go | 21 | ||||
-rw-r--r-- | store/sql_system_store_test.go | 6 | ||||
-rw-r--r-- | store/store.go | 1 |
3 files changed, 28 insertions, 0 deletions
diff --git a/store/sql_system_store.go b/store/sql_system_store.go index f8da06cec..a2b4f6396 100644 --- a/store/sql_system_store.go +++ b/store/sql_system_store.go @@ -114,3 +114,24 @@ func (s SqlSystemStore) Get() StoreChannel { return storeChannel } + +func (s SqlSystemStore) GetByName(name string) StoreChannel { + + storeChannel := make(StoreChannel) + + go func() { + result := StoreResult{} + + var system model.System + if err := s.GetReplica().SelectOne(&system, "SELECT * FROM Systems WHERE Name = :Name", map[string]interface{}{"Name": name}); err != nil { + result.Err = model.NewLocAppError("SqlSystemStore.GetByName", "store.sql_system.get_by_name.app_error", nil, "") + } + + result.Data = &system + + storeChannel <- result + close(storeChannel) + }() + + return storeChannel +} diff --git a/store/sql_system_store_test.go b/store/sql_system_store_test.go index ce149e97a..74e2876ad 100644 --- a/store/sql_system_store_test.go +++ b/store/sql_system_store_test.go @@ -30,6 +30,12 @@ func TestSqlSystemStore(t *testing.T) { if systems2[system.Name] != system.Value { t.Fatal() } + + result3 := <-store.System().GetByName(system.Name) + rsystem := result3.Data.(*model.System) + if rsystem.Value != system.Value { + t.Fatal() + } } func TestSqlSystemStoreSaveOrUpdate(t *testing.T) { diff --git a/store/store.go b/store/store.go index 323595ffb..4a4fa1481 100644 --- a/store/store.go +++ b/store/store.go @@ -184,6 +184,7 @@ type SystemStore interface { SaveOrUpdate(system *model.System) StoreChannel Update(system *model.System) StoreChannel Get() StoreChannel + GetByName(name string) StoreChannel } type WebhookStore interface { |