mirror of
https://github.com/phishingclub/phishingclub.git
synced 2026-07-30 23:47:23 +02:00
@@ -26,6 +26,8 @@ type Attachment struct {
|
||||
Description string `gorm:";"`
|
||||
Filename string `gorm:"not null;index"`
|
||||
EmbeddedContent bool `gorm:"not null;default:false;index"`
|
||||
// SendAsCalendar sends ics files as a calendar invitation
|
||||
SendAsCalendar bool `gorm:"not null;default:false;index"`
|
||||
}
|
||||
|
||||
func (Attachment) TableName() string {
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const (
|
||||
REMOTE_BROWSER_TABLE = "remote_browsers"
|
||||
)
|
||||
|
||||
// RemoteBrowser is a gorm data model for saved remote browser scripts.
|
||||
type RemoteBrowser 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;index"`
|
||||
CompanyID *uuid.UUID `gorm:"index;uniqueIndex:idx_remote_browsers_unique_name_and_company_id;type:uuid"`
|
||||
Name string `gorm:"not null;index;uniqueIndex:idx_remote_browsers_unique_name_and_company_id;"`
|
||||
Description string `gorm:"type:text"`
|
||||
Script string `gorm:"type:text;not null;"`
|
||||
Config string `gorm:"type:text;not null;default:'{}'"`
|
||||
|
||||
Company *Company
|
||||
}
|
||||
|
||||
func (e *RemoteBrowser) Migrate(db *gorm.DB) error {
|
||||
return UniqueIndexNameAndNullCompanyID(db, "remote_browsers")
|
||||
}
|
||||
|
||||
func (RemoteBrowser) TableName() string {
|
||||
return REMOTE_BROWSER_TABLE
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const (
|
||||
REPORT_TEMPLATE_TABLE = "report_templates"
|
||||
)
|
||||
|
||||
// ReportTemplate is a gorm data model
|
||||
type ReportTemplate 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;index"`
|
||||
CompanyID *uuid.UUID `gorm:"uniqueIndex;type:uuid"`
|
||||
Content string `gorm:"not null;type:text"`
|
||||
|
||||
Company *Company
|
||||
}
|
||||
|
||||
func (e *ReportTemplate) Migrate(db *gorm.DB) error {
|
||||
// enforce at most one global template (company_id IS NULL)
|
||||
idx := `CREATE UNIQUE INDEX IF NOT EXISTS idx_report_templates_null_company_id ON report_templates ((company_id IS NULL)) WHERE (company_id IS NULL)`
|
||||
return db.Exec(idx).Error
|
||||
}
|
||||
|
||||
func (ReportTemplate) TableName() string {
|
||||
return REPORT_TEMPLATE_TABLE
|
||||
}
|
||||
Reference in New Issue
Block a user