From dc09b7781ac310646014f05db23844ab2c6d63f4 Mon Sep 17 00:00:00 2001 From: Dmitri Aizenberg Date: Wed, 31 Aug 2016 06:24:14 -0700 Subject: PLT-1527 Add a slash command to set yourself away (#3752) * added handlers for slash commands * added manual status persistance * added tests * removed extra debug output and comments * rebase - fixing the PR * making echo messages after slash commands ephemeral --- store/sql_status_store.go | 6 ++++++ store/sql_status_store_test.go | 11 ++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'store') diff --git a/store/sql_status_store.go b/store/sql_status_store.go index f5259c212..99d89f0d5 100644 --- a/store/sql_status_store.go +++ b/store/sql_status_store.go @@ -5,6 +5,7 @@ package store import ( "database/sql" + "github.com/mattermost/platform/model" ) @@ -22,12 +23,17 @@ func NewSqlStatusStore(sqlStore *SqlStore) StatusStore { for _, db := range sqlStore.GetAllConns() { table := db.AddTableWithName(model.Status{}, "Status").SetKeys(false, "UserId") table.ColMap("UserId").SetMaxSize(26) + table.ColMap("Manual") table.ColMap("Status").SetMaxSize(32) } return s } +func (s SqlStatusStore) UpgradeSchemaIfNeeded() { + s.CreateColumnIfNotExists("Status", "Manual", "BOOLEAN", "BOOLEAN", "0") +} + func (s SqlStatusStore) CreateIndexesIfNotExists() { s.CreateIndexIfNotExists("idx_status_user_id", "Status", "UserId") s.CreateIndexIfNotExists("idx_status_status", "Status", "Status") diff --git a/store/sql_status_store_test.go b/store/sql_status_store_test.go index 139915bad..52759a4b1 100644 --- a/store/sql_status_store_test.go +++ b/store/sql_status_store_test.go @@ -4,14 +4,15 @@ package store import ( - "github.com/mattermost/platform/model" "testing" + + "github.com/mattermost/platform/model" ) func TestSqlStatusStore(t *testing.T) { Setup() - status := &model.Status{model.NewId(), model.STATUS_ONLINE, 0} + status := &model.Status{model.NewId(), model.STATUS_ONLINE, false, 0} if err := (<-store.Status().SaveOrUpdate(status)).Err; err != nil { t.Fatal(err) @@ -27,12 +28,12 @@ func TestSqlStatusStore(t *testing.T) { t.Fatal(err) } - status2 := &model.Status{model.NewId(), model.STATUS_AWAY, 0} + status2 := &model.Status{model.NewId(), model.STATUS_AWAY, false, 0} if err := (<-store.Status().SaveOrUpdate(status2)).Err; err != nil { t.Fatal(err) } - status3 := &model.Status{model.NewId(), model.STATUS_OFFLINE, 0} + status3 := &model.Status{model.NewId(), model.STATUS_OFFLINE, false, 0} if err := (<-store.Status().SaveOrUpdate(status3)).Err; err != nil { t.Fatal(err) } @@ -80,7 +81,7 @@ func TestSqlStatusStore(t *testing.T) { func TestActiveUserCount(t *testing.T) { Setup() - status := &model.Status{model.NewId(), model.STATUS_ONLINE, model.GetMillis()} + status := &model.Status{model.NewId(), model.STATUS_ONLINE, false, model.GetMillis()} Must(store.Status().SaveOrUpdate(status)) if result := <-store.Status().GetTotalActiveUsersCount(); result.Err != nil { -- cgit v1.2.3-1-g7c22