PLT-1326: Enable channel posts of type join or leave not trigger unread notifications

Этот коммит содержится в:
Florian Orben
2015-12-04 02:07:47 +01:00
родитель d5d66214db
Коммит 14d1ec5191
14 изменённых файлов: 93 добавлений и 13 удалений

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

@@ -10,9 +10,10 @@ import (
)
const (
POST_DEFAULT = ""
POST_SLACK_ATTACHMENT = "slack_attachment"
POST_JOIN_LEAVE = "join_leave"
POST_SYSTEM_MESSAGE_PREFIX = "system_"
POST_DEFAULT = ""
POST_SLACK_ATTACHMENT = "slack_attachment"
POST_JOIN_LEAVE = "system_join_leave"
)
type Post struct {
@@ -159,3 +160,7 @@ func (o *Post) AddProp(key string, value interface{}) {
func (o *Post) PreExport() {
}
func (o *Post) IsSystemMessage() bool {
return len(o.Type) >= len(POST_SYSTEM_MESSAGE_PREFIX) && o.Type[:len(POST_SYSTEM_MESSAGE_PREFIX)] == POST_SYSTEM_MESSAGE_PREFIX
}

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

@@ -98,3 +98,18 @@ func TestPostPreSave(t *testing.T) {
o.Etag()
}
func TestPostIsSystemMessage(t *testing.T) {
post1 := Post{Message: "test_1"}
post1.PreSave()
if post1.IsSystemMessage() {
t.Fatalf("TestPostIsSystemMessage failed, expected post1.IsSystemMessage() to be false")
}
post2 := Post{Message: "test_2", Type: POST_JOIN_LEAVE}
post2.PreSave()
if !post2.IsSystemMessage() {
t.Fatalf("TestPostIsSystemMessage failed, expected post2.IsSystemMessage() to be true")
}
}