diff options
author | =Corey Hulen <corey@hulen.com> | 2015-09-23 12:49:28 -0700 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2015-09-23 12:49:28 -0700 |
commit | 1626a6de6f16ba0878160b0a7eae9f49b8d34d4f (patch) | |
tree | abc9088402a783c2e1908fb2db93ad84731827dd /store | |
parent | 9e04909c0a3672d27c148c931d82b225cc86dfe5 (diff) | |
download | chat-1626a6de6f16ba0878160b0a7eae9f49b8d34d4f.tar.gz chat-1626a6de6f16ba0878160b0a7eae9f49b8d34d4f.tar.bz2 chat-1626a6de6f16ba0878160b0a7eae9f49b8d34d4f.zip |
PLT-349 adding team mgt to admin console
Diffstat (limited to 'store')
-rw-r--r-- | store/sql_session_store.go | 18 | ||||
-rw-r--r-- | store/sql_session_store_test.go | 23 | ||||
-rw-r--r-- | store/sql_team_store.go | 4 | ||||
-rw-r--r-- | store/store.go | 3 |
4 files changed, 45 insertions, 3 deletions
diff --git a/store/sql_session_store.go b/store/sql_session_store.go index c1d2c852b..22411389d 100644 --- a/store/sql_session_store.go +++ b/store/sql_session_store.go @@ -140,6 +140,24 @@ func (me SqlSessionStore) Remove(sessionIdOrToken string) StoreChannel { return storeChannel } +func (me SqlSessionStore) RemoveAllSessionsForTeam(teamId string) StoreChannel { + storeChannel := make(StoreChannel) + + go func() { + result := StoreResult{} + + _, err := me.GetMaster().Exec("DELETE FROM Sessions WHERE TeamId = :TeamId", map[string]interface{}{"TeamId": teamId}) + if err != nil { + result.Err = model.NewAppError("SqlSessionStore.RemoveAllSessionsForTeam", "We couldn't remove all the sessions for the team", "id="+teamId+", err="+err.Error()) + } + + storeChannel <- result + close(storeChannel) + }() + + return storeChannel +} + func (me SqlSessionStore) CleanUpExpiredSessions(userId string) StoreChannel { storeChannel := make(StoreChannel) diff --git a/store/sql_session_store_test.go b/store/sql_session_store_test.go index 4ae680556..3d8aafe25 100644 --- a/store/sql_session_store_test.go +++ b/store/sql_session_store_test.go @@ -80,6 +80,29 @@ func TestSessionRemove(t *testing.T) { } } +func TestSessionRemoveAll(t *testing.T) { + Setup() + + s1 := model.Session{} + s1.UserId = model.NewId() + s1.TeamId = model.NewId() + Must(store.Session().Save(&s1)) + + if rs1 := (<-store.Session().Get(s1.Id)); rs1.Err != nil { + t.Fatal(rs1.Err) + } else { + if rs1.Data.(*model.Session).Id != s1.Id { + t.Fatal("should match") + } + } + + Must(store.Session().RemoveAllSessionsForTeam(s1.TeamId)) + + if rs2 := (<-store.Session().Get(s1.Id)); rs2.Err == nil { + t.Fatal("should have been removed") + } +} + func TestSessionRemoveToken(t *testing.T) { Setup() diff --git a/store/sql_team_store.go b/store/sql_team_store.go index 3d644e577..109fe5401 100644 --- a/store/sql_team_store.go +++ b/store/sql_team_store.go @@ -196,7 +196,7 @@ func (s SqlTeamStore) GetTeamsForEmail(email string) StoreChannel { return storeChannel } -func (s SqlTeamStore) GetForExport() StoreChannel { +func (s SqlTeamStore) GetAll() StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -204,7 +204,7 @@ func (s SqlTeamStore) GetForExport() StoreChannel { var data []*model.Team if _, err := s.GetReplica().Select(&data, "SELECT * FROM Teams"); err != nil { - result.Err = model.NewAppError("SqlTeamStore.GetForExport", "We could not get all teams", err.Error()) + result.Err = model.NewAppError("SqlTeamStore.GetAllTeams", "We could not get all teams", err.Error()) } result.Data = data diff --git a/store/store.go b/store/store.go index c9d40cfa5..7ba3e1d99 100644 --- a/store/store.go +++ b/store/store.go @@ -47,7 +47,7 @@ type TeamStore interface { Get(id string) StoreChannel GetByName(name string) StoreChannel GetTeamsForEmail(domain string) StoreChannel - GetForExport() StoreChannel + GetAll() StoreChannel } type ChannelStore interface { @@ -110,6 +110,7 @@ type SessionStore interface { Get(sessionIdOrToken string) StoreChannel GetSessions(userId string) StoreChannel Remove(sessionIdOrToken string) StoreChannel + RemoveAllSessionsForTeam(teamId string) StoreChannel UpdateLastActivityAt(sessionId string, time int64) StoreChannel UpdateRoles(userId string, roles string) StoreChannel } |