summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
authorSaturnino Abril <saturnino.abril@gmail.com>2017-08-01 20:16:45 +0800
committerJoram Wilander <jwawilander@gmail.com>2017-08-01 08:16:45 -0400
commit88f398ffddbcbb58265d085c09cb72008be3f3d5 (patch)
tree6db22e220a781a144808e113505ce040c7e2eac7 /store
parentb023b891550cd8fb2f874e822f05921d13f51fb2 (diff)
downloadchat-88f398ffddbcbb58265d085c09cb72008be3f3d5.tar.gz
chat-88f398ffddbcbb58265d085c09cb72008be3f3d5.tar.bz2
chat-88f398ffddbcbb58265d085c09cb72008be3f3d5.zip
Revert " #4755 Combining consecutive user join/leave system messages to single message and few other changes." (#7072)
* Revert "PLT-6603: Don't return all posts on invalid query. (#7061)" This reverts commit 25a2013890c7e07b4621fa9b18342e7f35363049. * Revert " #4755 Combining consecutive user join/leave system messages to single message and few other changes. (#5945)" This reverts commit 8a91235fb3cdc8d094dbc2eaa0d7baa447132b3c.
Diffstat (limited to 'store')
-rw-r--r--store/sql_post_store.go29
-rw-r--r--store/sql_post_store_test.go34
-rw-r--r--store/store.go1
3 files changed, 2 insertions, 62 deletions
diff --git a/store/sql_post_store.go b/store/sql_post_store.go
index c66e44274..e89b5e042 100644
--- a/store/sql_post_store.go
+++ b/store/sql_post_store.go
@@ -97,7 +97,8 @@ func (s SqlPostStore) Save(post *model.Post) StoreChannel {
} else {
time := post.UpdateAt
- if !post.IsUserActivitySystemMessage() {
+ if post.Type != model.POST_JOIN_LEAVE && post.Type != model.POST_JOIN_CHANNEL && post.Type != model.POST_LEAVE_CHANNEL &&
+ post.Type != model.POST_ADD_REMOVE && post.Type != model.POST_ADD_TO_CHANNEL && post.Type != model.POST_REMOVE_FROM_CHANNEL {
s.GetMaster().Exec("UPDATE Channels SET LastPostAt = :LastPostAt, TotalMsgCount = TotalMsgCount + 1 WHERE Id = :ChannelId", map[string]interface{}{"LastPostAt": time, "ChannelId": post.ChannelId})
} else {
// don't update TotalMsgCount for unimportant messages so that the channel isn't marked as unread
@@ -1354,29 +1355,3 @@ func (s SqlPostStore) GetPostsBatchForIndexing(startTime int64, limit int) Store
return storeChannel
}
-
-func (s SqlPostStore) GetLastPostForChannel(channelId string) StoreChannel {
- storeChannel := make(StoreChannel, 1)
-
- go func() {
- result := StoreResult{}
-
- var post model.Post
- query := `
- SELECT * FROM Posts
- WHERE ChannelId = :channelId AND DeleteAt = 0
- ORDER BY CreateAt DESC
- LIMIT 1
- `
-
- if err := s.GetReplica().SelectOne(&post, query, map[string]interface{}{"channelId": channelId}); err != nil {
- l4g.Error(err)
- }
-
- result.Data = &post
- storeChannel <- result
- close(storeChannel)
- }()
-
- return storeChannel
-}
diff --git a/store/sql_post_store_test.go b/store/sql_post_store_test.go
index 761e0dcdf..27e816996 100644
--- a/store/sql_post_store_test.go
+++ b/store/sql_post_store_test.go
@@ -1661,37 +1661,3 @@ func TestPostStoreGetPostsBatchForIndexing(t *testing.T) {
}
}
}
-
-func TestGetLastPostForChannel(t *testing.T) {
- Setup()
-
- o1 := &model.Post{}
- o1.ChannelId = model.NewId()
- o1.UserId = model.NewId()
- o1.Message = ""
- o1.Type = model.POST_JOIN_CHANNEL
-
- o1 = (<-store.Post().Save(o1)).Data.(*model.Post)
-
- if r1 := <-store.Post().GetLastPostForChannel(o1.ChannelId); r1.Err != nil {
- t.Fatal(r1.Err)
- } else {
- if r1.Data.(*model.Post).Id != o1.Id {
- t.Fatal("invalid returned post")
- }
- }
-
- o2 := &model.Post{}
- o2.ChannelId = o1.ChannelId
- o2.UserId = model.NewId()
- o2.Message = ""
-
- o2 = (<-store.Post().Save(o2)).Data.(*model.Post)
- if r2 := <-store.Post().GetLastPostForChannel(o2.ChannelId); r2.Err != nil {
- t.Fatal(r2.Err)
- } else {
- if r2.Data.(*model.Post).Id != o2.Id {
- t.Fatal("invalid returned post")
- }
- }
-}
diff --git a/store/store.go b/store/store.go
index 9824ec213..d883ea5a2 100644
--- a/store/store.go
+++ b/store/store.go
@@ -170,7 +170,6 @@ type PostStore interface {
Overwrite(post *model.Post) StoreChannel
GetPostsByIds(postIds []string) StoreChannel
GetPostsBatchForIndexing(startTime int64, limit int) StoreChannel
- GetLastPostForChannel(channelId string) StoreChannel
}
type UserStore interface {