Compare commits
1 Commits
feat/admin
...
fix/activa
| Author | SHA1 | Date | |
|---|---|---|---|
| 9758ae345d |
@@ -185,13 +185,20 @@ export class SubscriptionsService {
|
||||
const allBrands = await this.db.select().from(brands).where(eq(brands.isActive, true));
|
||||
|
||||
if (allBrands.length > 0) {
|
||||
await this.db.insert(userBrands).values(
|
||||
allBrands.map((b) => ({
|
||||
userId: sub.userId,
|
||||
subscriptionId: sub.id,
|
||||
brandId: b.id,
|
||||
})),
|
||||
);
|
||||
// Full-plan trials already carry the complete userBrands set for this
|
||||
// same subscription row; activating them must not re-insert (unique
|
||||
// (userId, subscriptionId, brandId) would abort AFTER the status
|
||||
// update above, leaving a half-activated sub and a 500 to the panel).
|
||||
await this.db
|
||||
.insert(userBrands)
|
||||
.values(
|
||||
allBrands.map((b) => ({
|
||||
userId: sub.userId,
|
||||
subscriptionId: sub.id,
|
||||
brandId: b.id,
|
||||
})),
|
||||
)
|
||||
.onConflictDoNothing();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user