- 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
|
@ -3,13 +3,35 @@ package model
|
|||
import "time"
|
||||
|
||||
type Notification struct {
|
||||
ID int `json:"id" gorm:"primaryKey"`
|
||||
ChoreID int `json:"chore_id" gorm:"column:chore_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 int `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"`
|
||||
ID int `json:"id" gorm:"primaryKey"`
|
||||
ChoreID int `json:"chore_id" gorm:"column:chore_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 NotificationType `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"`
|
||||
}
|
||||
|
||||
func (n *Notification) IsValid() bool {
|
||||
switch n.TypeID {
|
||||
case NotificationTypeTelegram, NotificationTypePushover:
|
||||
if n.TargetID == "" {
|
||||
return false
|
||||
} else if n.Text == "0" {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
type NotificationType int8
|
||||
|
||||
const (
|
||||
NotificationTypeNone NotificationType = iota
|
||||
NotificationTypeTelegram
|
||||
NotificationTypePushover
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue