Skip to content

[server] Retention emails #5550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 36 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
cfa02f6
[server](SendFamilyNudge) method to get list of all subscribed users
mngshm Mar 5, 2025
2b28661
[server](SendFamilyNudge) Modify repo func to get subscribed users wi…
mngshm Mar 7, 2025
50ab944
[server](SendFamilyNudge) controller method to send emails to user wi…
mngshm Mar 7, 2025
3fc24d1
[server](SendFamilyNudge) record email nudge time in notification_his…
mngshm Mar 8, 2025
a726941
[server](StorageExceedingAlerts) refactor/modify existing method to r…
mngshm Mar 10, 2025
ba2ae29
[server](StorageExceedingAlerts) struct to loop through slices of set…
mngshm Mar 11, 2025
66d9c10
[server](StorageExceedingAlerts) handle bonus storage separately
mngshm Mar 13, 2025
763217c
[server](ServerExceedingAlerts) fix improper SetlastNotificationTimeT…
mngshm Mar 13, 2025
e1a0c1c
[server](StorageExceedingAlerts) Better struct name
mngshm Mar 13, 2025
709a375
[server](StorageExceedingAlerts) repo func to delete record from noti…
mngshm Mar 17, 2025
f27a2c6
[server](StorageExceedingAlerts) Delete user's record from notificati…
mngshm Mar 17, 2025
7e5a2c4
[server](StorageExceedingAlerts) Minor tweaks in multiple files
mngshm Mar 17, 2025
6474ff2
Update Comment
mngshm Mar 28, 2025
8bab350
Comment
mngshm Apr 3, 2025
611d268
Family nudge email template
mngshm Apr 18, 2025
edf6bae
90% storage exceeded email template
mngshm Apr 18, 2025
4623e05
update subject, notification ID's
mngshm Apr 18, 2025
df8ca46
turn off OnFirstFIleUpload email trigger
mngshm Apr 19, 2025
8e31384
remove unnecessary log statement
mngshm Apr 21, 2025
e7b5815
minor fix
mngshm Apr 21, 2025
20a26ea
Delete entry from table whenever there is a change in subscription
mngshm Apr 22, 2025
ab5c02d
delete last notification time from table after successful execution o…
mngshm Apr 22, 2025
f609cef
modify code to pass timeDuration as parameter to get list of users
mngshm Apr 23, 2025
ccfd7ab
remove batching
mngshm Apr 24, 2025
5d5e418
remove Dependency injection and functionality for DeleteLastNotificat…
mngshm Apr 24, 2025
0f24ba0
refactor: dedup code
mngshm Apr 25, 2025
abe0ef0
fix query, add filter for deleted users, switch temporarily to u.crea…
mngshm Apr 25, 2025
a2643f2
turn off the cron for SendFamilyNudge temporarily
mngshm Apr 25, 2025
0e435b6
simplify family nudge email
ua741 Apr 25, 2025
daf1d63
Fix typo & minor refactor
ua741 Apr 25, 2025
8b02edb
Fix query & add doc
ua741 Apr 25, 2025
d5b137e
clean up
ua741 Apr 25, 2025
70c8576
Fix bug in GetUsersWithExceedingStorages
ua741 Apr 25, 2025
6b92bac
Merge branch 'main' into retention-emails
ua741 Apr 29, 2025
aa3d852
Avoid spinning go routines for individual emails
ua741 Apr 29, 2025
c93f9ad
rename
ua741 Apr 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions server/cmd/museum/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"database/sql"
b64 "encoding/base64"
"fmt"
"github.com/ente-io/museum/pkg/controller/collections"
"net/http"
"os"
"os/signal"
Expand All @@ -15,6 +14,8 @@ import (
"syscall"
"time"

"github.com/ente-io/museum/pkg/controller/collections"

"github.com/ente-io/museum/ente/base"
"github.com/ente-io/museum/pkg/controller/emergency"
"github.com/ente-io/museum/pkg/controller/file_copy"
Expand Down Expand Up @@ -983,9 +984,8 @@ func setupAndStartCrons(userAuthRepo *repo.UserAuthRepository, publicCollectionR
_ = castDb.DeleteUnclaimedCodes(context.Background(), timeUtil.MicrosecondsBeforeMinutes(60))
dataCleanupCtrl.DeleteDataCron()
})

schedule(c, "@every 24h", func() {
emailNotificationCtrl.SendStorageLimitExceededMails()
emailNotificationCtrl.SendStorageAlerts()
})

schedule(c, "@every 1m", func() {
Expand All @@ -996,6 +996,10 @@ func setupAndStartCrons(userAuthRepo *repo.UserAuthRepository, publicCollectionR
pushController.ClearExpiredTokens()
})

// schedule(c, "@every 3s", func() {
// emailNotificationCtrl.SendFamilyNudgeEmail()
// })

scheduleAndRun(c, "@every 60m", func() {
emergencyCtrl.SendRecoveryReminder()
kexCtrl.DeleteOldKeys()
Expand Down
144 changes: 144 additions & 0 deletions server/mail-templates/90_percent_storage_consumed.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<!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>
<p>
You have used 90% of your available storage on Ente Photos. All your photos on Ente will continue to remain safe and accessible. However, new photos will not be backed up after you get to 100%.
</p>
<p>
Please upgrade your plan so that all the new photos you take can be backed up. You can also use our referral program to get more storage at no additional cost.
</p>
<p>
For any help, please reach out to [email protected] or reply to this email.
</p>
</p>
</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>
139 changes: 139 additions & 0 deletions server/mail-templates/nudge_for_family.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<!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>
Your subscription includes our family plan where you can share your subscription with upto 5 additional members at no extra cost. <br>
<br>
You can add family members to your account by going to Settings -> Manage Subscriptions -> Manage Family. For more information, you can also visit
<a href="https://help.ente.io/photos/features/family-plans">our help page</a> or reach out to [email protected]
</p>
</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>
4 changes: 3 additions & 1 deletion server/pkg/controller/billing.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import (
"database/sql"
"errors"
"fmt"
"github.com/ente-io/museum/pkg/controller/commonbilling"
"strconv"

"github.com/ente-io/museum/pkg/controller/commonbilling"

"github.com/ente-io/museum/pkg/repo/storagebonus"

"github.com/ente-io/museum/pkg/controller/discord"
Expand Down Expand Up @@ -292,6 +293,7 @@ func (c *BillingController) VerifySubscription(
if err != nil {
return ente.Subscription{}, stacktrace.Propagate(err, "")
}

log.Info("Replaced subscription")
newSubscription.ID = currentSubscription.ID
if paymentProvider == ente.PlayStore &&
Expand Down
Loading