Commit 14bb0e7
Feature: reminder email for blocked workspace (#484)
* Add blocked workspace reminder email template
Introduces a new email template for reminding users about blocked workspaces due to expired or depleted plans. Adds pluralization utility for Russian, updates template names, and includes logic to calculate days since the last payment.
* Send reminder emails to blocked workspace admins
Added logic to send reminder emails to admins of blocked workspaces at specific intervals after payday. Introduced the sendBlockedWorkspaceReminders method and updated tests to cover this new behavior.
* Fix workspace retrieval and header in EmailTestServer
Corrects the Content-Type header to include charset in sendHTML and fixes the getWorkspace method to properly return the workspace document. Also removes a redundant line in calculateDaysAfterPayday.
* Add comments and eslint disables for magic numbers
Added explanatory comments and disabled the @typescript-eslint/no-magic-numbers rule for specific lines in emailOverview.ts and paymaster/src/index.ts where magic numbers are used for date calculations and reminder scheduling.
* Update index.test.ts
* Update test to use expect.any(Number) for daysAfterPayday
Replaces the hardcoded value for daysAfterPayday with expect.any(Number) in the blocked-workspace-reminder test payload to allow for dynamic number matching.
* Move pluralize_ru macro from Twig to TypeScript extension
Removed the utils.twig file and its pluralize_ru macro, replacing it with a TypeScript implementation registered as a Twig function in extensions.ts. Updated all template usages to call pluralize_ru directly, simplifying imports and improving maintainability.
* Refactor blocked workspace reminder days to constant
Introduced DAYS_AFTER_PAYDAY_TO_REMIND constant to define the days after payday when admins are reminded about blocked workspaces. Updated the logic to use this constant for better maintainability and clarity.
* Fix test dates and assertions in PaymasterWorker tests
Updated test dates and moved the blocked-workspace-reminder assertion to the correct test case in index.test.ts. This ensures the tests accurately reflect the intended scenarios and improve test reliability.
* Add test for blocked workspace reminder after payday
Introduces a test to verify that admins are reminded for blocked workspaces with active subscriptions when 3 days have passed since payday. Ensures the reminder includes the correct number of days after payday.
* Rename daysBlocked to daysAfterPayday in reminder method
Updated the sendBlockedWorkspaceReminders method to use 'daysAfterPayday' instead of 'daysBlocked' for clarity and consistency in parameter naming and payload structure.
* Add eslint-disable for magic numbers in pluralize_ru
Added eslint-disable-next-line comments to suppress magic number warnings in the pluralize_ru Twig function. This helps maintain code clarity while adhering to linting rules.
* Update extensions.ts
* Add blocked workspace reminder notification support
Introduces handling for 'blocked-workspace-reminder' tasks in SenderWorker, including new types and template variables. Renames files for consistency and updates type exports to support the new notification event.
* Update provider.ts
* Add documentation to calculateDaysAfterPayday method
Added JSDoc comments to the calculateDaysAfterPayday method in EmailTestServer to clarify its purpose and usage. This improves code readability and maintainability.
* Simplify pluralization logic in blocked workspace emails
Removed redundant ternary check for daysAfterPayday in pluralize_ru calls across HTML, subject, and text templates for blocked workspace reminder emails. This streamlines the template code and ensures consistent pluralization.
* Update workers/email/scripts/emailOverview.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update workers/paymaster/tests/index.test.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update workers/paymaster/src/index.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update workers/paymaster/src/index.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update workers/email/src/templates/emails/blocked-workspace-reminder/subject.twig
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update workers/email/src/templates/emails/blocked-workspace-reminder/text.twig
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update workers/email/src/templates/emails/blocked-workspace-reminder/html.twig
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update workers/sender/types/sender-task/blocked-workspace-reminder.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update workers/sender/types/sender-task/blocked-workspace-reminder.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Add lastChargeDate fallback to calculateDaysAfterPayday in email overview (#485)
* Initial plan
* Add fallback logic for lastChargeDate in calculateDaysAfterPayday
Co-authored-by: talyguryn <15259299+talyguryn@users.noreply.github.com>
* Remove accidentally committed build artifacts
Co-authored-by: talyguryn <15259299+talyguryn@users.noreply.github.com>
* Remove env-test.js build artifact
Co-authored-by: talyguryn <15259299+talyguryn@users.noreply.github.com>
* Fix setMonth mutation issue in calculateDaysAfterPayday
Co-authored-by: talyguryn <15259299+talyguryn@users.noreply.github.com>
* Clean up build artifacts
Co-authored-by: talyguryn <15259299+talyguryn@users.noreply.github.com>
* Move MILLISECONDS_IN_DAY to module level
Co-authored-by: talyguryn <15259299+talyguryn@users.noreply.github.com>
* Stop tracking build artifacts and update gitignore
Co-authored-by: talyguryn <15259299+talyguryn@users.noreply.github.com>
* Fix grammar in MILLISECONDS_IN_DAY comment
Co-authored-by: talyguryn <15259299+talyguryn@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: talyguryn <15259299+talyguryn@users.noreply.github.com>
* Expand test coverage for blocked workspace reminder days (#486)
* Initial plan
* Add comprehensive test coverage for blocked workspace reminder days
Co-authored-by: talyguryn <15259299+talyguryn@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: talyguryn <15259299+talyguryn@users.noreply.github.com>
* Update blocked workspace reminder email text
Revised subject and body to emphasize required action and clarify that error monitoring is not working. The new wording provides clearer instructions for users to renew their subscription.
* Group blocked workspace reminder tests
Refactored blocked workspace reminder tests into a dedicated describe block for better organization and readability.
* Refactor blocked workspace reminder tests
Consolidated repetitive test logic for blocked workspace reminders into a reusable helper function. This improves maintainability and readability of the test suite by reducing code duplication.
* Fix extra closing bracket in test suite
Removed an unnecessary closing bracket in the PaymasterWorker test suite to correct the test structure.
* Refactor payday calculation logic to shared utility
Moved daysBeforePayday and daysAfterPayday functions to a new shared utility file (lib/utils/payday.ts) and updated emailOverview and paymaster worker to use these functions. This reduces code duplication and centralizes payday-related calculations.
* Update workers/sender/src/index.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Fix spacing in blocked workspace email templates
Added missing space after '{{' in variable references in subject and text templates for blocked workspace reminder emails to improve readability and consistency.
* Update index.ts
* Move updateLastNoticationDate call outside conditionals
Refactored the code to call updateLastNoticationDate after processing notifications, regardless of whether the conditional block is entered. This ensures the last notification date is always updated for each workspace and event type.
* Move updateLastNoticationDate call outside Promise.all
Refactored the updateLastNoticationDate invocation to occur after Promise.all resolves, ensuring it is called once per method execution rather than for each iteration.
* Fix typo in updateLastNotificationDate method name
Renamed updateLastNoticationDate to updateLastNotificationDate for consistency and correctness across all usages in SenderWorker.
* Update blocked-workspace-reminder.ts
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: talyguryn <15259299+talyguryn@users.noreply.github.com>1 parent f977eba commit 14bb0e7
18 files changed
Lines changed: 437 additions & 72 deletions
File tree
- lib/utils
- workers
- email
- scripts
- src
- templates
- emails/blocked-workspace-reminder
- paymaster
- src
- tests
- sender
- src
- types
- sender-task
- template-variables
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
147 | 148 | | |
148 | 149 | | |
149 | 150 | | |
| 151 | + | |
150 | 152 | | |
151 | 153 | | |
152 | 154 | | |
| |||
210 | 212 | | |
211 | 213 | | |
212 | 214 | | |
213 | | - | |
| 215 | + | |
214 | 216 | | |
215 | 217 | | |
216 | 218 | | |
| |||
323 | 325 | | |
324 | 326 | | |
325 | 327 | | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
326 | 347 | | |
327 | 348 | | |
328 | 349 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | 18 | | |
24 | 19 | | |
25 | 20 | | |
| |||
33 | 28 | | |
34 | 29 | | |
35 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | 107 | | |
153 | 108 | | |
154 | 109 | | |
| |||
247 | 202 | | |
248 | 203 | | |
249 | 204 | | |
250 | | - | |
| 205 | + | |
251 | 206 | | |
252 | 207 | | |
253 | 208 | | |
254 | 209 | | |
255 | 210 | | |
256 | | - | |
| 211 | + | |
257 | 212 | | |
258 | 213 | | |
259 | 214 | | |
| |||
319 | 274 | | |
320 | 275 | | |
321 | 276 | | |
322 | | - | |
| 277 | + | |
323 | 278 | | |
324 | 279 | | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
325 | 286 | | |
326 | 287 | | |
327 | 288 | | |
| |||
338 | 299 | | |
339 | 300 | | |
340 | 301 | | |
341 | | - | |
| 302 | + | |
342 | 303 | | |
343 | 304 | | |
344 | 305 | | |
| |||
403 | 364 | | |
404 | 365 | | |
405 | 366 | | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
406 | 387 | | |
407 | 388 | | |
408 | 389 | | |
| |||
0 commit comments