mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +10:00
This PR is handles the changes required to support envelopes. The new envelope editor/signing page will be hidden during release. The core changes here is to migrate the documents and templates model to a centralized envelopes model. Even though Documents and Templates are removed, from the user perspective they will still exist as we remap envelopes to documents and templates.
37 lines
924 B
TypeScript
37 lines
924 B
TypeScript
import { DocumentStatus, EnvelopeType, RecipientRole } from '@prisma/client';
|
|
|
|
import { prisma } from '@documenso/prisma';
|
|
|
|
import { authenticatedProcedure } from '../trpc';
|
|
import { ZGetInboxCountRequestSchema, ZGetInboxCountResponseSchema } from './get-inbox-count.types';
|
|
|
|
export const getInboxCountRoute = authenticatedProcedure
|
|
.input(ZGetInboxCountRequestSchema)
|
|
.output(ZGetInboxCountResponseSchema)
|
|
.query(async ({ input, ctx }) => {
|
|
const { readStatus } = input ?? {};
|
|
|
|
const userEmail = ctx.user.email;
|
|
|
|
const count = await prisma.recipient.count({
|
|
where: {
|
|
email: userEmail,
|
|
readStatus,
|
|
role: {
|
|
not: RecipientRole.CC,
|
|
},
|
|
envelope: {
|
|
type: EnvelopeType.DOCUMENT,
|
|
status: {
|
|
not: DocumentStatus.DRAFT,
|
|
},
|
|
deletedAt: null,
|
|
},
|
|
},
|
|
});
|
|
|
|
return {
|
|
count,
|
|
};
|
|
});
|