mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
Implemented Email Domains which allows Platform/Enterprise customers to send emails to recipients using their custom emails.
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { getInternalClaimPlans } from '@documenso/ee/server-only/stripe/get-internal-claim-plans';
|
|
import { getSubscription } from '@documenso/ee/server-only/stripe/get-subscription';
|
|
import { IS_BILLING_ENABLED } from '@documenso/lib/constants/app';
|
|
import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error';
|
|
|
|
import { authenticatedProcedure } from '../trpc';
|
|
import { ZGetSubscriptionRequestSchema } from './get-subscription.types';
|
|
|
|
export const getSubscriptionRoute = authenticatedProcedure
|
|
.input(ZGetSubscriptionRequestSchema)
|
|
.query(async ({ ctx, input }) => {
|
|
const { organisationId } = input;
|
|
|
|
ctx.logger.info({
|
|
input: {
|
|
organisationId,
|
|
},
|
|
});
|
|
|
|
const userId = ctx.user.id;
|
|
|
|
if (!IS_BILLING_ENABLED()) {
|
|
throw new AppError(AppErrorCode.INVALID_REQUEST, {
|
|
message: 'Billing is not enabled',
|
|
});
|
|
}
|
|
|
|
const [subscription, plans] = await Promise.all([
|
|
getSubscription({
|
|
organisationId,
|
|
userId,
|
|
}),
|
|
getInternalClaimPlans(),
|
|
]);
|
|
|
|
return {
|
|
subscription,
|
|
plans,
|
|
};
|
|
});
|