-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Irae Hueck Costa
committed
Mar 24, 2024
1 parent
a3e0774
commit 6236c71
Showing
2 changed files
with
45 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,24 @@ import ( | |
) | ||
|
||
|
||
var surveySender string = "[email protected]" | ||
var surveySubject string = "Is counter.dev useful?" | ||
var surveyText string = `Hello %s, | ||
you registered to https://counter.dev/ some days ago. In order to improve the service we would like to ask you three very short questions: https://forms.gle/EFZaq5zKv6YGdPro9 | ||
Feel free to write anything that might be in your mind as a reply to this email as well. | ||
Thank you. Your feedback is appreciated! | ||
Your counter.dev team` | ||
|
||
|
||
|
||
|
||
var passwordRecoverySender string = "[email protected]" | ||
var passwordRecoverSubject string = "Forgot your password?" | ||
var passwordRecoveryContent string = `Hello %s, | ||
You - or possibly someone else - requested to recover your account. Therefore we created an alternative temporary password. | ||
|
@@ -34,10 +52,6 @@ Cheers, | |
The counter.dev team` | ||
|
||
|
||
var passwordRecoverySender string = "[email protected]" | ||
var passwordRecoverSubject string = "Forgot your password?" | ||
|
||
|
||
var uuid2id = map[string]string{} | ||
|
||
type User struct { | ||
|
@@ -412,6 +426,31 @@ func (user User) PasswordRecovery(mailgunSecretApiKey string) error { | |
return nil | ||
} | ||
|
||
func (user User) SendSurvey(mailgunSecretApiKey string) error { | ||
mail, err := user.GetPref("mail") | ||
if err != nil { | ||
return err | ||
} | ||
if mail == "" { | ||
return nil | ||
} | ||
mg := mailgun.NewMailgun("counter.dev", mailgunSecretApiKey) | ||
|
||
body := fmt.Sprintf(surveyText, user.Id) | ||
message := mg.NewMessage(surveySender, surveySubject, body, mail) | ||
message.SetDeliveryTime(time.Now().Add(24 * 2 * time.Second)) | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30) | ||
defer cancel() | ||
|
||
_, _, err = mg.Send(ctx, message) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
|
||
func (user User) RegisterSubscriptionID(subscriptionID string) error{ | ||
_, err := user.redis.Do("HSET", "subscription", user.Id, subscriptionID) | ||
|