Task mentions (#926)
Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/api/pulls/926 Co-authored-by: konrad <konrad@kola-entertainments.de> Co-committed-by: konrad <konrad@kola-entertainments.de>
This commit is contained in:
@ -29,6 +29,15 @@ type Notification interface {
|
||||
Name() string
|
||||
}
|
||||
|
||||
type SubjectID interface {
|
||||
SubjectID() int64
|
||||
}
|
||||
|
||||
type NotificationWithSubject interface {
|
||||
Notification
|
||||
SubjectID
|
||||
}
|
||||
|
||||
// Notifiable is an entity which can be notified. Usually a user.
|
||||
type Notifiable interface {
|
||||
// Should return the email address this notifiable has.
|
||||
@ -82,6 +91,10 @@ func notifyDB(notifiable Notifiable, notification Notification) (err error) {
|
||||
Name: notification.Name(),
|
||||
}
|
||||
|
||||
if subject, is := notification.(SubjectID); is {
|
||||
dbNotification.SubjectID = subject.SubjectID()
|
||||
}
|
||||
|
||||
_, err = s.Insert(dbNotification)
|
||||
if err != nil {
|
||||
_ = s.Rollback()
|
||||
|
Reference in New Issue
Block a user