Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

Removed trial emails

Matt Roberts22ef1b631204
diff --git a/.gitignore b/.gitignore
index cb09769c8..951d627fb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,3 +22,5 @@ cover.out
coverage.tmp
tsconfig.tsbuildinfo
etc/*.pem
+fider_schema.sql
+fider.sql
diff --git a/app/cmd/server.go b/app/cmd/server.go
index fcfbeec20..5269ae40d 100644
--- a/app/cmd/server.go
+++ b/app/cmd/server.go
@@ -62,14 +62,6 @@ func startJobs(ctx context.Context) {
if env.IsBillingEnabled() {
_ = c.AddJob(jobs.NewJob(ctx, "LockExpiredTenantsJob", jobs.LockExpiredTenantsJobHandler{}))
- _ = c.AddJob(jobs.NewJob(ctx, "TrialReminder7DaysJob", jobs.TrialReminderJobHandler{
- Days: 7,
- TemplateName: "trial_7days",
- }))
- _ = c.AddJob(jobs.NewJob(ctx, "TrialReminder1DayJob", jobs.TrialReminderJobHandler{
- Days: 1,
- TemplateName: "trial_1day",
- }))
}
c.Start()
diff --git a/app/jobs/trial_reminder_job.go b/app/jobs/trial_reminder_job.go
deleted file mode 100644
index fa5ce44a8..000000000
--- a/app/jobs/trial_reminder_job.go
+++ /dev/null
@@ -1,62 +0,0 @@
-package jobs
-
-import (
- "fmt"
- "time"
-
- "github.com/getfider/fider/app/models/cmd"
- "github.com/getfider/fider/app/models/dto"
- "github.com/getfider/fider/app/models/query"
- "github.com/getfider/fider/app/pkg/bus"
- "github.com/getfider/fider/app/pkg/env"
- "github.com/getfider/fider/app/pkg/web"
-)
-
-type TrialReminderJobHandler struct {
- Days int
- TemplateName string
-}
-
-func (e TrialReminderJobHandler) Schedule() string {
- return "0 0 7 * * *" // every day at 7:00 AM
-}
-
-func (e TrialReminderJobHandler) Run(ctx Context) error {
- if ctx.LastSuccessfulRun == nil {
- // this is the first run, we can skip it
- return nil
- }
-
- date := time.Now().AddDate(0, 0, e.Days)
- q := &query.GetTrialingTenantContacts{
- TrialExpiresOn: date,
- }
-
- if err := bus.Dispatch(ctx, q); err != nil {
- return err
- }
-
- to := make([]dto.Recipient, 0)
- for _, contact := range q.Contacts {
- to = append(to, dto.NewRecipient(contact.Name, contact.Email, dto.Props{
- "url": fmt.Sprintf("https://%s.%s", contact.Tenant.Subdomain, env.Config.HostDomain),
- "name": contact.Name,
- }))
- }
-
- if len(to) > 0 {
- bus.Publish(ctx, &cmd.SendMail{
- From: dto.Recipient{
- Name: "Fider",
- Address: "[email protected]",
- },
- To: to,
- TemplateName: e.TemplateName,
- Props: dto.Props{
- "logo": web.LogoURL(ctx),
- },
- })
- }
-
- return nil
-}
diff --git a/app/jobs/trial_reminder_job_test.go b/app/jobs/trial_reminder_job_test.go
deleted file mode 100644
index 0046ba1d2..000000000
--- a/app/jobs/trial_reminder_job_test.go
+++ /dev/null
@@ -1,64 +0,0 @@
-package jobs_test
-
-import (
- "context"
- "testing"
- "time"
-
- "github.com/getfider/fider/app/jobs"
- "github.com/getfider/fider/app/models/cmd"
- "github.com/getfider/fider/app/models/dto"
- "github.com/getfider/fider/app/models/entity"
- "github.com/getfider/fider/app/models/query"
- . "github.com/getfider/fider/app/pkg/assert"
- "github.com/getfider/fider/app/pkg/bus"
-)
-
-func TestTrialReminderJob_Schedule_IsCorrect(t *testing.T) {
- RegisterT(t)
-
- job := &jobs.TrialReminderJobHandler{}
- Expect(job.Schedule()).Equals("0 0 7 * * *")
-}
-
-func TestTrialReminderJob_DoNothingOnFirstRun(t *testing.T) {
- RegisterT(t)
-
- job := &jobs.TrialReminderJobHandler{}
- err := job.Run(jobs.Context{
- Context: context.Background(),
- })
- Expect(err).IsNil()
-}
-
-func TestTrialReminderJob_ShouldSendEmailsToTrialingContacts(t *testing.T) {
- RegisterT(t)
-
- bus.AddHandler(func(ctx context.Context, q *query.GetTrialingTenantContacts) error {
- q.Contacts = []*entity.User{
- {Name: "user1", Email: "[email protected]", Tenant: &entity.Tenant{Subdomain: "demo1"}},
- {Name: "user2", Email: "[email protected]", Tenant: &entity.Tenant{Subdomain: "demo2"}},
- }
- return nil
- })
-
- bus.AddListener(func(ctx context.Context, c *cmd.SendMail) error {
- Expect(c.TemplateName).Equals("trial_1day")
- Expect(c.To).Equals([]dto.Recipient{
- {Name: "user1", Address: "[email protected]", Props: dto.Props{"name": "user1", "url": "https://demo1.test.fider.io"}},
- {Name: "user2", Address: "[email protected]", Props: dto.Props{"name": "user2", "url": "https://demo2.test.fider.io"}},
- })
- return nil
- })
-
- lastRun := time.Now()
- job := &jobs.TrialReminderJobHandler{
- Days: 1,
- TemplateName: "trial_1day",
- }
- err := job.Run(jobs.Context{
- Context: context.Background(),
- LastSuccessfulRun: &lastRun,
- })
- Expect(err).IsNil()
-}
diff --git a/views/email/trial_1day.html b/views/email/trial_1day.html
deleted file mode 100644
index 1324845e8..000000000
--- a/views/email/trial_1day.html
+++ /dev/null
@@ -1,14 +0,0 @@
-{{define "subject"}}{{ .url }} is about to expire: Update Now!{{end}}
-
-{{define "body"}}
-<tr>
- <td>
- <h2 style="color:#1c262d">Hey {{ .name }},</h2>
- <p style="color:#1c262d">Just a gently reminder that your Fider site <a href="{{ .url }}">{{ .url }}</a> will expire tomorrow and you won’t be able to access your site anymore.</p>
- <p style="color:#1c262d">You can subscribe from the <a href="{{ .url }}/admin/billing">Billing</a> page of your site.</p>
- <p style="color:#1c262d">Let me know if you have any questions or need any assistance!</p>
- <p></p>
- <p style="color:#1c262d"> - Guilherme</p>
- </td>
-</tr>
-{{end}}
\ No newline at end of file
diff --git a/views/email/trial_7days.html b/views/email/trial_7days.html
deleted file mode 100644
index 57d64e8f9..000000000
--- a/views/email/trial_7days.html
+++ /dev/null
@@ -1,16 +0,0 @@
-{{define "subject"}}{{ .url }} expires in 7 days!{{end}}
-
-{{define "body"}}
-<tr>
- <td>
- <h2 style="color:#1c262d">Hey {{ .name }},</h2>
- <p style="color:#1c262d">It’s been a fun journey, but unfortunately, we’re coming to the end of your trial period. We’d love to keep this going!</p>
- <p style="color:#1c262d">In order to keep <a href="{{ .url }}">{{ .url }}</a> online, you’ll need to subscribe to our paid plan.</p>
- <p style="color:#1c262d">Otherwise, your trial will end in 7 days and you won’t be able to access your site anymore.</p>
- <p style="color:#1c262d">You can subscribe from the <a href="{{ .url }}/admin/billing">Billing</a> page of your site.</p>
- <p style="color:#1c262d">Let me know if you have any questions or need any assistance!</p>
- <p></p>
- <p style="color:#1c262d"> - Guilherme</p>
- </td>
-</tr>
-{{end}}
\ No newline at end of file