-
Notifications
You must be signed in to change notification settings - Fork 1
Feature: reminder email for blocked workspace #484
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
Merged
Merged
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
2452285
Add blocked workspace reminder email template
talyguryn 130decc
Send reminder emails to blocked workspace admins
talyguryn a830c39
Fix workspace retrieval and header in EmailTestServer
talyguryn a02732b
Add comments and eslint disables for magic numbers
talyguryn 91a3014
Update index.test.ts
talyguryn 9a564e0
Update test to use expect.any(Number) for daysAfterPayday
talyguryn 89bac2c
Move pluralize_ru macro from Twig to TypeScript extension
talyguryn dd71fc5
Refactor blocked workspace reminder days to constant
talyguryn bbf8538
Fix test dates and assertions in PaymasterWorker tests
talyguryn e9155f4
Add test for blocked workspace reminder after payday
talyguryn 994ff1e
Rename daysBlocked to daysAfterPayday in reminder method
talyguryn 088e2b6
Add eslint-disable for magic numbers in pluralize_ru
talyguryn b229817
Update extensions.ts
talyguryn 8dabf96
Add blocked workspace reminder notification support
talyguryn b518d55
Update provider.ts
talyguryn ec8e589
Add documentation to calculateDaysAfterPayday method
talyguryn 8d12c54
Simplify pluralization logic in blocked workspace emails
talyguryn 3823bd5
Update workers/email/scripts/emailOverview.ts
talyguryn b38e439
Update workers/paymaster/tests/index.test.ts
talyguryn 9760aca
Update workers/paymaster/src/index.ts
talyguryn 597303b
Update workers/paymaster/src/index.ts
talyguryn 41b0bd7
Update workers/email/src/templates/emails/blocked-workspace-reminder/…
talyguryn 09464e0
Update workers/email/src/templates/emails/blocked-workspace-reminder/…
talyguryn e49c1e8
Update workers/email/src/templates/emails/blocked-workspace-reminder/…
talyguryn 05fea23
Update workers/sender/types/sender-task/blocked-workspace-reminder.ts
talyguryn 2553e95
Update workers/sender/types/sender-task/blocked-workspace-reminder.ts
talyguryn 6c668bc
Add lastChargeDate fallback to calculateDaysAfterPayday in email over…
Copilot 6c51cee
Expand test coverage for blocked workspace reminder days (#486)
Copilot cc3aa58
Update blocked workspace reminder email text
talyguryn fae76fb
Merge branch 'feat/reminder-email-for-blocked-workspace' of https://g…
talyguryn e209790
Group blocked workspace reminder tests
talyguryn cf3dcd3
Refactor blocked workspace reminder tests
talyguryn f8bf2a5
Fix extra closing bracket in test suite
talyguryn 25b910a
Refactor payday calculation logic to shared utility
talyguryn a65c54e
Update workers/sender/src/index.ts
talyguryn 28617cb
Fix spacing in blocked workspace email templates
talyguryn 6a8a1bd
Merge branch 'feat/reminder-email-for-blocked-workspace' of https://g…
talyguryn e86a2b3
Update index.ts
talyguryn 29928fa
Move updateLastNoticationDate call outside conditionals
talyguryn 9aa5af2
Move updateLastNoticationDate call outside Promise.all
talyguryn 3fb0dbc
Fix typo in updateLastNotificationDate method name
talyguryn 4e082d8
Update blocked-workspace-reminder.ts
talyguryn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import { HOURS_IN_DAY, MINUTES_IN_HOUR, SECONDS_IN_MINUTE, MS_IN_SEC } from './consts'; | ||
|
|
||
| /** | ||
| * Milliseconds in day. Needs for calculating difference between dates in days. | ||
| */ | ||
| const MILLISECONDS_IN_DAY = HOURS_IN_DAY * MINUTES_IN_HOUR * SECONDS_IN_MINUTE * MS_IN_SEC; | ||
|
|
||
| /** | ||
| * Returns difference between now and payday in days | ||
| * | ||
| * Pay day is calculated by formula: paidUntil date or last charge date + 1 month | ||
| * | ||
| * @param date - last charge date | ||
| * @param paidUntil - paid until date | ||
| * @param isDebug - flag for debug purposes | ||
| */ | ||
| export function daysBeforePayday(date: Date, paidUntil: Date = null, isDebug = false): number { | ||
| const expectedPayDay = paidUntil ? new Date(paidUntil) : new Date(date); | ||
|
|
||
| if (isDebug) { | ||
| expectedPayDay.setDate(date.getDate() + 1); | ||
| } else if (!paidUntil) { | ||
| expectedPayDay.setMonth(date.getMonth() + 1); | ||
| } | ||
|
|
||
| const now = new Date().getTime(); | ||
|
|
||
| return Math.floor((expectedPayDay.getTime() - now) / MILLISECONDS_IN_DAY); | ||
| } | ||
|
|
||
| /** | ||
| * Returns difference between payday and now in days | ||
| * | ||
| * Pay day is calculated by formula: paidUntil date or last charge date + 1 month | ||
| * | ||
| * @param date - last charge date | ||
| * @param paidUntil - paid until date | ||
| * @param isDebug - flag for debug purposes | ||
| */ | ||
| export function daysAfterPayday(date: Date, paidUntil: Date = null, isDebug = false): number { | ||
| const expectedPayDay = paidUntil ? new Date(paidUntil) : new Date(date); | ||
|
|
||
| if (isDebug) { | ||
| expectedPayDay.setDate(date.getDate() + 1); | ||
| } else if (!paidUntil) { | ||
| expectedPayDay.setMonth(date.getMonth() + 1); | ||
| } | ||
|
|
||
| const now = new Date().getTime(); | ||
|
|
||
| return Math.floor((now - expectedPayDay.getTime()) / MILLISECONDS_IN_DAY); | ||
| } |
This file contains hidden or 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 hidden or 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
39 changes: 39 additions & 0 deletions
39
workers/email/src/templates/emails/blocked-workspace-reminder/html.twig
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| {% extends '../../components/layout.twig' %} | ||
|
|
||
| {% block header %} | ||
| {% include '../../components/workspace.twig' with {workspace: workspace} %} | ||
| {% endblock %} | ||
|
|
||
| {% block content %} | ||
| <tr> | ||
| <td> | ||
| <img src="{{ hostOfStatic }}/email/low-balance-icon.png" width="32" height="32" hspace="3" style="display: block; vertical-align: middle; margin: 23px auto 0;"> | ||
| </td> | ||
| </tr> | ||
| <tr> | ||
| <td align="center" style="padding: 15px 0;"> | ||
| <font color="#dbe6ff" style="font-size: 15px; text-align: center; color: #dbe6ff; letter-spacing: 0.4px;"> | ||
| <span style="vertical-align: middle; display: inline-block;"> | ||
| {{ daysAfterPayday }} {{ pluralize_ru(daysAfterPayday, ['день', 'дня', 'дней']) }} без мониторинга | ||
| </span> | ||
| </font> | ||
| </td> | ||
| </tr> | ||
| <tr> | ||
| <td style="display: block; padding: 20px; margin-bottom: 30px; border-width: 1px; border-color: #494f5e; border-style: solid; border-radius: 10px; line-height: 1.47"> | ||
| <font color="#dbe6ff" style="font-size: 15px; letter-spacing: 0.4px;"> | ||
| <p style="margin-top: 0;"> | ||
| Напоминаем, что мониторинг ошибок в «{{ workspace.name | escape }}» всё ещё остановлен, потому что закончился лимит или срок действия тарифного плана. | ||
| </p> | ||
| <p style="margin-bottom: 0;"> | ||
| Чтобы снова видеть актуальные события, выберите подходящий тарифный план и продлите подписку в настройках оплаты. | ||
| </p> | ||
| </font> | ||
| </td> | ||
| </tr> | ||
| <tr> | ||
| <td style="padding-right: 20px; padding-left: 20px; padding-bottom: 40px;"> | ||
| {% include '../../components/button.twig' with {href: host ~ '/workspace/' ~ workspace._id ~ '/settings/billing', label: workspace.tariffPlanId is same as('5f47f031ff71510040f433c1') ? 'Выбрать тариф от 99 ₽' : 'Открыть настройки'} %} | ||
| </td> | ||
| </tr> | ||
| {% endblock %} |
1 change: 1 addition & 0 deletions
1
workers/email/src/templates/emails/blocked-workspace-reminder/subject.twig
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Требуется действие: мониторинг ошибок в {{ workspace.name }} не работает уже {{ daysAfterPayday }} {{ pluralize_ru(daysAfterPayday, ['день', 'дня', 'дней']) }} |
10 changes: 10 additions & 0 deletions
10
workers/email/src/templates/emails/blocked-workspace-reminder/text.twig
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| Требуется действие: мониторинг ошибок в {{ workspace.name }} не работает уже {{ daysAfterPayday }} {{ pluralize_ru(daysAfterPayday, ['день', 'дня', 'дней']) }} | ||
|
|
||
| Чтобы снова видеть актуальные события, выберите подходящий тарифный план и продлите подписку в настройках оплаты: {{ host }}/workspace/{{ workspace._id }}/settings/billing | ||
|
|
||
| *** | ||
|
|
||
| Хоук | ||
| Российский трекер ошибок | ||
|
|
||
| Made by CodeX |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.