- Assign default circle to user when leaving a circle
- Support Pushover - Support Disable Signup - Migrate chatID to TargetID
This commit is contained in:
parent
850d472445
commit
adf5c0c0cd
20 changed files with 362 additions and 151 deletions
37
internal/notifier/service/pushover/pushover.go
Normal file
37
internal/notifier/service/pushover/pushover.go
Normal file
|
@ -0,0 +1,37 @@
|
|||
package pushover
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"donetick.com/core/config"
|
||||
nModel "donetick.com/core/internal/notifier/model"
|
||||
"donetick.com/core/logging"
|
||||
"github.com/gregdel/pushover"
|
||||
)
|
||||
|
||||
type Pushover struct {
|
||||
pushover *pushover.Pushover
|
||||
}
|
||||
|
||||
func NewPushover(cfg *config.Config) *Pushover {
|
||||
|
||||
pushoverApp := pushover.New(cfg.Pushover.Token)
|
||||
|
||||
return &Pushover{
|
||||
pushover: pushoverApp,
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Pushover) SendNotification(c context.Context, notification *nModel.Notification) error {
|
||||
log := logging.FromContext(c)
|
||||
recipient := pushover.NewRecipient(notification.TargetID)
|
||||
message := pushover.NewMessageWithTitle(notification.Text, "Donetick")
|
||||
|
||||
_, err := p.pushover.SendMessage(message, recipient)
|
||||
if err != nil {
|
||||
log.Debug("Error sending pushover notification", err)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue