2020-05-20 12:28:08 +00:00
|
|
|
package view
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/caos/zitadel/internal/user/repository/view"
|
|
|
|
"github.com/caos/zitadel/internal/user/repository/view/model"
|
2020-06-25 06:01:13 +00:00
|
|
|
"github.com/caos/zitadel/internal/view/repository"
|
2020-05-20 12:28:08 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
notifyUserTable = "notification.notify_users"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (v *View) NotifyUserByID(userID string) (*model.NotifyUser, error) {
|
|
|
|
return view.NotifyUserByID(v.Db, notifyUserTable, userID)
|
|
|
|
}
|
|
|
|
|
2020-07-07 17:31:51 +00:00
|
|
|
func (v *View) PutNotifyUser(user *model.NotifyUser, sequence uint64) error {
|
2020-05-20 12:28:08 +00:00
|
|
|
err := view.PutNotifyUser(v.Db, notifyUserTable, user)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-07-07 17:31:51 +00:00
|
|
|
if sequence != 0 {
|
|
|
|
return v.ProcessedNotifyUserSequence(sequence)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) NotifyUsersByOrgID(orgID string) ([]*model.NotifyUser, error) {
|
|
|
|
return view.NotifyUsersByOrgID(v.Db, notifyUserTable, orgID)
|
2020-05-20 12:28:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) DeleteNotifyUser(userID string, eventSequence uint64) error {
|
|
|
|
err := view.DeleteNotifyUser(v.Db, notifyUserTable, userID)
|
|
|
|
if err != nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return v.ProcessedNotifyUserSequence(eventSequence)
|
|
|
|
}
|
|
|
|
|
2020-07-15 11:24:36 +00:00
|
|
|
func (v *View) GetLatestNotifyUserSequence() (*repository.CurrentSequence, error) {
|
2020-05-20 12:28:08 +00:00
|
|
|
return v.latestSequence(notifyUserTable)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) ProcessedNotifyUserSequence(eventSequence uint64) error {
|
|
|
|
return v.saveCurrentSequence(notifyUserTable, eventSequence)
|
|
|
|
}
|
|
|
|
|
2020-06-25 06:01:13 +00:00
|
|
|
func (v *View) GetLatestNotifyUserFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
2020-05-20 12:28:08 +00:00
|
|
|
return v.latestFailedEvent(notifyUserTable, sequence)
|
|
|
|
}
|
|
|
|
|
2020-06-25 06:01:13 +00:00
|
|
|
func (v *View) ProcessedNotifyUserFailedEvent(failedEvent *repository.FailedEvent) error {
|
2020-05-20 12:28:08 +00:00
|
|
|
return v.saveFailedEvent(failedEvent)
|
|
|
|
}
|