[PB-5977]: feat/integrate MailService for downgrade and upgrade handling#375
[PB-5977]: feat/integrate MailService for downgrade and upgrade handling#375jzunigax2 wants to merge 2 commits into
Conversation
- Added MailService to handle account suspension and reactivation. - Updated .env.template to include MAIL_URL and MAIL_GATEWAY_SECRET. - Modified TiersService to apply and remove mail features based on user tiers. - Enhanced InvoiceCompletedHandler to apply mail features upon invoice completion. - Introduced tests for MailService and updated TiersService tests to cover mail feature logic.
|
|
||
| async reactivateAccount(payload: { customerId: string }): Promise<void> { | ||
| const jwt = signToken('5m', this.config.OBJECT_STORAGE_GATEWAY_SECRET); | ||
| const jwt = signGatewayToken('5m', this.config.OBJECT_STORAGE_GATEWAY_SECRET); |
| }; | ||
|
|
||
| describe('suspendAccount', () => { | ||
| it('When called, then it POSTs to the suspend gateway endpoint with the signed token', async () => { |
| }); | ||
|
|
||
| describe('Enable Mail access based on user tier', () => { | ||
| it('When Mail is enabled, then a request to reactivate the mail account is sent', async () => { |
|
| ) {} | ||
|
|
||
| async suspendAccount(uuid: User['uuid']): Promise<void> { | ||
| await this.axios.post(`${this.config.MAIL_URL}/gateway/accounts/${uuid}/suspend`, {}, this.requestConfig()); |
There was a problem hiding this comment.
This is related to mail, not to here, but, shouldn't this be a PATCH as it is a partial update of the user enabled status field or so?
There was a problem hiding this comment.
It also disables some mail features (e.g. disable send emails, update emails and destroy emails), not just updating a status field. Not sure if PATCH is better. POST is also accepted, don't you think?
There was a problem hiding this comment.
plus a post feels more appropiate to me as its an explicit action /resource/id/suspend, don't you think?
|
Please @jzunigax2 on any PR that needs new environment variables: add a warning to the PR's description. Otherwise, I may ignore it and cause a downtime |


Calls the new mail-server gateway suspend/reactivate endpoints so a user's mail account follows their plan state.
invoice.paid:InvoiceCompletedHandlercallsapplyMailFeaturesafter Drive/VPN, gated onfeaturesPerService[Service.Mail].enabled.TiersService.removeTiernow handlescase Service.Mailreached viahandleCancelPlan.MAIL_URL: base URL of the mail-server gatewayMAIL_GATEWAY_SECRET: matching RSA key pair from mail'sGATEWAY_PUBLIC_SECRETvariable