feat: new billing and restrict access when trial has ended
* fix: simply billing * fix usage graph * imporve billing more + supporter prompt on self-hosting * revert service change * revert query builder * fix: comments
This commit is contained in:
committed by
GitHub
parent
bbd30ca6e0
commit
9cafd61b25
@@ -5,7 +5,11 @@ import { importQueue } from '@openpanel/queue';
|
||||
import { zCreateImport } from '@openpanel/validation';
|
||||
|
||||
import { getProjectAccess } from '../access';
|
||||
import { TRPCAccessError } from '../errors';
|
||||
import {
|
||||
TRPCAccessError,
|
||||
TRPCBadRequestError,
|
||||
TRPCNotFoundError,
|
||||
} from '../errors';
|
||||
import { createTRPCRouter, protectedProcedure } from '../trpc';
|
||||
|
||||
export const importRouter = createTRPCRouter({
|
||||
@@ -69,6 +73,28 @@ export const importRouter = createTRPCRouter({
|
||||
);
|
||||
}
|
||||
|
||||
const organization = await db.organization.findFirst({
|
||||
where: {
|
||||
projects: {
|
||||
some: {
|
||||
id: input.projectId,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!organization) {
|
||||
throw TRPCNotFoundError(
|
||||
'Could not start import, organization not found',
|
||||
);
|
||||
}
|
||||
|
||||
if (!organization.isActive) {
|
||||
throw TRPCBadRequestError(
|
||||
'You cannot start an import without an active subscription!',
|
||||
);
|
||||
}
|
||||
|
||||
// Create import record
|
||||
const importRecord = await db.import.create({
|
||||
data: {
|
||||
|
||||
Reference in New Issue
Block a user