[MM-13671] Rework Team InviteId Creation and Updates (#10536)
* Add regenerate invite ID endpoint; Dont allow inviteID updates via other methods; Remove unrequired checks in get handler * Fix tests; Dont accept TeamId as invite ID * Ensure all teams have an InviteID set * Custom Selector to get empty teams; dont crash when inviteid set fails * Remote InviteId from TeamPatch * Add missing translation * Translation string order * Use sync store * gofmt
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
ec95793b90
Коммит
f7982216e4
20
app/team.go
20
app/team.go
@@ -23,6 +23,7 @@ import (
|
||||
)
|
||||
|
||||
func (a *App) CreateTeam(team *model.Team) (*model.Team, *model.AppError) {
|
||||
team.InviteId = ""
|
||||
result := <-a.Srv.Store.Team().Save(team)
|
||||
if result.Err != nil {
|
||||
return nil, result.Err
|
||||
@@ -118,7 +119,6 @@ func (a *App) UpdateTeam(team *model.Team) (*model.Team, *model.AppError) {
|
||||
|
||||
oldTeam.DisplayName = team.DisplayName
|
||||
oldTeam.Description = team.Description
|
||||
oldTeam.InviteId = team.InviteId
|
||||
oldTeam.AllowOpenInvite = team.AllowOpenInvite
|
||||
oldTeam.CompanyName = team.CompanyName
|
||||
oldTeam.AllowedDomains = team.AllowedDomains
|
||||
@@ -202,6 +202,24 @@ func (a *App) PatchTeam(teamId string, patch *model.TeamPatch) (*model.Team, *mo
|
||||
return updatedTeam, nil
|
||||
}
|
||||
|
||||
func (a *App) RegenerateTeamInviteId(teamId string) (*model.Team, *model.AppError) {
|
||||
team, err := a.GetTeam(teamId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
team.InviteId = model.NewId()
|
||||
|
||||
updatedTeam, err := a.Srv.Store.Team().Update(team)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
a.sendTeamEvent(updatedTeam, model.WEBSOCKET_EVENT_UPDATE_TEAM)
|
||||
|
||||
return updatedTeam, nil
|
||||
}
|
||||
|
||||
func (a *App) sendTeamEvent(team *model.Team, event string) {
|
||||
sanitizedTeam := &model.Team{}
|
||||
*sanitizedTeam = *team
|
||||
|
||||
Ссылка в новой задаче
Block a user