-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[email] retention mails for usage consumption #6810
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
base: main
Are you sure you want to change the base?
Conversation
| // deletion for storage limit exceeding email notification | ||
| c.NotificationHistoryRepo.DeleteLastNotification(userID, StorageLimitExceedingTemplateID) | ||
|
|
||
| // deletion for storage limit exceeded email notification | ||
| c.NotificationHistoryRepo.DeleteLastNotification(userID, StorageLimitExceededTemplateID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of cancellation, I think we would want to reset it on account upgrade?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a user cancels their subscription and resubscribes, it will be cleaner to handle that edge case, that's why I did this. Will check on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If they got a notification, and then cancel.. will they again get notification?
I am thinking of this flow
- User is exceeding storage, already got an email
- They cancel.. again they will get an email..
- They upgrade/re-sub. will they again get email?
Just not doing anything on cancellation might be enough. I would be missing certain cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it goes with the flow you have described, for any action on their subscription (incl. cancellation) the notification must be sent again for proactively addressing their storage quota usage. That's why I handled the notification with cancellation too, it's an edge case.
| var lastNotificationTime sql.NullInt64 | ||
| row := repo.DB.QueryRow(`SELECT MAX(sent_time) FROM notification_history WHERE user_id = $1 and template_id = $2`, userID, templateID) | ||
| err := row.Scan(&lastNotificationTime) | ||
| if err != nil { | ||
| return stacktrace.Propagate(err, "") | ||
| } | ||
| if lastNotificationTime.Valid { | ||
| _, err := repo.DB.Exec(` | ||
| DELETE FROM notification_history | ||
| WHERE user_id = $1 AND template_id = $2 AND sent_time = $3 | ||
| `, userID, templateID, lastNotificationTime.Int64) | ||
|
|
||
| if err != nil { | ||
| return stacktrace.Propagate(err, "failed to delete last notification") | ||
| } | ||
| } | ||
| return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just call delete query instead of querying for last instance. It will simplify code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wait, intended to remove those lines, will do.
07d0e7b to
22fa8aa
Compare
| if (storageConsumed) <= (95 * (subStorage + refBonusStorage + addOnBonusStorage) / 100) { | ||
| continue | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If before cron runs (even for existing users), if storageConsumed is > 100%, will they get two emails.. one for exceeding and another for exceeded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed this
Description
This PR adds support for sending notification email for users who are about to exceed storage (95% of utilization incl. bonus, etc.) and deletes notification if the subscription has been altered (deletion, upgrade, downgrade)