summaryrefslogtreecommitdiffstats
path: root/app/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 /app/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 'app/team.go')
-rw-r--r--app/team.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/app/team.go b/app/team.go
index 78d932870..f5235792f 100644
--- a/app/team.go
+++ b/app/team.go
@@ -103,6 +103,7 @@ func (a *App) UpdateTeam(team *model.Team) (*model.Team, *model.AppError) {
oldTeam.AllowOpenInvite = team.AllowOpenInvite
oldTeam.CompanyName = team.CompanyName
oldTeam.AllowedDomains = team.AllowedDomains
+ oldTeam.LastTeamIconUpdate = team.LastTeamIconUpdate
if result := <-a.Srv.Store.Team().Update(oldTeam); result.Err != nil {
return nil, result.Err
@@ -1007,7 +1008,7 @@ func (a *App) SetTeamIconFromFile(teamId string, file multipart.File) *model.App
curTime := model.GetMillis()
if result := <-a.Srv.Store.Team().UpdateLastTeamIconUpdate(teamId, curTime); result.Err != nil {
- return model.NewAppError("SetTeamIcon", "api.team.set_team_icon.update.app_error", nil, result.Err.Error(), http.StatusBadRequest)
+ return model.NewAppError("SetTeamIcon", "api.team.team_icon.update.app_error", nil, result.Err.Error(), http.StatusBadRequest)
}
// manually set time to avoid possible cluster inconsistencies
@@ -1017,3 +1018,20 @@ func (a *App) SetTeamIconFromFile(teamId string, file multipart.File) *model.App
return nil
}
+
+func (a *App) RemoveTeamIcon(teamId string) *model.AppError {
+ team, err := a.GetTeam(teamId)
+ if err != nil {
+ return model.NewAppError("RemoveTeamIcon", "api.team.remove_team_icon.get_team.app_error", nil, err.Error(), http.StatusBadRequest)
+ }
+
+ if result := <-a.Srv.Store.Team().UpdateLastTeamIconUpdate(teamId, 0); result.Err != nil {
+ return model.NewAppError("RemoveTeamIcon", "api.team.team_icon.update.app_error", nil, result.Err.Error(), http.StatusBadRequest)
+ }
+
+ team.LastTeamIconUpdate = 0
+
+ a.sendTeamEvent(team, model.WEBSOCKET_EVENT_UPDATE_TEAM)
+
+ return nil
+}