• 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/location/delete.js
1
const ControllerService = require('../../../services/ControllerService');
1✔
2
const NotificationService = require('../../../services/NotificationService');
1✔
3
const LocationService = require('../../../services/LocationService');
1✔
4
const { toSimpleLocation } = require('../../../services/mapping/converters');
1✔
5
const RightService = require('../../../services/RightService');
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 location.');
×
14

15
  const locationId = req.param('id');
×
16
  const location = await LocationService.getLocation(locationId);
×
17
  if (!location) {
×
18
    return res.notFound({ message: `Location of id ${locationId} not found.` });
×
19
  }
20

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

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

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

43
  return ControllerService.treatAndConvert(
×
44
    req,
45
    null,
46
    location,
47
    { controllerMethod: 'LocationController.delete' },
48
    res,
49
    toSimpleLocation
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