MM-10272: Add a count for pinned posts header icon (#11840)

Этот коммит содержится в:
Woolim Cho
2019-09-04 20:41:29 +09:00
коммит произвёл Ben Schumacher
родитель 5a477a617a
Коммит b9a3c2e90e
11 изменённых файлов: 231 добавлений и 4 удалений

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

@@ -527,7 +527,13 @@ func getChannelStats(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
stats := model.ChannelStats{ChannelId: c.Params.ChannelId, MemberCount: memberCount, GuestCount: guestCount}
pinnedPostCount, err := c.App.GetChannelPinnedPostCount(c.Params.ChannelId)
if err != nil {
c.Err = err
return
}
stats := model.ChannelStats{ChannelId: c.Params.ChannelId, MemberCount: memberCount, GuestCount: guestCount, PinnedPostCount: pinnedPostCount}
w.Write([]byte(stats.ToJson()))
}

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

@@ -1849,6 +1849,16 @@ func TestGetChannelStats(t *testing.T) {
t.Fatal("couldnt't get extra info")
} else if stats.MemberCount != 1 {
t.Fatal("got incorrect member count")
} else if stats.PinnedPostCount != 0 {
t.Fatal("got incorrect pinned post count")
}
th.CreatePinnedPostWithClient(th.Client, channel)
stats, resp = Client.GetChannelStats(channel.Id, "")
CheckNoError(t, resp)
if stats.PinnedPostCount != 1 {
t.Fatal("should have returned 1 pinned post count")
}
_, resp = Client.GetChannelStats("junk", "")