summaryrefslogtreecommitdiffstats
path: root/api4/team.go
diff options
context:
space:
mode:
authorSaturnino Abril <saturnino.abril@gmail.com>2018-04-30 17:57:57 +0800
committerGitHub <noreply@github.com>2018-04-30 17:57:57 +0800
commit30011f67e88935f750bced6530e8ee92b352b7a3 (patch)
treeb4ec005faa0f11927669499a030c851efa15723b /api4/team.go
parent2e6b3da1d3466db379fef0d61a23e2878d17ee9d (diff)
downloadchat-30011f67e88935f750bced6530e8ee92b352b7a3.tar.gz
chat-30011f67e88935f750bced6530e8ee92b352b7a3.tar.bz2
chat-30011f67e88935f750bced6530e8ee92b352b7a3.zip
[MM-10354] Add feature to remove team icon (#8684)
* set team.LastTeamIconUpdate to 0 when removing team icon * add APIv4 for removing team icon * removed comment and updated typo on AppError
Diffstat (limited to 'api4/team.go')
-rw-r--r--api4/team.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/api4/team.go b/api4/team.go
index 94035a770..023289579 100644
--- a/api4/team.go
+++ b/api4/team.go
@@ -32,6 +32,7 @@ func (api *API) InitTeam() {
api.BaseRoutes.Team.Handle("/image", api.ApiSessionRequiredTrustRequester(getTeamIcon)).Methods("GET")
api.BaseRoutes.Team.Handle("/image", api.ApiSessionRequired(setTeamIcon)).Methods("POST")
+ api.BaseRoutes.Team.Handle("/image", api.ApiSessionRequired(removeTeamIcon)).Methods("DELETE")
api.BaseRoutes.TeamMembers.Handle("", api.ApiSessionRequired(getTeamMembers)).Methods("GET")
api.BaseRoutes.TeamMembers.Handle("/ids", api.ApiSessionRequired(getTeamMembersByIds)).Methods("POST")
@@ -812,3 +813,23 @@ func setTeamIcon(c *Context, w http.ResponseWriter, r *http.Request) {
c.LogAudit("")
ReturnStatusOK(w)
}
+
+func removeTeamIcon(c *Context, w http.ResponseWriter, r *http.Request) {
+ c.RequireTeamId()
+ if c.Err != nil {
+ return
+ }
+
+ if !c.App.SessionHasPermissionToTeam(c.Session, c.Params.TeamId, model.PERMISSION_MANAGE_TEAM) {
+ c.SetPermissionError(model.PERMISSION_MANAGE_TEAM)
+ return
+ }
+
+ if err := c.App.RemoveTeamIcon(c.Params.TeamId); err != nil {
+ c.Err = err
+ return
+ }
+
+ c.LogAudit("")
+ ReturnStatusOK(w)
+}