Fix sending notifications to users if the user object didn't have an email
This commit is contained in:
parent
58492fffce
commit
83f003355d
3 changed files with 21 additions and 7 deletions
|
|
@ -17,6 +17,7 @@
|
|||
package user
|
||||
|
||||
import (
|
||||
"code.vikunja.io/api/pkg/db"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
|
@ -75,8 +76,19 @@ type User struct {
|
|||
}
|
||||
|
||||
// RouteForMail routes all notifications for a user to its email address
|
||||
func (u *User) RouteForMail() string {
|
||||
return u.Email
|
||||
func (u *User) RouteForMail() (string, error) {
|
||||
|
||||
if u.Email == "" {
|
||||
s := db.NewSession()
|
||||
defer s.Close()
|
||||
user, err := getUser(s, &User{ID: u.ID}, true)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return user.Email, nil
|
||||
}
|
||||
|
||||
return u.Email, nil
|
||||
}
|
||||
|
||||
// RouteForDB routes all notifications for a user to their id
|
||||
|
|
|
|||
Reference in a new issue