This commit is contained in:
m5r
2021-08-01 22:03:49 +08:00
parent 7d34fcd48f
commit 1489f97c14
33 changed files with 147 additions and 313 deletions

View File

@ -9,23 +9,19 @@ const GetConversations = z.object({
recipient: z.string(),
});
export default resolver.pipe(
resolver.zod(GetConversations),
resolver.authorize(),
async ({ recipient }, context) => {
const customer = await getCurrentCustomer(null, context);
const conversation = await db.message.findMany({
where: {
OR: [{ from: recipient }, { to: recipient }],
},
orderBy: { sentAt: Prisma.SortOrder.asc },
});
export default resolver.pipe(resolver.zod(GetConversations), resolver.authorize(), async ({ recipient }, context) => {
const customer = await getCurrentCustomer(null, context);
const conversation = await db.message.findMany({
where: {
OR: [{ from: recipient }, { to: recipient }],
},
orderBy: { sentAt: Prisma.SortOrder.asc },
});
return conversation.map((message) => {
return {
...message,
content: decrypt(message.content, customer!.encryptionKey),
};
});
},
);
return conversation.map((message) => {
return {
...message,
content: decrypt(message.content, customer!.encryptionKey),
};
});
});