fix(auth): updating offline subscription end date

This commit is contained in:
Karol Sójko 2022-11-03 14:29:10 +01:00
parent 805e63379c
commit 2504887e8d
No known key found for this signature in database
GPG key ID: A50543BF560BDEB0

View file

@ -37,7 +37,11 @@ export class SubscriptionRenewedEventHandler implements DomainEventHandlerInterf
return
}
await this.updateOfflineSubscriptionEndsAt(offlineUserSubscription, event.payload.timestamp)
await this.updateOfflineSubscriptionEndsAt(
offlineUserSubscription,
event.payload.subscriptionExpiresAt,
event.payload.timestamp,
)
await this.roleService.setOfflineUserRole(offlineUserSubscription)
@ -92,9 +96,10 @@ export class SubscriptionRenewedEventHandler implements DomainEventHandlerInterf
private async updateOfflineSubscriptionEndsAt(
offlineUserSubscription: OfflineUserSubscription,
subscriptionExpiresAt: number,
timestamp: number,
): Promise<void> {
offlineUserSubscription.endsAt = timestamp
offlineUserSubscription.endsAt = subscriptionExpiresAt
offlineUserSubscription.updatedAt = timestamp
await this.offlineUserSubscriptionRepository.save(offlineUserSubscription)