34 lines
1.7 KiB
Go
34 lines
1.7 KiB
Go
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// Notification represents a notification delivered to a user.
|
|
// Reference: Chatwoot Notification model + P2B M8 spec
|
|
type Notification struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
AccountID *uint `gorm:"index" json:"account_id,omitempty"`
|
|
UserID uint `gorm:"not null;index" json:"user_id"`
|
|
NotificationType string `gorm:"size:100;not null;index" json:"notification_type"` // conversation_created/conversation_assigned/message_created/assigned_conversation_new_message
|
|
PrimaryActorType string `gorm:"size:100" json:"primary_actor_type"` // Conversation/Message/User/Contact
|
|
PrimaryActorID uint `json:"primary_actor_id"`
|
|
SecondaryActorType string `gorm:"size:100" json:"secondary_actor_type"`
|
|
SecondaryActorID uint `json:"secondary_actor_id"`
|
|
ReadAt *time.Time `json:"read_at,omitempty"`
|
|
SnoozedUntil *time.Time `json:"snoozed_until,omitempty"`
|
|
PushEnabled bool `gorm:"default:false" json:"push_enabled"`
|
|
EmailEnabled bool `gorm:"default:false" json:"email_enabled"`
|
|
AdditionalAttributes json.RawMessage `gorm:"type:jsonb" json:"additional_attributes"`
|
|
CreatedAt time.Time `gorm:"autoCreateTime;index" json:"created_at"`
|
|
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
|
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"`
|
|
|
|
User User `gorm:"foreignKey:UserID" json:"user,omitempty"`
|
|
}
|
|
|
|
func (Notification) TableName() string { return "notifications" }
|