Files
zeekayandHanzo Dev 1a76145191 Hanzo Marketing: lifecycle email, from one place
The web app for /v1/marketing on api.hanzo.ai (audiences, drip sequences and
their steps, enrollments, campaigns, the send calendar, promos and opt-outs)
and the small Go service beside it. Earlier history is kept privately in
hanzoai/marketing-v1.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-15 11:36:13 -07:00

79 lines
1.5 KiB
Go

package model
import (
"github.com/hanzoai/commerce/datastore"
"github.com/hanzoai/commerce/models/mixin"
"github.com/hanzoai/orm"
)
func init() { orm.Register[Copy]("copy") }
type CopyType string
const (
HeadlineType CopyType = "headline"
ContentType CopyType = "content"
)
type Copy struct {
mixin.Model[Copy]
AdIntegration
Type CopyType `json:"type" orm:"default:content"`
Text string `json:"text" datastore:",noindex"`
ParentCopyId string `json:"parentCopyId"`
// Only for filters and searches, don't rely on this after you get it out
// of the db. Always check m.ParentCopyId != "".
IsParent bool `json:"isParent"`
}
func (m Copy) Fork() *Copy {
m2 := NewCopy(m.Datastore())
m2.AdIntegration = m.AdIntegration
m2.Type = m.Type
m2.Text = m.Text
m2.ParentCopyId = m.Id()
m2.IsParent = false
return m2
}
func (m *Copy) Load(ps []datastore.Property) (err error) {
// Ensure we're initialized
if m.Type == "" {
m.Type = ContentType
}
// Load supported properties
return datastore.LoadStruct(m, ps)
}
func (m *Copy) Save() (ps []datastore.Property, err error) {
// Serialize unsupported properties
m.IsParent = m.ParentCopyId != ""
// Save properties
return datastore.SaveStruct(m)
}
func (m Copy) GetParentCopyId() string {
return m.ParentCopyId
}
func (m Copy) GetCopySearchFieldAndIds() (string, []string) {
return "ParentCopyId", []string{m.Id()}
}
func NewCopy(db *datastore.Datastore) *Copy {
a := new(Copy)
a.Init(db)
return a
}
func QueryCopy(db *datastore.Datastore) datastore.Query {
return db.Query("copy")
}