imporve billing more + supporter prompt on self-hosting

This commit is contained in:
Carl-Gerhard Lindesvärd
2025-11-10 22:35:59 +01:00
parent e9fc9713e4
commit aa0120a79d
10 changed files with 211 additions and 25 deletions

View File

@@ -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: {