Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix old formation subscription check and creation on login #358

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions app/services/subscription.service.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,33 @@ export default class SubscriptionService {
}

private async _createOrUpdateOldFormationSubscription(user: TUser): Promise<void> {
await this.createOrUpdate({
userId: user.id,
courseSlug: convertSubscriptionIdentifierToCourseSlug('oldFormation'),
provider: 'manual',
providerSubscriptionId: `old-formation-${user.id}`,
expiresAt: new Date(2_556_113_460_000),
});
if (user.roles?.some(role =>
role === 'formacao2017'
|| role === 'formacao2018'
|| role === 'formacao20182'
|| role === 'formacaoJan2019'
|| role === 'formacaoMai2019'
|| role === 'formacaoSet2019'
|| role === 'formacaoJan2020'
|| role === 'formacaoMai2020'
|| role === 'formacaoSet2020'
|| role === 'formacaoJan2021',
)) {
await this.createOrUpdate({
userId: user.id,
courseSlug: convertSubscriptionIdentifierToCourseSlug('oldFormation'),
provider: 'manual',
providerSubscriptionId: `old-formation-${user.id}`,
expiresAt: new Date(2_556_113_460_000),
});
} else {
await this.createOrUpdate({
userId: user.id,
courseSlug: convertSubscriptionIdentifierToCourseSlug('oldFormation'),
provider: 'manual',
providerSubscriptionId: `no-oldFormation-${user.id}`,
expiresAt: new Date(946_684_800),
});
}
}
}