|
|
@@ -6,9 +6,6 @@ import escapeStringRegexp from 'escape-string-regexp';
|
|
|
import mongoose, { ObjectId, QueryCursor } from 'mongoose';
|
|
|
import streamToPromise from 'stream-to-promise';
|
|
|
|
|
|
-import {
|
|
|
- SUPPORTED_TARGET_MODEL_TYPE, SUPPORTED_ACTION_TYPE, SupportedActionType, ISnapshot,
|
|
|
-} from '~/interfaces/activity';
|
|
|
import { Ref } from '~/interfaces/common';
|
|
|
import { V5ConversionErrCode } from '~/interfaces/errors/v5-conversion-error';
|
|
|
import { HasObjectId } from '~/interfaces/has-object-id';
|
|
|
@@ -20,7 +17,6 @@ import {
|
|
|
} from '~/interfaces/page-delete-config';
|
|
|
import { IUserHasId } from '~/interfaces/user';
|
|
|
import { PageMigrationErrorData, SocketEventName, UpdateDescCountRawData } from '~/interfaces/websocket';
|
|
|
-import { stringifySnapshot } from '~/models/serializers/in-app-notification-snapshot/page';
|
|
|
import {
|
|
|
CreateMethod, PageCreateOptions, PageModel, PageDocument, pushRevision,
|
|
|
} from '~/server/models/page';
|
|
|
@@ -2147,29 +2143,6 @@ class PageService {
|
|
|
return shortBodiesMap;
|
|
|
}
|
|
|
|
|
|
- private async createAndSendNotifications(user: IUserHasId, target: IPage, action: SupportedActionType) {
|
|
|
- const { activityService, inAppNotificationService } = this.crowi;
|
|
|
-
|
|
|
- // Create activity
|
|
|
- const snapshotForActivity: ISnapshot = { username: user.username };
|
|
|
- const parameters = {
|
|
|
- user: user._id,
|
|
|
- targetModel: SUPPORTED_TARGET_MODEL_TYPE.MODEL_PAGE,
|
|
|
- target,
|
|
|
- action,
|
|
|
- snapshot: snapshotForActivity,
|
|
|
- };
|
|
|
- const activity = await activityService.createByParameters(parameters);
|
|
|
-
|
|
|
- // Get user to be notified
|
|
|
- const targetUsers = await activity.getNotificationTargetUsers();
|
|
|
-
|
|
|
- // Create and send notifications
|
|
|
- const snapshotForInAppNotification = stringifySnapshot(target);
|
|
|
- await inAppNotificationService.upsertByActivity(targetUsers, activity, snapshotForInAppNotification);
|
|
|
- await inAppNotificationService.emitSocketIo(targetUsers);
|
|
|
- }
|
|
|
-
|
|
|
async normalizeParentByPath(path: string, user): Promise<void> {
|
|
|
const Page = mongoose.model('Page') as unknown as PageModel;
|
|
|
const { PageQueryBuilder } = Page;
|