donetick/internal/notifier/model/model.go
Mo Tarbin 04d1894aea Add Event Producer
Update User to carry webhook from circle if assigned
Refactor notification handling and update models for webhook support
2025-02-09 20:15:28 -05:00

34 lines
1.3 KiB
Go

package model
import "time"
type Notification struct {
ID int `json:"id" gorm:"primaryKey"`
ChoreID int `json:"chore_id" gorm:"column:chore_id"`
CircleID int `json:"circle_id" gorm:"column:circle_id"`
UserID int `json:"user_id" gorm:"column:user_id"`
TargetID string `json:"target_id" gorm:"column:target_id"`
Text string `json:"text" gorm:"column:text"`
IsSent bool `json:"is_sent" gorm:"column:is_sent;index;default:false"`
TypeID NotificationPlatform `json:"type" gorm:"column:type"`
ScheduledFor time.Time `json:"scheduled_for" gorm:"column:scheduled_for;index"`
CreatedAt time.Time `json:"created_at" gorm:"column:created_at"`
RawEvent interface{} `json:"raw_event" gorm:"column:raw_event;type:jsonb"`
}
type NotificationDetails struct {
Notification
WebhookURL *string `json:"webhook_url" gorm:"column:webhook_url;<-:null"` // read-only, will only be used if webhook enabled
}
func (n *Notification) IsValid() bool {
return true
}
type NotificationPlatform int8
const (
NotificationPlatformNone NotificationPlatform = iota
NotificationPlatformTelegram
NotificationPlatformPushover
)