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 25a2013890.

* Revert " #4755 Combining consecutive user join/leave system messages to single message and few other changes. (#5945)"

This reverts commit 8a91235fb3.
Этот коммит содержится в:
Saturnino Abril
2017-08-01 20:16:45 +08:00
коммит произвёл Joram Wilander
родитель b023b89155
Коммит 88f398ffdd
14 изменённых файлов: 66 добавлений и 574 удалений

Просмотреть файл

@@ -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
}