|
@@ -34,7 +34,7 @@ class CommentService {
|
|
|
const Page = getModelSafely('Page') || require('../models/page')(this.crowi);
|
|
const Page = getModelSafely('Page') || require('../models/page')(this.crowi);
|
|
|
await Page.updateCommentCount(savedComment.page);
|
|
await Page.updateCommentCount(savedComment.page);
|
|
|
|
|
|
|
|
- const savedActivity = await this.createCommentActivity(savedComment);
|
|
|
|
|
|
|
+ const savedActivity = await this.createCommentActivity(savedComment, ActivityDefine.ACTION_COMMENT_CREATE);
|
|
|
|
|
|
|
|
let targetUsers: Types.ObjectId[] = [];
|
|
let targetUsers: Types.ObjectId[] = [];
|
|
|
targetUsers = await savedActivity.getNotificationTargetUsers();
|
|
targetUsers = await savedActivity.getNotificationTargetUsers();
|
|
@@ -48,10 +48,16 @@ class CommentService {
|
|
|
|
|
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- // update
|
|
|
|
|
- this.commentEvent.on('update', (userId, pageId) => {
|
|
|
|
|
|
|
+ this.commentEvent.on('update', async(updatedComment) => {
|
|
|
this.commentEvent.onUpdate();
|
|
this.commentEvent.onUpdate();
|
|
|
|
|
|
|
|
|
|
+ const savedActivity = await this.createCommentActivity(updatedComment, ActivityDefine.ACTION_COMMENT_UPDATE);
|
|
|
|
|
+
|
|
|
|
|
+ let targetUsers: Types.ObjectId[] = [];
|
|
|
|
|
+ targetUsers = await savedActivity.getNotificationTargetUsers();
|
|
|
|
|
+
|
|
|
|
|
+ await this.inAppNotificationService.upsertByActivity(targetUsers, savedActivity);
|
|
|
|
|
+
|
|
|
// TODO: 79713
|
|
// TODO: 79713
|
|
|
// const { inAppNotificationService } = this.crowi;
|
|
// const { inAppNotificationService } = this.crowi;
|
|
|
// inAppNotificationService.emitSocketIo(userId, pageId);
|
|
// inAppNotificationService.emitSocketIo(userId, pageId);
|
|
@@ -75,18 +81,16 @@ class CommentService {
|
|
|
* @param {Comment} comment
|
|
* @param {Comment} comment
|
|
|
* @return {Promise}
|
|
* @return {Promise}
|
|
|
*/
|
|
*/
|
|
|
- createCommentActivity = function(comment) {
|
|
|
|
|
|
|
+ createCommentActivity = function(comment, actionType) {
|
|
|
const { activityService } = this.crowi;
|
|
const { activityService } = this.crowi;
|
|
|
|
|
|
|
|
- // TODO: Changing the action name in Create and Update
|
|
|
|
|
-
|
|
|
|
|
const parameters = {
|
|
const parameters = {
|
|
|
user: comment.creator,
|
|
user: comment.creator,
|
|
|
targetModel: ActivityDefine.MODEL_PAGE,
|
|
targetModel: ActivityDefine.MODEL_PAGE,
|
|
|
target: comment.page,
|
|
target: comment.page,
|
|
|
eventModel: ActivityDefine.MODEL_COMMENT,
|
|
eventModel: ActivityDefine.MODEL_COMMENT,
|
|
|
event: comment._id,
|
|
event: comment._id,
|
|
|
- action: ActivityDefine.ACTION_COMMENT,
|
|
|
|
|
|
|
+ action: actionType,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
return activityService.createByParameters(parameters);
|
|
return activityService.createByParameters(parameters);
|