There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
feat(core): add notification service (#10855)
EYHNa2eb3fe1b2be
diff --git a/packages/frontend/core/src/modules/notification/index.ts b/packages/frontend/core/src/modules/notification/index.tsindex 27b6f6d258..a1f5f97e34 100644--- a/packages/frontend/core/src/modules/notification/index.ts+++ b/packages/frontend/core/src/modules/notification/index.ts@@ -1,18 +1,22 @@export { NotificationCountService } from './services/count';export { NotificationListService } from './services/list';+export { NotificationService } from './services/notification';export type { Notification, NotificationBody } from './stores/notification';export { NotificationType } from './stores/notification';+import type { Framework } from '@toeverything/infra';import { GraphQLService, ServerScope, ServerService } from '../cloud';import { GlobalSessionState } from '../storage';import { NotificationCountService } from './services/count';import { NotificationListService } from './services/list';+import { NotificationService } from './services/notification';import { NotificationStore } from './stores/notification';export function configureNotificationModule(framework: Framework) {framework.scope(ServerScope)+ .service(NotificationService, [NotificationStore]).service(NotificationCountService, [NotificationStore]).service(NotificationListService, [NotificationStore,diff --git a/packages/frontend/core/src/modules/notification/services/notification.ts b/packages/frontend/core/src/modules/notification/services/notification.tsnew file mode 100644index 0000000000..691e67eec7--- /dev/null+++ b/packages/frontend/core/src/modules/notification/services/notification.ts@@ -0,0 +1,24 @@+import type { DocMode } from '@affine/graphql';+import { Service } from '@toeverything/infra';++import type { NotificationStore } from '../stores/notification';++export class NotificationService extends Service {+ constructor(private readonly store: NotificationStore) {+ super();+ }++ async mentionUser(+ userId: string,+ workspaceId: string,+ doc: {+ id: string;+ title: string;+ blockId?: string;+ elementId?: string;+ mode: DocMode;+ }+ ): Promise<string> {+ return this.store.mentionUser(userId, workspaceId, doc);+ }+}diff --git a/packages/frontend/core/src/modules/notification/stores/notification.ts b/packages/frontend/core/src/modules/notification/stores/notification.tsindex b0257808cb..f7f663149f 100644--- a/packages/frontend/core/src/modules/notification/stores/notification.ts+++ b/packages/frontend/core/src/modules/notification/stores/notification.ts@@ -1,6 +1,8 @@import {+ type DocMode,type ListNotificationsQuery,listNotificationsQuery,+ mentionUserMutation,notificationCountQuery,type PaginationInput,readNotificationMutation,@@ -82,4 +84,28 @@ export class NotificationStore extends Store {},});}++ async mentionUser(+ userId: string,+ workspaceId: string,+ doc: {+ id: string;+ title: string;+ blockId?: string;+ elementId?: string;+ mode: DocMode;+ }+ ) {+ const result = await this.gqlService.gql({+ query: mentionUserMutation,+ variables: {+ input: {+ userId,+ workspaceId,+ doc,+ },+ },+ });+ return result.mentionUser;+ }}diff --git a/packages/frontend/graphql/src/graphql/index.ts b/packages/frontend/graphql/src/graphql/index.tsindex 5878d8abc4..c88eb5106d 100644--- a/packages/frontend/graphql/src/graphql/index.ts+++ b/packages/frontend/graphql/src/graphql/index.ts@@ -1107,6 +1107,14 @@ export const listUsersQuery = {}`,};+export const mentionUserMutation = {+ id: 'mentionUserMutation' as const,+ op: 'mentionUser',+ query: `mutation mentionUser($input: MentionInput!) {+ mentionUser(input: $input)+}`,+};+export const notificationCountQuery = {id: 'notificationCountQuery' as const,op: 'notificationCount',diff --git a/packages/frontend/graphql/src/graphql/mention-user.gql b/packages/frontend/graphql/src/graphql/mention-user.gqlnew file mode 100644index 0000000000..01d1db9e73--- /dev/null+++ b/packages/frontend/graphql/src/graphql/mention-user.gql@@ -0,0 +1,3 @@+mutation mentionUser($input: MentionInput!) {+ mentionUser(input: $input)+}\ No newline at end of filediff --git a/packages/frontend/graphql/src/schema.ts b/packages/frontend/graphql/src/schema.tsindex e2405da888..46e78fea25 100644--- a/packages/frontend/graphql/src/schema.ts+++ b/packages/frontend/graphql/src/schema.ts@@ -3424,6 +3424,15 @@ export type ListUsersQuery = {}>;};+export type MentionUserMutationVariables = Exact<{+ input: MentionInput;+}>;++export type MentionUserMutation = {+ __typename?: 'Mutation';+ mentionUser: string;+};+export type NotificationCountQueryVariables = Exact<{ [key: string]: never }>;export type NotificationCountQuery = {@@ -4434,6 +4443,11 @@ export type Mutations =variables: LeaveWorkspaceMutationVariables;response: LeaveWorkspaceMutation;}+ | {+ name: 'mentionUserMutation';+ variables: MentionUserMutationVariables;+ response: MentionUserMutation;+ }| {name: 'publishPageMutation';variables: PublishPageMutationVariables;