summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2015-07-07 11:00:29 -0400
committerhmhealey <harrisonmhealey@gmail.com>2015-07-07 11:00:29 -0400
commit23e527978ed3e889bebe5c879de2d4835509626a (patch)
tree7534d89f2c8964cba7aa2c21d29dd066de15f6e1 /store
parent3dec509899f60ca0d2eadfcc192ccc49969852ef (diff)
downloadchat-23e527978ed3e889bebe5c879de2d4835509626a.tar.gz
chat-23e527978ed3e889bebe5c879de2d4835509626a.tar.bz2
chat-23e527978ed3e889bebe5c879de2d4835509626a.zip
Add a post type for user joined/left messages and don't flag a channel as unread when one of those is automatically posted
Diffstat (limited to 'store')
-rw-r--r--store/sql_post_store.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/store/sql_post_store.go b/store/sql_post_store.go
index 01900023f..7ada515d7 100644
--- a/store/sql_post_store.go
+++ b/store/sql_post_store.go
@@ -72,7 +72,13 @@ func (s SqlPostStore) Save(post *model.Post) StoreChannel {
result.Err = model.NewAppError("SqlPostStore.Save", "We couldn't save the Post", "id="+post.Id+", "+err.Error())
} else {
time := model.GetMillis()
- s.GetMaster().Exec("UPDATE Channels SET LastPostAt = ?, TotalMsgCount = TotalMsgCount + 1 WHERE Id = ?", time, post.ChannelId)
+
+ if post.Type != model.POST_JOIN_LEAVE {
+ s.GetMaster().Exec("UPDATE Channels SET LastPostAt = ?, TotalMsgCount = TotalMsgCount + 1 WHERE Id = ?", time, post.ChannelId)
+ } else {
+ // don't update TotalMsgCount for unimportant messages so that the channel isn't marked as unread
+ s.GetMaster().Exec("UPDATE Channels SET LastPostAt = ? WHERE Id = ?", time, post.ChannelId)
+ }
if len(post.RootId) > 0 {
s.GetMaster().Exec("UPDATE Posts SET UpdateAt = ? WHERE Id = ?", time, post.RootId)
@@ -361,8 +367,8 @@ func (s SqlPostStore) Search(teamId string, userId string, terms string, isHasht
searchType := "Message"
if isHashtagSearch {
searchType = "Hashtags"
- for _,term := range strings.Split(terms, " ") {
- termMap[term] = true;
+ for _, term := range strings.Split(terms, " ") {
+ termMap[term] = true
}
}