Files
phishingclub/backend/database/campaignEvent.go
Ronni Skansing fa1174e06c add option to save additional data
Signed-off-by: Ronni Skansing <rskansing@gmail.com>
2025-11-11 19:47:19 +01:00

56 lines
1.3 KiB
Go

package database
import (
"reflect"
"time"
"github.com/google/uuid"
)
const (
CAMPAIGN_EVENT_TABLE = "campaign_events"
)
// Campaign is gorm data model
type CampaignEvent struct {
ID *uuid.UUID `gorm:"primary_key;not null;unique;type:uuid"`
CreatedAt *time.Time `gorm:"not null;index;"`
UpdatedAt *time.Time `gorm:"not null;"`
// arbitrary data
Data string `gorm:"not null;"`
// metadata stores browser fingerprinting data (ja4, platform, accept-language) as json
Metadata string `gorm:"not null;default:''"`
// has one
CampaignID *uuid.UUID `gorm:"not null;index;type:uuid;"`
EventID *uuid.UUID `gorm:"not null;index;type:uuid;"`
// can has one
UserAgent string `gorm:";"`
IPAddress string `gorm:";"`
// AnonymizedID is set when the recipient has been anonymized
AnonymizedID *uuid.UUID `gorm:"type:uuid;index;"`
// if null either the event has no recipient or the recipient has been anonymized
RecipientID *uuid.UUID `gorm:"index;type:uuid;"`
Recipient *Recipient
CompanyID *uuid.UUID `gorm:"index;type:uuid;index;"`
}
// RecipientCampaignEvent is a aggregated read-only model
type RecipientCampaignEvent struct {
CampaignEvent
Name string // event name
CampaignName string
}
func (CampaignEvent) TableName() string {
return CAMPAIGN_EVENT_TABLE
}
var _ = reflect.TypeOf(RecipientCampaignEvent{})