• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

GrottoCenter / grottocenter-api / 10997921112

23 Sep 2024 03:53PM UTC coverage: 46.105% (-0.05%) from 46.158%
10997921112

push

github

vmarseguerra
fix(entrance): cannot delete entrance sub entities with notification

740 of 2203 branches covered (33.59%)

Branch coverage included in aggregate %.

0 of 13 new or added lines in 6 files covered. (0.0%)

5 existing lines in 5 files now uncovered.

2462 of 4742 relevant lines covered (51.92%)

4.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

18.18
/api/controllers/v1/comment/delete.js
1
const ControllerService = require('../../../services/ControllerService');
1✔
2
const NotificationService = require('../../../services/NotificationService');
1✔
3
const { toSimpleComment } = require('../../../services/mapping/converters');
1✔
4
const RightService = require('../../../services/RightService');
1✔
5
const CommentService = require('../../../services/CommentService');
1✔
6

7
module.exports = async (req, res) => {
1✔
8
  const hasRight = RightService.hasGroup(
×
9
    req.token.groups,
10
    RightService.G.MODERATOR
11
  );
12
  if (!hasRight)
×
13
    return res.forbidden('You are not authorized to delete comment.');
×
14

15
  const commentId = req.param('id');
×
16
  const comment = await CommentService.getComment(commentId);
×
17
  if (!comment) {
×
18
    return res.notFound({ message: `Comment of id ${commentId} not found.` });
×
19
  }
20

21
  if (!comment.isDeleted) {
×
22
    await TComment.destroyOne({ id: commentId }); // Soft delete
×
23
    comment.isDeleted = true;
×
24
  }
25

26
  const deletePermanently = !!req.param('isPermanent');
×
27
  if (deletePermanently) {
×
28
    await HComment.destroy({ t_id: commentId });
×
NEW
29
    await TNotification.destroy({ comment: commentId });
×
UNCOV
30
    await TComment.destroyOne({ id: commentId }); // Hard delete
×
31
  }
32

33
  await NotificationService.notifySubscribers(
×
34
    req,
35
    comment,
36
    req.token.id,
37
    deletePermanently
×
38
      ? NotificationService.NOTIFICATION_TYPES.PERMANENT_DELETE
39
      : NotificationService.NOTIFICATION_TYPES.DELETE,
40
    NotificationService.NOTIFICATION_ENTITIES.COMMENT
41
  );
42

43
  return ControllerService.treatAndConvert(
×
44
    req,
45
    null,
46
    comment,
47
    { controllerMethod: 'CommentController.delete' },
48
    res,
49
    toSimpleComment
50
  );
51
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc