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));
|
const allBrands = await this.db.select().from(brands).where(eq(brands.isActive, true));
|
||||||
|
|
||||||
if (allBrands.length > 0) {
|
if (allBrands.length > 0) {
|
||||||
await this.db.insert(userBrands).values(
|
// Full-plan trials already carry the complete userBrands set for this
|
||||||
allBrands.map((b) => ({
|
// same subscription row; activating them must not re-insert (unique
|
||||||
userId: sub.userId,
|
// (userId, subscriptionId, brandId) would abort AFTER the status
|
||||||
subscriptionId: sub.id,
|
// update above, leaving a half-activated sub and a 500 to the panel).
|
||||||
brandId: b.id,
|
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