Fix unnecessary $queryRawUnsafe and missing await (#2117)
* Fix unnecessary usage of $queryRawUnsafe * Fix missing await
This commit is contained in:
parent
e94a231192
commit
ff057039f5
@ -248,11 +248,16 @@ export const notifyThreadSubscribers = async ({ models, item }) => {
|
||||
export const notifyItemParents = async ({ models, item }) => {
|
||||
try {
|
||||
const user = await models.user.findUnique({ where: { id: item.userId } })
|
||||
const parents = await models.$queryRawUnsafe(
|
||||
'SELECT DISTINCT p."userId", i."userId" = p."userId" as "isDirect" FROM "Item" i JOIN "Item" p ON p.path @> i.path WHERE i.id = $1 and p."userId" <> $2 ' +
|
||||
'AND NOT EXISTS (SELECT 1 FROM "Mute" m WHERE m."muterId" = p."userId" AND m."mutedId" = $2)',
|
||||
Number(item.parentId), Number(user.id))
|
||||
Promise.allSettled(
|
||||
const parents = await models.$queryRaw`
|
||||
SELECT DISTINCT p."userId", i."userId" = p."userId" as "isDirect"
|
||||
FROM "Item" i
|
||||
JOIN "Item" p ON p.path @> i.path
|
||||
WHERE i.id = ${Number(item.parentId)} and p."userId" <> ${Number(user.id)}
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM "Mute" m
|
||||
WHERE m."muterId" = p."userId" AND m."mutedId" = ${Number(user.id)}
|
||||
)`
|
||||
await Promise.allSettled(
|
||||
parents.map(({ userId, isDirect }) => {
|
||||
return sendUserNotification(userId, {
|
||||
title: `@${user.name} replied to you`,
|
||||
|
Loading…
x
Reference in New Issue
Block a user