[MM-13820] Optimize flagged post handling in preferences and web handler (#10135)
* Optimize flagged post handling in preferences and web handler
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
94e45c3466
Коммит
b890f8d007
27
api4/post.go
27
api4/post.go
@@ -195,12 +195,37 @@ func getFlaggedPostsForUser(c *Context, w http.ResponseWriter, r *http.Request)
|
||||
posts, err = c.App.GetFlaggedPosts(c.Params.UserId, c.Params.Page, c.Params.PerPage)
|
||||
}
|
||||
|
||||
pl := model.NewPostList()
|
||||
channelReadPermission := make(map[string]bool)
|
||||
|
||||
for _, post := range posts.Posts {
|
||||
allowed, ok := channelReadPermission[post.ChannelId]
|
||||
|
||||
if !ok {
|
||||
allowed = false
|
||||
|
||||
if c.App.SessionHasPermissionToChannel(c.App.Session, post.ChannelId, model.PERMISSION_READ_CHANNEL) {
|
||||
allowed = true
|
||||
}
|
||||
|
||||
channelReadPermission[post.ChannelId] = allowed
|
||||
}
|
||||
|
||||
if !allowed {
|
||||
continue
|
||||
}
|
||||
|
||||
pl.AddPost(post)
|
||||
pl.AddOrder(post.Id)
|
||||
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
|
||||
w.Write([]byte(c.App.PreparePostListForClient(posts).ToJson()))
|
||||
w.Write([]byte(c.App.PreparePostListForClient(pl).ToJson()))
|
||||
}
|
||||
|
||||
func getPost(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Ссылка в новой задаче
Block a user