fix(auth): add renewal for shared offline subscriptions

This commit is contained in:
Karol Sójko 2024-01-15 12:42:54 +01:00
parent c7217a92ba
commit 045358ddbf
No known key found for this signature in database
GPG key ID: C2F813669419D05F
2 changed files with 26 additions and 0 deletions

View file

@ -34,6 +34,19 @@ export class SubscriptionPurchasedEventHandler implements DomainEventHandlerInte
event.payload.timestamp, 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) await this.roleService.setOfflineUserRole(offlineUserSubscription)
return return

View file

@ -51,6 +51,19 @@ export class SubscriptionSyncRequestedEventHandler implements DomainEventHandler
event.payload.timestamp, 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) await this.roleService.setOfflineUserRole(offlineUserSubscription)
const offlineFeaturesTokenDecoded = this.contentDecoder.decode( const offlineFeaturesTokenDecoded = this.contentDecoder.decode(