fmt
This commit is contained in:
parent
b1ad9ffb7f
commit
4e507306ea
@ -17,9 +17,7 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"code.vikunja.io/api/pkg/user"
|
||||
"encoding/json"
|
||||
"xorm.io/xorm"
|
||||
|
||||
"code.vikunja.io/api/pkg/db"
|
||||
"code.vikunja.io/api/pkg/events"
|
||||
@ -27,7 +25,10 @@ import (
|
||||
"code.vikunja.io/api/pkg/metrics"
|
||||
"code.vikunja.io/api/pkg/modules/keyvalue"
|
||||
"code.vikunja.io/api/pkg/notifications"
|
||||
"code.vikunja.io/api/pkg/user"
|
||||
|
||||
"github.com/ThreeDotsLabs/watermill/message"
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
// RegisterListeners registers all event listeners
|
||||
@ -95,7 +96,6 @@ func notifyMentionedUsers(sess *xorm.Session, task *Task, text string, n notific
|
||||
log.Debugf("Processing %d mentioned users for text %d", len(users), n.SubjectID())
|
||||
|
||||
var notified int
|
||||
outer:
|
||||
for _, u := range users {
|
||||
can, _, err := task.CanRead(sess, u)
|
||||
if err != nil {
|
||||
@ -107,13 +107,13 @@ outer:
|
||||
}
|
||||
|
||||
// Don't notify a user if they were already notified
|
||||
dbn, err := notifications.GetNotificationsForEventAndUser(sess, u.ID, n.Name(), n.SubjectID())
|
||||
dbn, err := notifications.GetNotificationsForNameAndUser(sess, u.ID, n.Name(), n.SubjectID())
|
||||
if err != nil {
|
||||
return users, err
|
||||
}
|
||||
|
||||
if len(dbn) > 0 {
|
||||
continue outer
|
||||
continue
|
||||
}
|
||||
|
||||
err = notifications.Notify(u, n)
|
||||
|
@ -17,9 +17,11 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"code.vikunja.io/api/pkg/user"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"code.vikunja.io/api/pkg/user"
|
||||
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
|
@ -17,11 +17,12 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"code.vikunja.io/api/pkg/notifications"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"code.vikunja.io/api/pkg/db"
|
||||
"code.vikunja.io/api/pkg/notifications"
|
||||
"code.vikunja.io/api/pkg/user"
|
||||
)
|
||||
|
||||
|
@ -33,7 +33,7 @@ type DatabaseNotification struct {
|
||||
Notification interface{} `xorm:"json not null" json:"notification"`
|
||||
// The name of the notification
|
||||
Name string `xorm:"varchar(250) index not null" json:"name"`
|
||||
// The thing the notification is about. Used to check if a notification for this thing already happend or not.
|
||||
// The thing the notification is about. Used to check if a notification for this thing already happened or not.
|
||||
SubjectID int64 `xorm:"bigint null" json:"-"`
|
||||
|
||||
// When this notification is marked as read, this will be updated with the current timestamp.
|
||||
@ -67,7 +67,7 @@ func GetNotificationsForUser(s *xorm.Session, notifiableID int64, limit, start i
|
||||
return notifications, len(notifications), total, err
|
||||
}
|
||||
|
||||
func GetNotificationsForEventAndUser(s *xorm.Session, notifiableID int64, event string, subjectID int64) (notifications []*DatabaseNotification, err error) {
|
||||
func GetNotificationsForNameAndUser(s *xorm.Session, notifiableID int64, event string, subjectID int64) (notifications []*DatabaseNotification, err error) {
|
||||
notifications = []*DatabaseNotification{}
|
||||
err = s.Where("notifiable_id = ? AND name = ? AND subject_id = ?", notifiableID, event, subjectID).
|
||||
Find(¬ifications)
|
||||
|
Loading…
x
Reference in New Issue
Block a user