mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 12:55:00 +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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user