feat: add organisations (#1820)

This commit is contained in:
David Nguyen
2025-06-10 11:49:52 +10:00
committed by GitHub
parent 0b37f19641
commit e6dc237ad2
631 changed files with 37616 additions and 25695 deletions

View File

@ -0,0 +1,80 @@
import sharp from 'sharp';
import { getFileServerSide } from '@documenso/lib/universal/upload/get-file.server';
import { prisma } from '@documenso/prisma';
import type { Route } from './+types/branding.logo.team.$teamId';
export async function loader({ params }: Route.LoaderArgs) {
const organisationId = params.orgId;
if (!organisationId) {
return Response.json(
{
status: 'error',
message: 'Invalid organisation ID',
},
{ status: 400 },
);
}
const organisation = await prisma.organisation.findUnique({
where: {
id: organisationId,
},
include: {
organisationGlobalSettings: true,
},
});
const settings = organisation?.organisationGlobalSettings;
if (!settings || !settings.brandingLogo) {
return Response.json(
{
status: 'error',
message: 'Logo not found',
},
{ status: 404 },
);
}
if (!settings.brandingEnabled) {
return Response.json(
{
status: 'error',
message: 'Branding is not enabled',
},
{ status: 400 },
);
}
const file = await getFileServerSide(JSON.parse(settings.brandingLogo)).catch((e) => {
console.error(e);
});
if (!file) {
return Response.json(
{
status: 'error',
message: 'Not found',
},
{ status: 404 },
);
}
const img = await sharp(file)
.toFormat('png', {
quality: 80,
})
.toBuffer();
return new Response(img, {
headers: {
'Content-Type': 'image/png',
'Content-Length': img.length.toString(),
// Stale while revalidate for 1 hours to 24 hours
'Cache-Control': 'public, s-maxage=3600, stale-while-revalidate=86400',
},
});
}

View File

@ -1,7 +1,7 @@
import sharp from 'sharp';
import { getTeamSettings } from '@documenso/lib/server-only/team/get-team-settings';
import { getFileServerSide } from '@documenso/lib/universal/upload/get-file.server';
import { prisma } from '@documenso/prisma';
import type { Route } from './+types/branding.logo.team.$teamId';
@ -18,10 +18,8 @@ export async function loader({ params }: Route.LoaderArgs) {
);
}
const settings = await prisma.teamGlobalSettings.findFirst({
where: {
teamId,
},
const settings = await getTeamSettings({
teamId,
});
if (!settings || !settings.brandingLogo) {