setting for emailNotificationsChatMessage

This commit is contained in:
Ulf Gebhardt 2025-04-07 23:24:17 +02:00
parent ad96e08e68
commit 574da51327
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
5 changed files with 27 additions and 5 deletions

View File

@ -1,4 +1,4 @@
import { getDriver } from '../../db/neo4j'
import { getDriver } from '../neo4j'
export const description =
'Transforms the `sendNotificationEmails` property on User to a multi value system'
@ -14,6 +14,7 @@ export async function up(next) {
MATCH (user:User)
SET user.emailNotificationsCommentOnObservedPost = user.sendNotificationEmails
SET user.emailNotificationsMention = user.sendNotificationEmails
SET user.emailNotificationsChatMessage = user.sendNotificationEmails
SET user.emailNotificationsGroupMemberJoined = user.sendNotificationEmails
SET user.emailNotificationsGroupMemberLeft = user.sendNotificationEmails
SET user.emailNotificationsGroupMemberRemoved = user.sendNotificationEmails
@ -46,6 +47,7 @@ export async function down(next) {
SET user.sendNotificationEmails = true
REMOVE user.emailNotificationsCommentOnObservedPost
REMOVE user.emailNotificationsMention
REMOVE user.emailNotificationsChatMessage
REMOVE user.emailNotificationsGroupMemberJoined
REMOVE user.emailNotificationsGroupMemberLeft
REMOVE user.emailNotificationsGroupMemberRemoved

View File

@ -44,7 +44,6 @@ const publishNotifications = async (context, promises, emailNotificationSetting:
notifications.forEach((notificationAdded, index) => {
pubsub.publish(NOTIFICATION_ADDED, { notificationAdded })
if (notificationAdded.to[emailNotificationSetting] ?? true) {
// Default to true
sendMail(
notificationTemplate({
email: notificationsEmailAddresses[index].email,
@ -356,7 +355,7 @@ const handleCreateMessage = async (resolve, root, args, context, resolveInfo) =>
MATCH (room)<-[:CHATS_IN]-(recipientUser:User)-[:PRIMARY_EMAIL]->(emailAddress:EmailAddress)
WHERE NOT recipientUser.id = $currentUserId
AND NOT (recipientUser)-[:BLOCKED]-(currentUser)
AND recipientUser.sendNotificationEmails = true
AND NOT recipientUser.emailNotificationsChatMessage = false
RETURN recipientUser, emailAddress {.email}
`
const txResponse = await transaction.run(messageRecipientCypher, {

View File

@ -165,6 +165,10 @@ export default {
type: 'boolean',
default: true,
},
emailNotificationsChatMessage: {
type: 'boolean',
default: true,
},
emailNotificationsGroupMemberJoined: {
type: 'boolean',
default: true,

View File

@ -676,6 +676,15 @@ describe('emailNotificationSettings', () => {
},
],
},
{
type: 'chat',
settings: [
{
name: 'chatMessage',
value: true,
},
],
},
{
type: 'group',
settings: [

View File

@ -160,8 +160,7 @@ export default {
const allowedSettingNames = [
'commentOnObservedPost',
'mention',
'postByFollowedUser',
'postInGroup',
'chatMessage',
'groupMemberJoined',
'groupMemberLeft',
'groupMemberRemoved',
@ -396,6 +395,15 @@ export default {
},
],
},
{
type: 'chat',
settings: [
{
name: 'chatMessage',
value: parent.emailNotificationsChatMessage ?? true,
},
],
},
{
type: 'group',
settings: [