summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
Diffstat (limited to 'store')
-rw-r--r--store/sql_post_store.go1
-rw-r--r--store/sql_post_store_test.go7
-rw-r--r--store/sql_session_store.go18
-rw-r--r--store/sql_session_store_test.go22
-rw-r--r--store/store.go1
5 files changed, 49 insertions, 0 deletions
diff --git a/store/sql_post_store.go b/store/sql_post_store.go
index a2b18a163..2d5d66e0d 100644
--- a/store/sql_post_store.go
+++ b/store/sql_post_store.go
@@ -642,6 +642,7 @@ func (s SqlPostStore) Search(teamId string, userId string, params *model.SearchP
Posts
WHERE
DeleteAt = 0
+ AND Type NOT LIKE '` + model.POST_SYSTEM_MESSAGE_PREFIX + `%'
POST_FILTER
AND ChannelId IN (
SELECT
diff --git a/store/sql_post_store_test.go b/store/sql_post_store_test.go
index a3e3e10dd..46b8d7678 100644
--- a/store/sql_post_store_test.go
+++ b/store/sql_post_store_test.go
@@ -676,6 +676,13 @@ func TestPostStoreSearch(t *testing.T) {
o1.Message = "corey mattermost new york"
o1 = (<-store.Post().Save(o1)).Data.(*model.Post)
+ o1a := &model.Post{}
+ o1a.ChannelId = c1.Id
+ o1a.UserId = model.NewId()
+ o1a.Message = "corey mattermost new york"
+ o1a.Type = model.POST_JOIN_LEAVE
+ o1a = (<-store.Post().Save(o1a)).Data.(*model.Post)
+
o2 := &model.Post{}
o2.ChannelId = c1.Id
o2.UserId = model.NewId()
diff --git a/store/sql_session_store.go b/store/sql_session_store.go
index 4762a1dfd..6532947f4 100644
--- a/store/sql_session_store.go
+++ b/store/sql_session_store.go
@@ -232,3 +232,21 @@ func (me SqlSessionStore) UpdateRoles(userId, roles string) StoreChannel {
return storeChannel
}
+
+func (me SqlSessionStore) UpdateDeviceId(id, deviceId string) StoreChannel {
+ storeChannel := make(StoreChannel)
+
+ go func() {
+ result := StoreResult{}
+ if _, err := me.GetMaster().Exec("UPDATE Sessions SET DeviceId = :DeviceId WHERE Id = :Id", map[string]interface{}{"DeviceId": deviceId, "Id": id}); err != nil {
+ result.Err = model.NewLocAppError("SqlSessionStore.UpdateDeviceId", "store.sql_session.update_device_id.app_error", nil, "")
+ } else {
+ result.Data = deviceId
+ }
+
+ storeChannel <- result
+ close(storeChannel)
+ }()
+
+ return storeChannel
+}
diff --git a/store/sql_session_store_test.go b/store/sql_session_store_test.go
index cec8e93b0..34d3128a6 100644
--- a/store/sql_session_store_test.go
+++ b/store/sql_session_store_test.go
@@ -157,6 +157,28 @@ func TestSessionRemoveToken(t *testing.T) {
}
}
+func TestSessionUpdateDeviceId(t *testing.T) {
+ Setup()
+
+ s1 := model.Session{}
+ s1.UserId = model.NewId()
+ s1.TeamId = model.NewId()
+ Must(store.Session().Save(&s1))
+
+ if rs1 := (<-store.Session().UpdateDeviceId(s1.Id, model.PUSH_NOTIFY_APPLE+":1234567890")); rs1.Err != nil {
+ t.Fatal(rs1.Err)
+ }
+
+ s2 := model.Session{}
+ s2.UserId = model.NewId()
+ s2.TeamId = model.NewId()
+ Must(store.Session().Save(&s2))
+
+ if rs2 := (<-store.Session().UpdateDeviceId(s2.Id, model.PUSH_NOTIFY_APPLE+":1234567890")); rs2.Err != nil {
+ t.Fatal(rs2.Err)
+ }
+}
+
func TestSessionStoreUpdateLastActivityAt(t *testing.T) {
Setup()
diff --git a/store/store.go b/store/store.go
index b91b08f27..3988f0c6a 100644
--- a/store/store.go
+++ b/store/store.go
@@ -137,6 +137,7 @@ type SessionStore interface {
PermanentDeleteSessionsByUser(teamId string) StoreChannel
UpdateLastActivityAt(sessionId string, time int64) StoreChannel
UpdateRoles(userId string, roles string) StoreChannel
+ UpdateDeviceId(id string, deviceId string) StoreChannel
}
type AuditStore interface {