Skip to content

Conversation

@talyguryn
Copy link
Member

add reminder emails for blocked workspaces after 1, 2, 3, 5, 7, 30 after pay day

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.
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.
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.
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.
Replaces the hardcoded value for daysAfterPayday with expect.any(Number) in the blocked-workspace-reminder test payload to allow for dynamic number matching.
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.
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.
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.
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.
Updated the sendBlockedWorkspaceReminders method to use 'daysAfterPayday' instead of 'daysBlocked' for clarity and consistency in parameter naming and payload structure.
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.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a reminder email system for blocked workspaces that send notifications to administrators at specific intervals (1, 2, 3, 5, 7, and 30 days) after the payment due date. The feature extends the existing PaymasterWorker to check if a workspace is blocked and, on designated reminder days, triggers email notifications through the email worker.

Key Changes:

  • Added reminder scheduling logic in PaymasterWorker that checks blocked workspaces against a configured list of reminder days
  • Implemented new email templates (HTML, text, and subject) for blocked workspace reminders in Russian with pluralization support
  • Added test coverage for the reminder functionality on day 5 after payday

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
workers/paymaster/src/index.ts Added DAYS_AFTER_PAYDAY_TO_REMIND constant and sendBlockedWorkspaceReminders() method; modified blocked workspace handling to send reminders on specific days
workers/paymaster/tests/index.test.ts Added test for reminder functionality on day 5; updated existing test date from day 4 to day 5 to avoid conflicts
workers/email/src/templates/names.ts Added BlockedWorkspaceReminder enum entry for the new email template type
workers/email/src/templates/extensions.ts Added pluralize_ru() Twig function for Russian word pluralization based on numeric values
workers/email/src/templates/emails/blocked-workspace-reminder/text.twig Created plain text email template for blocked workspace reminders
workers/email/src/templates/emails/blocked-workspace-reminder/subject.twig Created email subject line template with dynamic day count
workers/email/src/templates/emails/blocked-workspace-reminder/html.twig Created HTML email template with workspace information and billing settings link
workers/email/scripts/emailOverview.ts Added daysAfterPayday to template data and calculateDaysAfterPayday() helper method for email preview functionality; updated Content-Type header to include charset

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

talyguryn and others added 8 commits December 5, 2025 23:42
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.
Added JSDoc comments to the calculateDaysAfterPayday method in EmailTestServer to clarify its purpose and usage. This improves code readability and maintainability.
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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 16 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI commented Dec 6, 2025

@talyguryn I've opened a new pull request, #487, to work on those changes. Once the pull request is ready, I'll request review from you.

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.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 18 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

talyguryn and others added 4 commits December 6, 2025 19:02
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Added missing space after '{{' in variable references in subject and text templates for blocked workspace reminder emails to improve readability and consistency.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 18 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 18 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Refactored the updateLastNoticationDate invocation to occur after Promise.all resolves, ensuring it is called once per method execution rather than for each iteration.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 18 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}
}));

await this.updateLastNoticationDate(workspace, eventType);
Copy link

Copilot AI Dec 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in method name: 'Notication' should be 'Notification'.

Copilot uses AI. Check for mistakes.
Renamed updateLastNoticationDate to updateLastNotificationDate for consistency and correctness across all usages in SenderWorker.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 18 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

neSpecc
neSpecc previously approved these changes Dec 6, 2025
@talyguryn talyguryn merged commit 14bb0e7 into master Dec 6, 2025
6 of 7 checks passed
@talyguryn talyguryn deleted the feat/reminder-email-for-blocked-workspace branch December 6, 2025 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants