Verbessere Dokumentation
This commit is contained in:
parent
ec24c6c4dc
commit
fe54d76ab2
14 changed files with 75 additions and 34 deletions
|
@ -68,6 +68,8 @@ func (r *RequestRepo) FindByOfficeHour(officeHour models.OfficeHour) ([]models.R
|
|||
return requests, nil
|
||||
}
|
||||
|
||||
// Add a request to the database if it doesnt already exist.
|
||||
// Send a mail with the secret to the confirmation address in any case.
|
||||
func (r *RequestRepo) Add(officeHour models.OfficeHour, action int) (int, error) {
|
||||
existents, err := r.FindByOfficeHour(officeHour)
|
||||
if err != nil && !errors.Is(err, sql.ErrNoRows) {
|
||||
|
@ -97,6 +99,7 @@ func (r *RequestRepo) Add(officeHour models.OfficeHour, action int) (int, error)
|
|||
return request.Id, r.sendConfirmationMail(request)
|
||||
}
|
||||
|
||||
// Execute a request and delete it.
|
||||
func (r *RequestRepo) Execute(request models.Request) error {
|
||||
var err error
|
||||
switch request.Action {
|
||||
|
@ -107,11 +110,13 @@ func (r *RequestRepo) Execute(request models.Request) error {
|
|||
err = r.officeHourRepo.Delete(request.OfficeHour)
|
||||
r.db.Exec("DELETE FROM request WHERE officeHour=?", request.OfficeHour.Id)
|
||||
default:
|
||||
log.Printf("Executing request: Action type %d unknown.", request.Action)
|
||||
_, err = r.db.Exec("DELETE FROM request WHERE id=?", request.Id)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// Find a new secret token with configured length that is currently unused.
|
||||
func (r *RequestRepo) newSecret() (string, error) {
|
||||
var err error
|
||||
var secret string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue