diff options
author | Robin Naundorf <r.naundorf@fh-muenster.de> | 2017-05-09 14:52:46 +0200 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2017-05-09 07:52:46 -0500 |
commit | 5efcd2d9d3fb91ae7475918b807b7947b533da9b (patch) | |
tree | 7f1c0bfe5ca751b27b6a520f63cd20e280377d85 /api4/channel.go | |
parent | 530814b8c9b1b47dd6eb05e70548c61d75da9a23 (diff) | |
download | chat-5efcd2d9d3fb91ae7475918b807b7947b533da9b.tar.gz chat-5efcd2d9d3fb91ae7475918b807b7947b533da9b.tar.bz2 chat-5efcd2d9d3fb91ae7475918b807b7947b533da9b.zip |
Add API Endpoint for deleted Channels (#5889)
Diffstat (limited to 'api4/channel.go')
-rw-r--r-- | api4/channel.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/api4/channel.go b/api4/channel.go index 493b012a0..69cc0953e 100644 --- a/api4/channel.go +++ b/api4/channel.go @@ -21,6 +21,7 @@ func InitChannel() { BaseRoutes.Channels.Handle("/members/{user_id:[A-Za-z0-9]+}/view", ApiSessionRequired(viewChannel)).Methods("POST") BaseRoutes.ChannelsForTeam.Handle("", ApiSessionRequired(getPublicChannelsForTeam)).Methods("GET") + BaseRoutes.ChannelsForTeam.Handle("/deleted", ApiSessionRequired(getDeletedChannelsForTeam)).Methods("GET") BaseRoutes.ChannelsForTeam.Handle("/ids", ApiSessionRequired(getPublicChannelsByIdsForTeam)).Methods("POST") BaseRoutes.ChannelsForTeam.Handle("/search", ApiSessionRequired(searchChannelsForTeam)).Methods("POST") BaseRoutes.User.Handle("/teams/{team_id:[A-Za-z0-9]+}/channels", ApiSessionRequired(getChannelsForTeamForUser)).Methods("GET") @@ -385,6 +386,26 @@ func getPublicChannelsForTeam(c *Context, w http.ResponseWriter, r *http.Request } } +func getDeletedChannelsForTeam(c *Context, w http.ResponseWriter, r *http.Request) { + c.RequireTeamId() + if c.Err != nil { + return + } + + if !app.SessionHasPermissionToTeam(c.Session, c.Params.TeamId, model.PERMISSION_MANAGE_TEAM) { + c.SetPermissionError(model.PERMISSION_MANAGE_TEAM) + return + } + + if channels, err := app.GetDeletedChannels(c.Params.TeamId, c.Params.Page * c.Params.PerPage, c.Params.PerPage); err != nil { + c.Err = err + return + } else { + w.Write([]byte(channels.ToJson())) + return + } +} + func getPublicChannelsByIdsForTeam(c *Context, w http.ResponseWriter, r *http.Request) { c.RequireTeamId() if c.Err != nil { |