Răsfoiți Sursa

Merge pull request #4439 from weseek/imprv/#77970-remove-unnecessary-code

Imprv/#77970 remove unnecessary code
Yuki Takei 4 ani în urmă
părinte
comite
efcc2be495

+ 0 - 46
packages/app/src/server/models/activity.ts

@@ -1,4 +1,3 @@
-import { DeleteWriteOpResultObject } from 'mongodb';
 import {
   Types, Document, Model, Schema,
 } from 'mongoose';
@@ -13,7 +12,6 @@ import Subscription from './subscription';
 
 const logger = loggerFactory('growi:models:activity');
 
-const mongoose = require('mongoose');
 
 export interface ActivityDocument extends Document {
   _id: Types.ObjectId
@@ -30,11 +28,8 @@ export interface ActivityDocument extends Document {
 
 export interface ActivityModel extends Model<ActivityDocument> {
   createByParameters(parameters: any): Promise<ActivityDocument>
-  removeByParameters(parameters: any): any
   createByPageComment(comment: any): Promise<ActivityDocument>
   createByPageLike(page: any, user: any): Promise<ActivityDocument>
-  removeByPageUnlike(page: any, user: any): Promise<DeleteWriteOpResultObject['result']>
-  removeByPage(page: any): Promise<DeleteWriteOpResultObject['result']>
   findByUser(user: any): Promise<ActivityDocument[]>
   getActionUsersFromActivities(activities: ActivityDocument[]): any[]
 }
@@ -91,16 +86,6 @@ module.exports = function(crowi: Crowi) {
     return this.create(parameters);
   };
 
-  /**
-     * @param {object} parameters
-     */
-  activitySchema.statics.removeByParameters = async function(parameters) {
-    const activity = await this.findOne(parameters);
-    activityEvent.emit('remove', activity);
-
-    return this.deleteMany(parameters).exec();
-  };
-
   /**
      * @param {Comment} comment
      * @return {Promise}
@@ -134,37 +119,6 @@ module.exports = function(crowi: Crowi) {
     return this.createByParameters(parameters);
   };
 
-  /**
-     * @param {Page} page
-     * @param {User} user
-     * @return {Promise}
-     */
-  activitySchema.statics.removeByPageUnlike = function(page, user) {
-    const parameters = {
-      user,
-      targetModel: ActivityDefine.MODEL_PAGE,
-      target: page,
-      action: ActivityDefine.ACTION_LIKE,
-    };
-
-    return this.removeByParameters(parameters);
-  };
-
-  /**
-     * @param {Page} page
-     *
-     * @return {Promise}
-     */
-  activitySchema.statics.removeByPage = async function(page) {
-    // const activityEvent = new ActivityEvent();
-    const activities = await this.find({ target: page });
-    for (const activity of activities) {
-      // TODO: implement removeActivity when page deleted by GW-7481
-      // activityEvent.emit('remove', activity);
-    }
-    return this.deleteMany({ target: page }).exec();
-  };
-
   /**
      * @param {User} user
      * @return {Promise}

+ 2 - 5
packages/app/src/server/models/in-app-notification.ts

@@ -1,14 +1,11 @@
 import {
   Types, Document, Model, Schema /* , Query */,
 } from 'mongoose';
-import { subDays } from 'date-fns';
 import ActivityDefine from '../util/activityDefine';
-import { getOrCreateModel, getModelSafely } from '../util/mongoose-utils';
+import { getOrCreateModel } from '../util/mongoose-utils';
 import loggerFactory from '../../utils/logger';
-import { ActivityDocument } from './activity';
 
 const logger = loggerFactory('growi:models:inAppNotification');
-const mongoose = require('mongoose');
 
 export const STATUS_UNREAD = 'UNREAD';
 export const STATUS_UNOPENED = 'UNOPENED';
@@ -82,7 +79,7 @@ const inAppNotificationSchema = new Schema<InAppNotificationDocument, InAppNotif
   },
 });
 
-// TODO: move this virtual property getter to the service layer if necessary 77893
+// TODO: move this virtual property getter to the service layer if necessary by #78284
 // inAppNotificationSchema.virtual('actionUsers').get(function(this: InAppNotificationDocument) {
 //   const Activity = getModelSafely('Activity') || require('../models/activity')(this.crowi);
 //   return Activity.getActionUsersFromActivities((this.activities as any) as ActivityDocument[]);

+ 0 - 9
packages/app/src/server/service/activity.ts

@@ -1,15 +1,9 @@
-import { Types } from 'mongoose';
 import Crowi from '../crowi';
-import loggerFactory from '../../utils/logger';
-
-import { ActivityDocument } from '../models/activity';
 
 import ActivityDefine from '../util/activityDefine';
 import { getModelSafely } from '../util/mongoose-utils';
 
 
-const logger = loggerFactory('growi:service:ActivityService');
-
 class ActivityService {
 
   crowi!: Crowi;
@@ -18,15 +12,12 @@ class ActivityService {
 
   activityEvent!: any;
 
-  // commentEvent!: any;
-
   constructor(crowi: Crowi) {
     this.crowi = crowi;
     this.inAppNotificationService = crowi.inAppNotificationService;
     this.activityEvent = crowi.event('activity');
   }
 
-
   /**
    * @param {Page} page
    * @param {User} user