Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[server] nudge paid users to use family

Keerthana9937b9f096f3
diff --git a/server/cmd/museum/main.go b/server/cmd/museum/main.go
index 742d098397..5e5daef7ed 100644
--- a/server/cmd/museum/main.go
+++ b/server/cmd/museum/main.go
@@ -995,6 +995,10 @@ func setupAndStartCrons(userAuthRepo *repo.UserAuthRepository, publicCollectionR
emailNotificationCtrl.SayHelloToCustomers()
})
+ scheduleAndRun(c, "@every 24h", func() {
+ emailNotificationCtrl.NudgePaidSubscriberForFamily()
+ })
+
schedule(c, "@every 1m", func() {
pushController.SendPushes()
})
diff --git a/server/go.mod b/server/go.mod
index 32cb90bfca..9c0870c71f 100644
--- a/server/go.mod
+++ b/server/go.mod
@@ -11,6 +11,7 @@ require (
github.com/aws/aws-sdk-go v1.34.13
github.com/bwmarrin/discordgo v0.25.0
github.com/dlmiddlecote/sqlstats v1.0.2
+ github.com/ente-io/go-srp v0.0.0-20250116115009-d52061067e78
github.com/ente-io/stacktrace v0.0.0-20210619050357-0af9fad4639c
github.com/gin-contrib/gzip v0.0.5
github.com/gin-contrib/requestid v0.0.2-0.20210619060739-3f23d9a07dc5
@@ -19,7 +20,6 @@ require (
github.com/go-playground/validator/v10 v10.14.0
github.com/golang-jwt/jwt v3.2.1+incompatible
github.com/golang-migrate/migrate/v4 v4.12.2
- github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.6.0
github.com/lib/pq v1.8.0
github.com/lithammer/shortuuid/v3 v3.0.4
@@ -48,12 +48,12 @@ require (
cloud.google.com/go/longrunning v0.4.1 // indirect
github.com/bytedance/sonic v1.9.1 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
- github.com/ente-io/go-srp v0.0.0-20250116115009-d52061067e78 // indirect
github.com/fxamacker/cbor/v2 v2.6.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/go-webauthn/x v0.1.9 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
+ github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-tpm v0.9.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
diff --git a/server/go.sum b/server/go.sum
index 4dbb603da8..a75c347709 100644
--- a/server/go.sum
+++ b/server/go.sum
@@ -583,8 +583,6 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
-github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
-github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stripe/stripe-go/v72 v72.37.0 h1:y/PW0SeIk17S1uq6tQ0RdyeizG1anZlvowMZ4AQ17YY=
diff --git a/server/mail-templates/family_nudge.html b/server/mail-templates/family_nudge.html
new file mode 100644
index 0000000000..98a48c554e
--- /dev/null
+++ b/server/mail-templates/family_nudge.html
@@ -0,0 +1,143 @@
+<!DOCTYPE html>
+<html>
+ <meta content="text/html; charset=utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1,
+ minimum-scale=1" />
+ <style>
+ body {
+ background-color: #f0f1f3;
+ font-family: "Helvetica Neue", "Segoe UI", Helvetica, sans-serif;
+ font-size: 16px;
+ line-height: 27px;
+ margin: 0;
+ color: #444;
+ }
+
+ pre {
+ background: #f4f4f4f4;
+ padding: 2px;
+ }
+
+ table {
+ width: 100%;
+ border: 1px solid #ddd;
+ }
+
+ table td {
+ border-color: #ddd;
+ padding: 5px;
+ }
+
+ .wrap {
+ background-color: #fff;
+ padding: 30px;
+ max-width: 525px;
+ margin: 0 auto;
+ border-radius: 5px;
+ }
+
+ .button {
+ background: #0055d4;
+ border-radius: 3px;
+ text-decoration: none !important;
+ color: #fff !important;
+ font-weight: bold;
+ padding: 10px 30px;
+ display: inline-block;
+ }
+
+ .button:hover {
+ background: #111;
+ }
+
+ .footer {
+ text-align: center;
+ font-size: 12px;
+ color: #888;
+ }
+
+ .footer a {
+ color: #888;
+ margin-right: 5px;
+ }
+
+ .gutter {
+ padding: 30px;
+ }
+
+ img {
+ max-width: 100%;
+ height: auto;
+ }
+
+ a {
+ color: #0055d4;
+ }
+
+ a:hover {
+ color: #111;
+ }
+
+ @media screen and (max-width: 600px) {
+ .wrap {
+ max-width: auto;
+ }
+
+ .gutter {
+ padding: 10px;
+ }
+ }
+
+ .footer-icons {
+ padding: 4px !important;
+ width: 24px !important;
+ }
+ </style>
+
+ <body>
+ <div class="gutter" style="padding: 4px">&nbsp;</div>
+ <div class="wrap" style=" background-color: rgb(255, 255, 255); padding: 2px
+ 30px 30px 30px; max-width: 525px; margin: 0 auto; border-radius: 5px;
+ font-size: 16px; " >
+ <p>Hello there,</p>
+ <p>
+ Your subscription includes our family plan where you can share your
+ subscription with upto 5 additional members at no extra cost.
+ </p>
+ <p>
+ You can add family members to your account by going to
+ Settings -> Manage Subscriptions -> Manage Family.
+ </p>
+ <p>For more information, you can also visit our <a href="https://help.ente.io" target="_blank">help page</a> or reach out to <a href="mailto:[email protected]">[email protected]</a>
+ </div>
+ <br />
+ <div class="footer" style="text-align: center; font-size: 12px; color:
+ rgb(136, 136, 136)" >
+ <div>
+ <a href="https://ente.io" target="_blank" ><img
+ src="https://email-assets.ente.io/ente-green.png" style="width: 100px;
+ padding: 24px" title="Ente" alt="Ente" /></a>
+ </div>
+ <div>
+ <a href="https://fosstodon.org/@ente" target="_blank" ><img
+ src="https://email-assets.ente.io/mastodon-icon.png"
+ class="footer-icons" style="width: 24px; padding: 4px" title="Mastodon"
+ alt="Mastodon" /></a>
+ <a href="https://twitter.com/enteio" target="_blank" ><img
+ src="https://email-assets.ente.io/twitter-icon.png" class="footer-icons"
+ style="width: 24px; padding: 4px" title="Twitter" alt="Twitter" /></a>
+ <a href="https://discord.ente.io" target="_blank" ><img
+ src="https://email-assets.ente.io/discord-icon.png" class="footer-icons"
+ style="width: 24px; padding: 4px" title="Discord" alt="Discord" /></a>
+ <a href="https://github.com/ente-io" target="_blank" ><img
+ src="https://email-assets.ente.io/github-icon.png" class="footer-icons"
+ style="width: 24px; padding: 4px" title="GitHub" alt="GitHub" /></a>
+ </div>
+ <p>
+ Ente Technologies, Inc.
+ <br /> 1111B S Governors Ave 6032 Dover, DE 19904
+ </p>
+ <br />
+ </div>
+ </body>
+</html>
diff --git a/server/pkg/controller/email/email_notification.go b/server/pkg/controller/email/email_notification.go
index a825f61b12..3f6ab25d86 100644
--- a/server/pkg/controller/email/email_notification.go
+++ b/server/pkg/controller/email/email_notification.go
@@ -44,6 +44,11 @@ const (
LoginSuccessSubject = "New login to your Ente account"
LoginSuccessTemplate = "on_login.html"
+
+ FamilyNudgeMailLock = "family_nudge_mail_lock"
+ FamilyNudgeTemplate = "family_nudge.html"
+ FamilyNudgeSubject = "Share your Ente Subscription with your Family!"
+ FamilyNudgeTemplateID = "family_nudge"
)
type EmailNotificationController struct {
@@ -245,3 +250,47 @@ func (c *EmailNotificationController) SendStorageLimitExceededMails() {
func (c *EmailNotificationController) setStorageLimitExceededMailerJobStatus(isSending bool) {
c.isSendingStorageLimitExceededMails = isSending
}
+
+func (c *EmailNotificationController) NudgePaidSubscriberForFamily() {
+ log.Info("Running NudgePaidSubscriberForFamily")
+ lockStatus := c.LockController.TryLock(FamilyNudgeMailLock, time.MicrosecondsAfterHours(24))
+ if !lockStatus {
+ log.Error("Could not acquire lock to send family nudge mails")
+ return
+ }
+ defer c.LockController.ReleaseLock(FamilyNudgeMailLock)
+
+ users, err := c.UserRepo.GetUsersWhoUpgradedNDaysAgo(30)
+ if err != nil {
+ log.Error("Error while fetching users", err)
+ return
+ }
+ for _, u := range users {
+ lastNotificationTime, err := c.NotificationHistoryRepo.GetLastNotificationTime(u.ID, FamilyNudgeTemplateID)
+ logger := log.WithFields(log.Fields{
+ "user_id": u.ID,
+ "email": u.Email,
+ })
+
+ if err != nil {
+ logger.Error("Could not fetch last notification time", err)
+ continue
+ }
+
+ if lastNotificationTime > 0 {
+ continue
+ }
+
+ if u.FamilyAdminID != nil {
+ continue
+ }
+
+ logger.Info("Sending family nudge mail to paid subscriber")
+ err = email.SendTemplatedEmail([]string{u.Email}, "[email protected]", "[email protected]", FamilyNudgeSubject, FamilyNudgeTemplate, nil, nil)
+ if err != nil {
+ logger.Info("Error notifying", err)
+ continue
+ }
+ c.NotificationHistoryRepo.SetLastNotificationTimeToNow(u.ID, FamilyNudgeTemplateID)
+ }
+}