mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
feat(core): add notification service (#10855)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
|
||||
3
packages/frontend/graphql/src/graphql/mention-user.gql
Normal file
3
packages/frontend/graphql/src/graphql/mention-user.gql
Normal file
@@ -0,0 +1,3 @@
|
||||
mutation mentionUser($input: MentionInput!) {
|
||||
mentionUser(input: $input)
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user