mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2026-01-20 20:01:22 +00:00
send only one notification for mention and comment
This commit is contained in:
parent
7aa84d1c8a
commit
529a8a6365
@ -91,11 +91,30 @@ const handleContentDataOfPost = async (resolve, root, args, context, resolveInfo
|
||||
|
||||
const handleContentDataOfComment = async (resolve, root, args, context, resolveInfo) => {
|
||||
const idsOfUsers = extractMentionedUsers(args.content)
|
||||
|
||||
const comment = await resolve(root, args, context, resolveInfo)
|
||||
|
||||
if (comment) {
|
||||
await notifyUsers('Comment', comment.id, idsOfUsers, 'mentioned_in_comment', context)
|
||||
const session = context.driver.session()
|
||||
const cypherFindUser = `
|
||||
MATCH (user: User)-[:WROTE]->(:Post)<-[:COMMENTS]-(:Comment { id: $commentId })
|
||||
RETURN user { .id }
|
||||
`
|
||||
const result = await session.run(cypherFindUser, {
|
||||
commentId: comment.id,
|
||||
})
|
||||
session.close()
|
||||
const [postAuthor] = await result.records.map(record => {
|
||||
return record.get('user')
|
||||
})
|
||||
const idsOfUsersExcludingPostAuthor = idsOfUsers.filter(res => !res.equals([postAuthor]))
|
||||
cosole.log('idsOfUsers1')
|
||||
await notifyUsers(
|
||||
'Comment',
|
||||
comment.id,
|
||||
idsOfUsersExcludingPostAuthor,
|
||||
'mentioned_in_comment',
|
||||
context,
|
||||
)
|
||||
}
|
||||
|
||||
return comment
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user