| 1 | package notifications |
| 2 | |
| 3 | import ( |
| 4 | "amadan.net/oficina/equipo/internal/equipo/personapi" |
| 5 | "time" |
| 6 | ) |
| 7 | |
| 8 | type Notification = personapi.Notification |
| 9 | type NotificationSubscription = personapi.NotificationSubscription |
| 10 | |
| 11 | type Event struct { |
| 12 | Sequence int64 `gorm:"primaryKey;autoIncrement;index:notification_feed,priority:3"` |
| 13 | ID string `gorm:"uniqueIndex:notification_id;not null"` |
| 14 | TeamID string `gorm:"uniqueIndex:notification_event,priority:1;index:notification_feed,priority:1;not null"` |
| 15 | Recipient string `gorm:"uniqueIndex:notification_event,priority:2;index:notification_feed,priority:2;not null"` |
| 16 | Event string `gorm:"uniqueIndex:notification_event,priority:3;not null"` |
| 17 | ResourceID string `gorm:"uniqueIndex:notification_event,priority:4;not null"` |
| 18 | ResourceRevision int64 `gorm:"uniqueIndex:notification_event,priority:5;not null"` |
| 19 | Kind, ResourceType, DeepLink, State string |
| 20 | CreatedAt time.Time |
| 21 | AcknowledgedAt *time.Time |
| 22 | } |
| 23 | |
| 24 | func (Event) TableName() string { return "notification_outbox" } |
| 25 | |
| 26 | type Subscription struct { |
| 27 | ID string `gorm:"primaryKey"` |
| 28 | TeamID, Person string |
| 29 | DeviceID string `gorm:"index:notification_device"` |
| 30 | Revision, AckSequence int64 |
| 31 | Active bool |
| 32 | CreatedAt, ExpiresAt time.Time |
| 33 | } |
| 34 | |
| 35 | func (Subscription) TableName() string { return "notification_subscriptions" } |
| 36 | |
| 37 | type Delivery struct { |
| 38 | SubscriptionID string `gorm:"primaryKey"` |
| 39 | Sequence int64 `gorm:"primaryKey;autoIncrement:false"` |
| 40 | DeliveredAt time.Time |
| 41 | AcknowledgedAt *time.Time |
| 42 | } |
| 43 | |
| 44 | func (Delivery) TableName() string { return "notification_deliveries" } |
| 45 | |
| 46 | type History struct { |
| 47 | TeamID, Person string `gorm:"primaryKey"` |
| 48 | PrunedThrough int64 |
| 49 | } |
| 50 | |
| 51 | func (History) TableName() string { return "notification_history" } |
| 52 | |
| 53 | var Models = []any{&Event{}, &Subscription{}, &Delivery{}, &History{}} |
| 54 | |