diff --git a/packages/auth/src/Domain/Handler/SubscriptionPurchasedEventHandler.ts b/packages/auth/src/Domain/Handler/SubscriptionPurchasedEventHandler.ts index cde6c4aa3..bcfc560cc 100644 --- a/packages/auth/src/Domain/Handler/SubscriptionPurchasedEventHandler.ts +++ b/packages/auth/src/Domain/Handler/SubscriptionPurchasedEventHandler.ts @@ -34,6 +34,19 @@ export class SubscriptionPurchasedEventHandler implements DomainEventHandlerInte event.payload.timestamp, ) + const renewalResult = await this.renewSharedSubscriptions.execute({ + inviterEmail: event.payload.userEmail, + newSubscriptionId: event.payload.subscriptionId, + newSubscriptionName: event.payload.subscriptionName, + newSubscriptionExpiresAt: event.payload.subscriptionExpiresAt, + timestamp: event.payload.timestamp, + }) + if (renewalResult.isFailed()) { + this.logger.error(`Could not renew shared offline subscriptions: ${renewalResult.getError()}`, { + subscriptionId: event.payload.subscriptionId, + }) + } + await this.roleService.setOfflineUserRole(offlineUserSubscription) return diff --git a/packages/auth/src/Domain/Handler/SubscriptionSyncRequestedEventHandler.ts b/packages/auth/src/Domain/Handler/SubscriptionSyncRequestedEventHandler.ts index 7c7e5e4e4..a8b74463a 100644 --- a/packages/auth/src/Domain/Handler/SubscriptionSyncRequestedEventHandler.ts +++ b/packages/auth/src/Domain/Handler/SubscriptionSyncRequestedEventHandler.ts @@ -51,6 +51,19 @@ export class SubscriptionSyncRequestedEventHandler implements DomainEventHandler event.payload.timestamp, ) + const renewalResult = await this.renewSharedSubscriptions.execute({ + inviterEmail: event.payload.userEmail, + newSubscriptionId: event.payload.subscriptionId, + newSubscriptionName: event.payload.subscriptionName, + newSubscriptionExpiresAt: event.payload.subscriptionExpiresAt, + timestamp: event.payload.timestamp, + }) + if (renewalResult.isFailed()) { + this.logger.error(`Could not renew shared offline subscriptions for user: ${renewalResult.getError()}`, { + subscriptionId: event.payload.subscriptionId, + }) + } + await this.roleService.setOfflineUserRole(offlineUserSubscription) const offlineFeaturesTokenDecoded = this.contentDecoder.decode(