Add nym in reply notification (#349)
Co-authored-by: ekzyis <ek@stacker.news>
This commit is contained in:
parent
422b2ce8b6
commit
5e4dedad28
@ -895,13 +895,15 @@ export default {
|
|||||||
createComment: async (parent, data, { me, models }) => {
|
createComment: async (parent, data, { me, models }) => {
|
||||||
await ssValidate(commentSchema, data)
|
await ssValidate(commentSchema, data)
|
||||||
const item = await createItem(parent, data, { me, models })
|
const item = await createItem(parent, data, { me, models })
|
||||||
|
// fetch user to get up-to-date name
|
||||||
|
const user = await models.user.findUnique({ where: { id: me.id } })
|
||||||
|
|
||||||
const parents = await models.$queryRaw(
|
const parents = await models.$queryRaw(
|
||||||
'SELECT DISTINCT p."userId" FROM "Item" i JOIN "Item" p ON p.path @> i.path WHERE i.id = $1 and p."userId" <> $2',
|
'SELECT DISTINCT p."userId" FROM "Item" i JOIN "Item" p ON p.path @> i.path WHERE i.id = $1 and p."userId" <> $2',
|
||||||
Number(item.parentId), Number(me.id))
|
Number(item.parentId), Number(me.id))
|
||||||
Promise.allSettled(
|
Promise.allSettled(
|
||||||
parents.map(({ userId }) => sendUserNotification(userId, {
|
parents.map(({ userId }) => sendUserNotification(userId, {
|
||||||
title: 'you have a new reply',
|
title: `@${user.name} replied to you`,
|
||||||
body: data.text,
|
body: data.text,
|
||||||
item,
|
item,
|
||||||
tag: 'REPLY'
|
tag: 'REPLY'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user