Commit 5d7ae488 authored by Saturnino Abril's avatar Saturnino Abril Committed by Harrison Healey

[PLT-8494] Add delete_team websocket event (#8167)

* add delete_team websocket event

* add to PermanentDeleteTeam
parent e50fea9d
......@@ -104,7 +104,7 @@ func (a *App) UpdateTeam(team *model.Team) (*model.Team, *model.AppError) {
return nil, result.Err
}
a.sendUpdatedTeamEvent(oldTeam)
a.sendTeamEvent(oldTeam, model.WEBSOCKET_EVENT_UPDATE_TEAM)
return oldTeam, nil
}
......@@ -122,17 +122,17 @@ func (a *App) PatchTeam(teamId string, patch *model.TeamPatch) (*model.Team, *mo
return nil, err
}
a.sendUpdatedTeamEvent(updatedTeam)
a.sendTeamEvent(updatedTeam, model.WEBSOCKET_EVENT_UPDATE_TEAM)
return updatedTeam, nil
}
func (a *App) sendUpdatedTeamEvent(team *model.Team) {
func (a *App) sendTeamEvent(team *model.Team, event string) {
sanitizedTeam := &model.Team{}
*sanitizedTeam = *team
sanitizedTeam.Sanitize()
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_UPDATE_TEAM, "", "", "", nil)
message := model.NewWebSocketEvent(event, "", "", "", nil)
message.Add("team", sanitizedTeam.ToJson())
a.Go(func() {
a.Publish(message)
......@@ -820,6 +820,8 @@ func (a *App) PermanentDeleteTeam(team *model.Team) *model.AppError {
return result.Err
}
a.sendTeamEvent(team, model.WEBSOCKET_EVENT_DELETE_TEAM)
return nil
}
......@@ -834,6 +836,8 @@ func (a *App) SoftDeleteTeam(teamId string) *model.AppError {
return result.Err
}
a.sendTeamEvent(team, model.WEBSOCKET_EVENT_DELETE_TEAM)
return nil
}
......
......@@ -22,6 +22,7 @@ const (
WEBSOCKET_EVENT_ADDED_TO_TEAM = "added_to_team"
WEBSOCKET_EVENT_LEAVE_TEAM = "leave_team"
WEBSOCKET_EVENT_UPDATE_TEAM = "update_team"
WEBSOCKET_EVENT_DELETE_TEAM = "delete_team"
WEBSOCKET_EVENT_USER_ADDED = "user_added"
WEBSOCKET_EVENT_USER_UPDATED = "user_updated"
WEBSOCKET_EVENT_USER_ROLE_UPDATED = "user_role_updated"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment