hotfix: team billing on batch operations (#15570)
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
This commit is contained in:
1 parent
e33930e5c0
commit
4f944ec12d
2 files changed
+18
-17
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { updateQuantitySubscriptionFromStripe } from "@calcom/features/ee/teams/lib/payments";
|
||||
import { isOrganisationAdmin } from "@calcom/lib/server/queries/organisations";
|
||||
import { ProfileRepository } from "@calcom/lib/server/repository/profile";
|
||||
import { prisma } from "@calcom/prisma";
|
||||
@@ -62,7 +63,7 @@ export async function bulkDeleteUsersHandler({ ctx, input }: BulkDeleteUsersHand
|
||||
// We do this in a transaction to make sure that all memberships are removed before we remove the organization relation from the user
|
||||
// We also do this to make sure that if one of the queries fail, the whole transaction fails
|
||||
await prisma.$transaction([removeProfiles, deleteMany, removeOrgrelation]);
|
||||
|
||||
await updateQuantitySubscriptionFromStripe(currentUser.organizationId);
|
||||
return {
|
||||
success: true,
|
||||
usersDeleted: input.userIds.length,
|
||||
|
||||
@@ -18,18 +18,18 @@ import type { TInviteMemberInputSchema } from "./inviteMember.schema";
|
||||
import type { TeamWithParent } from "./types";
|
||||
import {
|
||||
checkPermissions,
|
||||
getTeamOrThrow,
|
||||
getUniqueUsernameOrEmailsOrThrow,
|
||||
createMemberships,
|
||||
createNewUsersConnectToOrgIfExists,
|
||||
getExistingUsersToInvite,
|
||||
getOrgConnectionInfo,
|
||||
getOrgState,
|
||||
sendSignupToOrganizationEmail,
|
||||
getExistingUsersToInvite,
|
||||
createNewUsersConnectToOrgIfExists,
|
||||
createMemberships,
|
||||
getTeamOrThrow,
|
||||
getUniqueUsernameOrEmailsOrThrow,
|
||||
groupUsersByJoinability,
|
||||
sendExistingUserTeamInviteEmails,
|
||||
sendEmails,
|
||||
INVITE_STATUS,
|
||||
sendEmails,
|
||||
sendExistingUserTeamInviteEmails,
|
||||
sendSignupToOrganizationEmail,
|
||||
} from "./utils";
|
||||
|
||||
const log = logger.getSubLogger({ prefix: ["inviteMember.handler"] });
|
||||
@@ -151,7 +151,7 @@ export const inviteMemberHandler = async ({ ctx, input }: InviteMemberOptions) =
|
||||
isOrg: input.isOrg,
|
||||
});
|
||||
});
|
||||
sendEmails(sendVerifEmailsPromises);
|
||||
await sendEmails(sendVerifEmailsPromises);
|
||||
}
|
||||
|
||||
const organization = ctx.user.profile.organization;
|
||||
@@ -166,13 +166,8 @@ export const inviteMemberHandler = async ({ ctx, input }: InviteMemberOptions) =
|
||||
orgSlug,
|
||||
});
|
||||
|
||||
if (IS_TEAM_BILLING_ENABLED) {
|
||||
if (team.parentId) {
|
||||
await updateQuantitySubscriptionFromStripe(team.parentId);
|
||||
} else {
|
||||
await updateQuantitySubscriptionFromStripe(input.teamId);
|
||||
}
|
||||
}
|
||||
await handleSubscriptionUpdates(team.parentId || input.teamId);
|
||||
|
||||
return {
|
||||
...input,
|
||||
numUsersInvited:
|
||||
@@ -180,6 +175,11 @@ export const inviteMemberHandler = async ({ ctx, input }: InviteMemberOptions) =
|
||||
};
|
||||
};
|
||||
|
||||
async function handleSubscriptionUpdates(teamId: number) {
|
||||
if (!IS_TEAM_BILLING_ENABLED) return;
|
||||
await updateQuantitySubscriptionFromStripe(teamId);
|
||||
}
|
||||
|
||||
export default inviteMemberHandler;
|
||||
|
||||
async function handleExistingUsersInvites({
|
||||
|
||||
Reference in new issue
Block a user