APIv4 get /channels/{channel_id}/pinned (#5893)

Этот коммит содержится в:
Saturnino Abril
2017-03-30 00:09:05 +09:00
коммит произвёл Corey Hulen
родитель 64f80decaf
Коммит 8a31718db1
5 изменённых файлов: 102 добавлений и 0 удалений

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

@@ -29,6 +29,7 @@ func InitChannel() {
BaseRoutes.Channel.Handle("/patch", ApiSessionRequired(patchChannel)).Methods("PUT")
BaseRoutes.Channel.Handle("", ApiSessionRequired(deleteChannel)).Methods("DELETE")
BaseRoutes.Channel.Handle("/stats", ApiSessionRequired(getChannelStats)).Methods("GET")
BaseRoutes.Channel.Handle("/pinned", ApiSessionRequired(getPinnedPosts)).Methods("GET")
BaseRoutes.ChannelForUser.Handle("/unread", ApiSessionRequired(getChannelUnread)).Methods("GET")
@@ -303,6 +304,28 @@ func getChannelStats(c *Context, w http.ResponseWriter, r *http.Request) {
w.Write([]byte(stats.ToJson()))
}
func getPinnedPosts(c *Context, w http.ResponseWriter, r *http.Request) {
c.RequireChannelId()
if c.Err != nil {
return
}
if !app.SessionHasPermissionToChannel(c.Session, c.Params.ChannelId, model.PERMISSION_READ_CHANNEL) {
c.SetPermissionError(model.PERMISSION_READ_CHANNEL)
return
}
if posts, err := app.GetPinnedPosts(c.Params.ChannelId); err != nil {
c.Err = err
return
} else if HandleEtag(posts.Etag(), "Get Pinned Posts", w, r) {
return
} else {
w.Header().Set(model.HEADER_ETAG_SERVER, posts.Etag())
w.Write([]byte(posts.ToJson()))
}
}
func getPublicChannelsForTeam(c *Context, w http.ResponseWriter, r *http.Request) {
c.RequireTeamId()
if c.Err != nil {