fix: move event dispatch to new function
All checks were successful
continuous-integration/drone/pr Build is passing

This commit is contained in:
Daniel Herrmann 2024-03-05 22:13:07 +01:00
parent 6781e5e6cd
commit 07dcfd8249

View File

@ -213,7 +213,7 @@ func addMoreInfoToTeams(s *xorm.Session, teams []*Team) (err error) {
// CreateNewTeam creates a new team and assignes the user that has caused creation
// as the first member of the team
// If def_adm is true, the user will be an admin of the team
// If firstUserShouldBeAdmin is true, the user will be an admin of the team
// Note: this function has been extracted from the Create method to allow
// an additional parameter to control whether the user should become admin of the team
func (t *Team) CreateNewTeam(s *xorm.Session, a web.Auth, firstUserShouldBeAdmin bool) (err error) {
@ -240,7 +240,11 @@ func (t *Team) CreateNewTeam(s *xorm.Session, a web.Auth, firstUserShouldBeAdmin
if err = tm.Create(s, doer); err != nil {
return err
}
return
return events.Dispatch(&TeamCreatedEvent{
Team: t,
Doer: a,
})
}
// ReadOne implements the CRUD method to get one team
@ -329,10 +333,7 @@ func (t *Team) Create(s *xorm.Session, a web.Auth) (err error) {
return err
}
return events.Dispatch(&TeamCreatedEvent{
Team: t,
Doer: a,
})
return
}
// Delete deletes a team