* [MM-42027] - Invitation Email is resent as a Reminder after invalidating pending email invites

* generate app layers mocks

* add tests

* improve err handling

* fix translations

* change status code
Этот коммит содержится в:
Allan Guwatudde
2022-02-25 20:02:08 +03:00
коммит произвёл GitHub
родитель 3c48be040f
Коммит 81f82729d2
13 изменённых файлов: 204 добавлений и 2 удалений

Просмотреть файл

@@ -1901,11 +1901,29 @@ func (a *App) RemoveTeamIcon(teamID string) *model.AppError {
func (a *App) InvalidateAllEmailInvites() *model.AppError {
if err := a.Srv().Store.Token().RemoveAllTokensByType(TokenTypeTeamInvitation); err != nil {
return model.NewAppError("InvalidateAllEmailInvites", "api.team.invalidate_all_email_invites.app_error", nil, err.Error(), http.StatusBadRequest)
return model.NewAppError("InvalidateAllEmailInvites", "api.team.invalidate_all_email_invites.app_error", nil, err.Error(), http.StatusInternalServerError)
}
if err := a.Srv().Store.Token().RemoveAllTokensByType(TokenTypeGuestInvitation); err != nil {
return model.NewAppError("InvalidateAllEmailInvites", "api.team.invalidate_all_email_invites.app_error", nil, err.Error(), http.StatusBadRequest)
return model.NewAppError("InvalidateAllEmailInvites", "api.team.invalidate_all_email_invites.app_error", nil, err.Error(), http.StatusInternalServerError)
}
if err := a.InvalidateAllResendInviteEmailJobs(); err != nil {
return model.NewAppError("InvalidateAllEmailInvites", "api.team.invalidate_all_email_invites.app_error", nil, err.Error(), http.StatusInternalServerError)
}
return nil
}
func (a *App) InvalidateAllResendInviteEmailJobs() *model.AppError {
jobs, appErr := a.Srv().Jobs.GetJobsByTypeAndStatus(model.JobTypeResendInvitationEmail, model.JobStatusPending)
if appErr != nil {
return appErr
}
for _, j := range jobs {
a.Srv().Jobs.SetJobCanceled(j)
// clean up any system values this job was using
a.Srv().Store.System().PermanentDeleteByName(j.Id)
}
return nil
}