prevent email notifications for blocked users

comment
This commit is contained in:
Ulf Gebhardt 2025-04-03 00:38:07 +02:00
parent 2bd21b8be3
commit cf059cd9d4
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9

View File

@ -321,6 +321,7 @@ const handleCreateMessage = async (resolve, root, args, context, resolveInfo) =>
MATCH (currentUser:User { id: $currentUserId })-[:CHATS_IN]->(room:Room { id: $roomId })
MATCH (room)<-[:CHATS_IN]-(recipientUser:User)-[:PRIMARY_EMAIL]->(emailAddress:EmailAddress)
WHERE NOT recipientUser.id = $currentUserId
AND NOT (recipientUser)-[:BLOCKED]-(currentUser)
RETURN recipientUser, emailAddress {.email}
`
const txResponse = await transaction.run(messageRecipientCypher, {
@ -338,8 +339,8 @@ const handleCreateMessage = async (resolve, root, args, context, resolveInfo) =>
// Execute Query
const { user, email } = await messageRecipient
// Send EMail if not considered online
if (!isUserOnline(user)) {
// Send EMail if we found a user(not blocked) and he is not considered online
if (user && !isUserOnline(user)) {
void sendMail(chatMessageTemplate({ email, variables: { name: user.properties.name } }))
}