From 7e5a2c437752f68d82faefd3e5b79b6374a8d593 Mon Sep 17 00:00:00 2001 From: mngshm Date: Mon, 17 Mar 2025 17:22:46 +0530 Subject: [PATCH] [server](StorageExceedingAlerts) Minor tweaks in multiple files --- server/cmd/museum/main.go | 2 +- .../pkg/controller/email/email_notification.go | 18 +++++++++++------- server/pkg/repo/billing.go | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/server/cmd/museum/main.go b/server/cmd/museum/main.go index e23a2516dc..db6cc1d536 100644 --- a/server/cmd/museum/main.go +++ b/server/cmd/museum/main.go @@ -217,7 +217,7 @@ func main() { billingController := controller.NewBillingController(plans, appStoreController, playStoreController, stripeController, discordController, emailNotificationCtrl, - billingRepo, userRepo, usageRepo, storagBonusRepo, commonBillController) + billingRepo, userRepo, usageRepo, storagBonusRepo, commonBillController, notificationHistoryRepo) pushController := controller.NewPushController(pushRepo, taskLockingRepo, hostName) mailingListsController := controller.NewMailingListsController() diff --git a/server/pkg/controller/email/email_notification.go b/server/pkg/controller/email/email_notification.go index a3c4c54313..20ce91ab4b 100644 --- a/server/pkg/controller/email/email_notification.go +++ b/server/pkg/controller/email/email_notification.go @@ -23,6 +23,7 @@ const ( StorageLimitExceededMailLock = "storage_limit_exceeded_mail_lock" StorageLimitExceededTemplateID = "storage_limit_exceeded" StorageLimitExceededTemplate = "storage_limit_exceeded.html" + StorageLimitExceededSubject = "[Alert] You have exceeded your storage limit" FilesCollectedTemplate = "files_collected.html" FilesCollectedTemplateID = "files_collected" @@ -35,9 +36,12 @@ const ( SubscriptionCancelledTemplate = "subscription_cancelled.html" FilesCollectedMuteDurationInMinutes = 10 - StorageLimitExceededSubject = "[Alert] You have exceeded your storage limit" - ReferralSuccessfulTemplate = "successful_referral.html" - ReferralSuccessfulSubject = "You've earned 10 GB on Ente! 🎁" + ReferralSuccessfulTemplate = "successful_referral.html" + ReferralSuccessfulSubject = "You've earned 10 GB on Ente! 🎁" + + StorageLimitExceedingID = "90_percent_consumed" + StorageLimitExceedingTemplate = "ninety_percent_consumed.html" + StorageLimitExceedingSubject = "Storage About to Exceed!!" LoginSuccessSubject = "New login to your Ente account" LoginSuccessTemplate = "on_login.html" @@ -179,10 +183,10 @@ func (c *EmailNotificationController) SendStorageAlerts() { } defer c.LockController.ReleaseLock(StorageLimitExceededMailLock) - // Notifs struct gets the list of both the users who have consumed + // storageAlertGroups struct gets the list of both the users who have consumed // 90% storage and 100% of their subcriptions. Then, it ranges through // the slices of the both the users and inside this for loop, users from - // both the slices are separately looped. This was done to avoid + // both the slices are separately looped. This is done to avoid // duplication of a lot of code if both the users were ranged inside a loop // separately. storageAlertGroups := []struct { @@ -194,8 +198,8 @@ func (c *EmailNotificationController) SendStorageAlerts() { getListofSubscribers: func() ([]ente.User, error) { return c.UserRepo.GetUsersWithExceedingStorages(90) }, - template: StorageLimitExceededTemplate, - subject: StorageLimitExceededTemplate, + template: StorageLimitExceedingTemplate, + subject: StorageLimitExceedingSubject, }, { getListofSubscribers: func() ([]ente.User, error) { diff --git a/server/pkg/repo/billing.go b/server/pkg/repo/billing.go index d66dce90d7..10bc18dbb8 100644 --- a/server/pkg/repo/billing.go +++ b/server/pkg/repo/billing.go @@ -155,7 +155,7 @@ func (repo *BillingRepository) LogStripePush(eventLog ente.StripeEventLog) error return stacktrace.Propagate(err, "") } -// LogStripePush logs a subscription modification by an admin +// LogAdminTriggeredSubscriptionUpdate logs a subscription modification by an admin func (repo *BillingRepository) LogAdminTriggeredSubscriptionUpdate(r ente.UpdateSubscriptionRequest) error { requestJSON, _ := json.Marshal(r) _, err := repo.DB.Exec(`INSERT INTO subscription_logs(user_id, payment_provider, notification, verification_response) VALUES($1, $2, $3, '{}'::json)`,