From 296089efc99442c7bebc19be259a12ade9325981 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Fri, 4 Jul 2025 16:04:18 +0800 Subject: [PATCH] feat(core): add comment notification settings (#13029) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ![image](https://github.com/user-attachments/assets/1b239592-1c0d-4575-ad3b-bfb3d0c873c8) #### PR Dependency Tree * **PR #13029** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) ## Summary by CodeRabbit * **New Features** * Added an option in user settings to enable or disable email notifications for comments on your documents. * Updated the user interface to include a toggle for comment email notifications. * Extended GraphQL queries and schema to support the new comment email notification setting. * **Localization** * Added new English translations for comment email notification settings. --- .../src/__tests__/utils/user-settings.ts | 1 + .../src/core/user/__tests__/resolver.e2e.ts | 31 +++++++++++++++++++ .../graphql/src/graphql/get-user-settings.gql | 3 +- packages/common/graphql/src/graphql/index.ts | 1 + packages/common/graphql/src/schema.ts | 1 + .../general-setting/notifications/index.tsx | 11 +++++++ packages/frontend/i18n/src/i18n.gen.ts | 8 +++++ packages/frontend/i18n/src/resources/en.json | 2 ++ 8 files changed, 57 insertions(+), 1 deletion(-) diff --git a/packages/backend/server/src/__tests__/utils/user-settings.ts b/packages/backend/server/src/__tests__/utils/user-settings.ts index 30beda004..563dc60c5 100644 --- a/packages/backend/server/src/__tests__/utils/user-settings.ts +++ b/packages/backend/server/src/__tests__/utils/user-settings.ts @@ -14,6 +14,7 @@ export async function getUserSettings( settings { receiveInvitationEmail receiveMentionEmail + receiveCommentEmail } } } diff --git a/packages/backend/server/src/core/user/__tests__/resolver.e2e.ts b/packages/backend/server/src/core/user/__tests__/resolver.e2e.ts index ecec8417b..d9db42523 100644 --- a/packages/backend/server/src/core/user/__tests__/resolver.e2e.ts +++ b/packages/backend/server/src/core/user/__tests__/resolver.e2e.ts @@ -23,6 +23,7 @@ test('should get user settings', async t => { t.deepEqual(settings, { receiveInvitationEmail: true, receiveMentionEmail: true, + receiveCommentEmail: true, }); }); @@ -31,11 +32,13 @@ test('should update user settings', async t => { await updateUserSettings(app, { receiveInvitationEmail: false, receiveMentionEmail: false, + receiveCommentEmail: false, }); const settings = await getUserSettings(app); t.deepEqual(settings, { receiveInvitationEmail: false, receiveMentionEmail: false, + receiveCommentEmail: false, }); await updateUserSettings(app, { @@ -45,6 +48,7 @@ test('should update user settings', async t => { t.deepEqual(settings2, { receiveInvitationEmail: false, receiveMentionEmail: true, + receiveCommentEmail: false, }); await updateUserSettings(app, { @@ -55,6 +59,33 @@ test('should update user settings', async t => { t.deepEqual(settings3, { receiveInvitationEmail: false, receiveMentionEmail: true, + receiveCommentEmail: false, + }); +}); + +test('should update user settings with comment email', async t => { + await app.signup(); + + await updateUserSettings(app, { + receiveCommentEmail: true, + }); + + const settings = await getUserSettings(app); + t.deepEqual(settings, { + receiveCommentEmail: true, + receiveInvitationEmail: true, + receiveMentionEmail: true, + }); + + await updateUserSettings(app, { + receiveCommentEmail: false, + }); + + const settings2 = await getUserSettings(app); + t.deepEqual(settings2, { + receiveCommentEmail: false, + receiveInvitationEmail: true, + receiveMentionEmail: true, }); }); diff --git a/packages/common/graphql/src/graphql/get-user-settings.gql b/packages/common/graphql/src/graphql/get-user-settings.gql index 7dc59e57f..9f2002734 100644 --- a/packages/common/graphql/src/graphql/get-user-settings.gql +++ b/packages/common/graphql/src/graphql/get-user-settings.gql @@ -3,6 +3,7 @@ query getUserSettings { settings { receiveInvitationEmail receiveMentionEmail + receiveCommentEmail } } -} \ No newline at end of file +} diff --git a/packages/common/graphql/src/graphql/index.ts b/packages/common/graphql/src/graphql/index.ts index 014badd11..b86d79002 100644 --- a/packages/common/graphql/src/graphql/index.ts +++ b/packages/common/graphql/src/graphql/index.ts @@ -1558,6 +1558,7 @@ export const getUserSettingsQuery = { settings { receiveInvitationEmail receiveMentionEmail + receiveCommentEmail } } }`, diff --git a/packages/common/graphql/src/schema.ts b/packages/common/graphql/src/schema.ts index b858db634..57e825eaa 100644 --- a/packages/common/graphql/src/schema.ts +++ b/packages/common/graphql/src/schema.ts @@ -4714,6 +4714,7 @@ export type GetUserSettingsQuery = { __typename?: 'UserSettingsType'; receiveInvitationEmail: boolean; receiveMentionEmail: boolean; + receiveCommentEmail: boolean; }; } | null; }; diff --git a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/notifications/index.tsx b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/notifications/index.tsx index a37bb016d..159831f82 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/notifications/index.tsx +++ b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/notifications/index.tsx @@ -95,6 +95,17 @@ export const NotificationSettings = () => { } /> + + handleUpdate('receiveCommentEmail', checked)} + /> + ); diff --git a/packages/frontend/i18n/src/i18n.gen.ts b/packages/frontend/i18n/src/i18n.gen.ts index 745ce92b0..166fa208c 100644 --- a/packages/frontend/i18n/src/i18n.gen.ts +++ b/packages/frontend/i18n/src/i18n.gen.ts @@ -4825,6 +4825,14 @@ export function useAFFiNEI18N(): { * `Invitation related messages will be sent through emails.` */ ["com.affine.setting.notifications.email.invites.subtitle"](): string; + /** + * `Comments` + */ + ["com.affine.setting.notifications.email.comments.title"](): string; + /** + * `You will be notified through email when other members of the workspace comment on your docs.` + */ + ["com.affine.setting.notifications.email.comments.subtitle"](): string; /** * `Account settings` */ diff --git a/packages/frontend/i18n/src/resources/en.json b/packages/frontend/i18n/src/resources/en.json index 45e825d9d..bfd57723a 100644 --- a/packages/frontend/i18n/src/resources/en.json +++ b/packages/frontend/i18n/src/resources/en.json @@ -1199,6 +1199,8 @@ "com.affine.setting.notifications.email.mention.subtitle": "You will be notified through email when other members of the workspace @ you.", "com.affine.setting.notifications.email.invites.title": "Invites", "com.affine.setting.notifications.email.invites.subtitle": "Invitation related messages will be sent through emails.", + "com.affine.setting.notifications.email.comments.title": "Comments", + "com.affine.setting.notifications.email.comments.subtitle": "You will be notified through email when other members of the workspace comment on your docs.", "com.affine.setting.account": "Account settings", "com.affine.setting.account.delete": "Delete your account", "com.affine.setting.account.delete.message": "Once deleted, your account will no longer be accessible, and all data in your personal cloud space will be permanently deleted.",