use team redis keys to resolve team gated features
This commit is contained in:
1 parent
0a4dcebed7
commit
cd2b303e89
7 files changed
+58
-13
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { fetchAccount } from '@/lib/load';
|
||||
import { fetchAccount, fetchTeam } from '@/lib/load';
|
||||
import { parseRequest } from '@/lib/request';
|
||||
import { json } from '@/lib/response';
|
||||
import { getAllUserTeams } from '@/queries/prisma';
|
||||
@@ -20,9 +20,29 @@ export async function POST(request: Request) {
|
||||
user.subscription = {
|
||||
isPro: account.isPro || false,
|
||||
isBusiness: account.isBusiness || false,
|
||||
isNoBilling: account.isNoBilling || false,
|
||||
hasSubscription: account.hasSubscription || false,
|
||||
};
|
||||
}
|
||||
|
||||
const teamsWithSubscription = await Promise.all(
|
||||
teams.map(async (team: any) => {
|
||||
const teamAccount = await fetchTeam(team.id);
|
||||
return {
|
||||
...team,
|
||||
subscription: teamAccount
|
||||
? {
|
||||
isPro: teamAccount.isPro || false,
|
||||
isBusiness: teamAccount.isBusiness || false,
|
||||
isNoBilling: teamAccount.isNoBilling || false,
|
||||
hasSubscription: teamAccount.hasSubscription || false,
|
||||
}
|
||||
: null,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
return json({ ...user, teams: teamsWithSubscription });
|
||||
}
|
||||
|
||||
return json({ ...user, teams });
|
||||
|
||||
Reference in new issue
Block a user