diff --git a/models/attachment.go b/models/attachment.go index a3fce358..005e5ce1 100644 --- a/models/attachment.go +++ b/models/attachment.go @@ -22,23 +22,26 @@ type Attachment struct { } // ValidateAttachment ensures that the provided attachment uses the supported template variables correctly. -func (a Attachment) ValidateAttachment() error { +func (a Attachment) Validate() error { - ptx := PhishingTemplateContext{ + vc := ValidationContext{ + FromAddress: "foo@bar.com", + BaseURL: "http://example.com", + } + td := Result{ BaseRecipient: BaseRecipient{ + Email: "foo@bar.com", FirstName: "Foo", LastName: "Bar", - Email: "foo@bar.com", + Position: "Test", }, - BaseURL: "http://testurl.com", - URL: "http://testurl.com/?rid=1234567", - TrackingURL: "http://testurl.local/track?rid=1234567", - Tracker: "", - From: "Foobus Barbus", - RId: "1234567", + RId: "123456", } - - _, err := a.ApplyTemplate(ptx) + ptx, err := NewPhishingTemplateContext(vc, td.BaseRecipient, td.RId) + if err != nil { + return err + } + _, err = a.ApplyTemplate(ptx) return err } diff --git a/models/template.go b/models/template.go index 74eb2314..4010b9e4 100644 --- a/models/template.go +++ b/models/template.go @@ -41,7 +41,7 @@ func (t *Template) Validate() error { return err } for _, a := range t.Attachments { - if err := a.ValidateAttachment(); err != nil { + if err := a.Validate(); err != nil { return err } }