PLT-5483 Fix bug where flagged posts endpoint returned posts on other teams (#5765)

* Fix bug where flagged posts endpoint returned posts on other teams

* Include flagged posts from DMs/GMs
Этот коммит содержится в:
Joram Wilander
2017-03-31 12:25:39 -04:00
коммит произвёл Harrison Healey
родитель 84826bf563
Коммит aba07e5cb9
6 изменённых файлов: 240 добавлений и 1 удалений

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

@@ -161,7 +161,12 @@ func getFlaggedPosts(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
if posts, err := app.GetFlaggedPosts(c.Session.UserId, offset, limit); err != nil {
if !app.SessionHasPermissionToTeam(c.Session, c.TeamId, model.PERMISSION_VIEW_TEAM) {
c.SetPermissionError(model.PERMISSION_VIEW_TEAM)
return
}
if posts, err := app.GetFlaggedPostsForTeam(c.Session.UserId, c.TeamId, offset, limit); err != nil {
c.Err = err
return
} else {

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

@@ -1115,6 +1115,11 @@ func TestGetFlaggedPosts(t *testing.T) {
if len(r2.Order) != 0 {
t.Fatal("should not have gotten a flagged post")
}
Client.SetTeamId(model.NewId())
if _, err := Client.GetFlaggedPosts(0, 2); err == nil {
t.Fatal("should have failed - bad team id")
}
}
func TestGetMessageForNotification(t *testing.T) {