Open platform to collect and prioritize feedback
feature: send welcome email on signup
goenning846214530b38
diff --git a/app/handlers/signup.go b/app/handlers/signup.goindex a8df45d24..38f5a966e 100644--- a/app/handlers/signup.go+++ b/app/handlers/signup.go@@ -42,7 +42,7 @@ func CheckAvailability() web.HandlerFunc {}}-//CreateTenant creates a new tenant+// CreateTenant creates a new tenantfunc CreateTenant() web.HandlerFunc {return func(c *web.Context) error {if env.Config.SignUpDisabled {@@ -79,6 +79,8 @@ func CreateTenant() web.HandlerFunc {Role: enum.RoleAdministrator,}+ siteURL := web.TenantBaseURL(c, c.Tenant())+if socialSignUp {user.Name = action.UserClaims.OAuthNameuser.Email = action.UserClaims.OAuthEmail@@ -112,14 +114,18 @@ func CreateTenant() web.HandlerFunc {return c.Failure(err)}- c.Enqueue(tasks.SendSignUpEmail(action, web.TenantBaseURL(c, createTenant.Result)))+ c.Enqueue(tasks.SendSignUpEmail(action, siteURL))+ }++ if status == enum.TenantActive && user.Email != "" {+ c.Enqueue(tasks.SendWelcomeEmail(user.Name, user.Email, siteURL))}return c.Ok(web.Map{})}}-//SignUp is the entry point for installation / signup+// SignUp is the entry point for installation / signupfunc SignUp() web.HandlerFunc {return func(c *web.Context) error {if env.Config.SignUpDisabled {@@ -186,6 +192,8 @@ func VerifySignUpKey() web.HandlerFunc {webutil.AddAuthUserCookie(c, user)+ c.Enqueue(tasks.SendWelcomeEmail(user.Name, user.Email, c.BaseURL()))+return c.Redirect(c.BaseURL())}}diff --git a/app/jobs/trial_reminder_job.go b/app/jobs/trial_reminder_job.goindex af24659a4..1e2fc9d15 100644--- a/app/jobs/trial_reminder_job.go+++ b/app/jobs/trial_reminder_job.go@@ -47,7 +47,7 @@ func (e TrialReminderJobHandler) Run(ctx Context) error {if len(to) > 0 {bus.Publish(ctx, &cmd.SendMail{From: dto.Recipient{- Name: "Guilherme",+ Name: "Guilherme from Fider",Address: "[email protected]",},To: to,diff --git a/app/tasks/signup.go b/app/tasks/signup.goindex d8555a604..791ec198b 100644--- a/app/tasks/signup.go+++ b/app/tasks/signup.go@@ -9,7 +9,7 @@ import ("github.com/getfider/fider/app/pkg/worker")-//SendSignUpEmail is used to send the sign up email to requestor+// SendSignUpEmail is used to send the sign up email to requestorfunc SendSignUpEmail(action *actions.CreateTenant, baseURL string) worker.Task {return describe("Send sign up email", func(c *worker.Context) error {to := dto.NewRecipient(action.Name, action.Email, dto.Props{@@ -28,3 +28,27 @@ func SendSignUpEmail(action *actions.CreateTenant, baseURL string) worker.Task {return nil})}++// SendWelcomeEmail is used to send a welcome email to new tenant admin+func SendWelcomeEmail(name, email, baseURL string) worker.Task {+ return describe("Send welcome email", func(c *worker.Context) error {+ to := dto.NewRecipient(name, email, dto.Props{+ "name": name,+ "url": link(baseURL, "/"),+ })++ bus.Publish(c, &cmd.SendMail{+ From: dto.Recipient{+ Name: "Guilherme from Fider",+ Address: "[email protected]",+ },+ To: []dto.Recipient{to},+ TemplateName: "welcome_email",+ Props: dto.Props{+ "logo": web.LogoURL(c),+ },+ })++ return nil+ })+}diff --git a/views/email/welcome_email.html b/views/email/welcome_email.htmlnew file mode 100644index 000000000..5a993f261--- /dev/null+++ b/views/email/welcome_email.html@@ -0,0 +1,24 @@+{{define "subject"}}Welcome to Fider! π{{end}}++{{define "body"}}+<tr>+ <td style="color:#1c262d">+ <h2>Hey {{ .name }} π,</h2>+ <p>Thanks for giving Fider a go.</p>+ <p>You can now start collecting ideas and suggestions from your customers and clients without hassle.</p>+ <p>Reach out to your audience and invite them to join in by sharing this link through email, Facebook, Twitter or any other platform they may be on.</p>+ <p></p>+ <p>π {{ .url | html }}</p>+ <p></p>+ <p>I'm here to support you in any way I can, let me know if you have any questions or need help with something.</p>+ <p></p>+ <p>+ Best,+ <br/>+ Guilherme+ <br/>+ Founder Β· Fider.io+ </p>+ </td>+</tr>+{{end}}\ No newline at end of file