Skip to content

Commit

Permalink
fix: mask documents in search
Browse files Browse the repository at this point in the history
  • Loading branch information
Mythie committed Jan 22, 2024
1 parent 1191e1d commit e8c2ca8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 6 additions & 2 deletions packages/lib/server-only/document/get-document-by-token.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { prisma } from '@documenso/prisma';
import { DocumentWithRecipient } from '@documenso/prisma/types/document-with-recipient';
import type { DocumentWithRecipient } from '@documenso/prisma/types/document-with-recipient';

export interface GetDocumentAndSenderByTokenOptions {
token: string;
Expand Down Expand Up @@ -58,7 +58,11 @@ export const getDocumentAndRecipientByToken = async ({
},
},
include: {
Recipient: true,
Recipient: {
where: {
token,
},
},
documentData: true,
},
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { prisma } from '@documenso/prisma';
import { DocumentStatus } from '@documenso/prisma/client';

import { maskRecipientTokensForDocument } from '../../utils/mask-recipient-tokens-for-document';

export type SearchDocumentsWithKeywordOptions = {
query: string;
userId: number;
Expand Down Expand Up @@ -77,5 +79,12 @@ export const searchDocumentsWithKeyword = async ({
take: limit,
});

return documents;
const maskedDocuments = documents.map((document) =>
maskRecipientTokensForDocument({
document,
user,
}),
);

return maskedDocuments;
};

0 comments on commit e8c2ca8

Please sign in to comment.