52 lines
1.4 KiB
Go
52 lines
1.4 KiB
Go
package domain
|
|
|
|
import "time"
|
|
|
|
type NotificationType string
|
|
|
|
const (
|
|
NotificationEntrada2 NotificationType = "entrada2"
|
|
NotificationSaida2 NotificationType = "saida2"
|
|
)
|
|
|
|
type NotificationStatus string
|
|
|
|
const (
|
|
NotificationScheduled NotificationStatus = "scheduled"
|
|
NotificationSending NotificationStatus = "sending"
|
|
NotificationSent NotificationStatus = "sent"
|
|
NotificationFailed NotificationStatus = "failed"
|
|
NotificationCancelled NotificationStatus = "cancelled"
|
|
NotificationExpired NotificationStatus = "expired"
|
|
)
|
|
|
|
type Notification struct {
|
|
ID int64
|
|
UserID int64
|
|
ReferenceDate string
|
|
Type NotificationType
|
|
ScheduledAt time.Time // quando o aviso deve sair
|
|
PredictedAt time.Time // horário previsto do ponto (retorno ou saída)
|
|
Status NotificationStatus
|
|
Attempts int
|
|
LockedAt *time.Time
|
|
SentAt *time.Time
|
|
TelegramMessageID *int64
|
|
ErrorMessage *string
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
func ValidNotificationType(t string) bool {
|
|
return t == string(NotificationEntrada2) || t == string(NotificationSaida2)
|
|
}
|
|
|
|
func ValidNotificationStatus(s string) bool {
|
|
switch NotificationStatus(s) {
|
|
case NotificationScheduled, NotificationSending, NotificationSent,
|
|
NotificationFailed, NotificationCancelled, NotificationExpired:
|
|
return true
|
|
}
|
|
return false
|
|
}
|