Tweak default list and subscriber entries in install

This commit is contained in:
Kailash Nadh 2020-02-09 11:45:01 +05:30
parent 8616aa8028
commit 6cb2cd7ea2
1 changed files with 26 additions and 4 deletions

View File

@ -49,24 +49,45 @@ func install(app *App, qMap goyesql.Queries, prompt bool) {
}
// Sample list.
var listID int
if err := q.CreateList.Get(&listID,
var (
defList int
optinList int
)
if err := q.CreateList.Get(&defList,
uuid.NewV4().String(),
"Default list",
models.ListTypePublic,
models.ListTypePrivate,
models.ListOptinSingle,
pq.StringArray{"test"},
); err != nil {
logger.Fatalf("Error creating list: %v", err)
}
if err := q.CreateList.Get(&optinList, uuid.NewV4().String(),
"Opt-in list",
models.ListTypePublic,
models.ListOptinDouble,
pq.StringArray{"test"},
); err != nil {
logger.Fatalf("Error creating list: %v", err)
}
// Sample subscriber.
if _, err := q.UpsertSubscriber.Exec(
uuid.NewV4(),
"john@example.com",
"John Doe",
`{"type": "known", "good": true, "city": "Bengaluru"}`,
pq.Int64Array{int64(listID)},
pq.Int64Array{int64(defList)},
); err != nil {
logger.Fatalf("Error creating subscriber: %v", err)
}
if _, err := q.UpsertSubscriber.Exec(
uuid.NewV4(),
"anon@example.com",
"Anon Doe",
`{"type": "unknown", "good": true, "city": "Bengaluru"}`,
pq.Int64Array{int64(optinList)},
); err != nil {
logger.Fatalf("Error creating subscriber: %v", err)
}
@ -92,6 +113,7 @@ func install(app *App, qMap goyesql.Queries, prompt bool) {
sendAt := time.Now()
sendAt.Add(time.Minute * 43200)
if _, err := q.CreateCampaign.Exec(uuid.NewV4(),
models.CampaignTypeRegular,
"Test campaign",
"Welcome to listmonk",
"No Reply <noreply@yoursite.com>",