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

GrottoCenter / grottocenter-api / 25457721116

06 May 2026 07:47PM UTC coverage: 86.494% (-0.2%) from 86.702%
25457721116

Pull #1565

github

ClemRz
feat(account): consolidate account endpoints and add locale-aware emails

- Add GET /api/v1/account for authenticated user's private data
- Add PATCH /api/v1/account for self-service updates (name, surname,
  nickname, email, password, language)
- Restrict PUT /api/v1/cavers/:caverId to admin-only
- Add optional language param to sign-up endpoint
- Add locale support to send-email helper for recipient-language emails
- Remove orphaned change-email, change-alert-for-news controllers
- Update Swagger spec with consolidated /account path
- Update tests to match new endpoint behavior
- Silence pre-existing func-names lint warnings in property tests
Pull Request #1565: feat(account): consolidate endpoints and add locale-aware emails

3047 of 3661 branches covered (83.23%)

Branch coverage included in aggregate %.

71 of 91 new or added lines in 8 files covered. (78.02%)

27 existing lines in 6 files now uncovered.

6297 of 7142 relevant lines covered (88.17%)

53.2 hits per line

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

97.14
/api/controllers/v1/document/validate.js
1
const ControllerService = require('../../../services/ControllerService');
1✔
2
const DocumentService = require('../../../services/DocumentService');
1✔
3
const NotificationService = require('../../../services/NotificationService');
1✔
4
const RightService = require('../../../services/RightService');
1✔
5
const { toDocument } = require('../../../services/mapping/converters');
1✔
6

7
// Unused by front
8
// TODO Remove ?
9
// eslint-disable-next-line consistent-return
10
module.exports = async (req, res) => {
1✔
11
  const hasRight = RightService.hasGroup(
8✔
12
    req.token.groups,
13
    RightService.G.MODERATOR
14
  );
15
  if (!hasRight) {
8✔
16
    return res.forbidden('You are not authorized to validate a document.');
1✔
17
  }
18

19
  const isValidated = req.param('isValidated')
7✔
20
    ? !(req.param('isValidated').toLowerCase() === 'false')
21
    : true;
22
  const validationComment = req.param('validationComment', null);
7✔
23
  const id = req.param('id');
7✔
24

25
  if (isValidated === false && !validationComment) {
7✔
26
    return res.badRequest(
1✔
27
      `If the document with id ${id} is refused, a comment must be provided.`
28
    );
29
  }
30

31
  await TDocument.updateOne({ id }).set({
6✔
32
    dateValidation: new Date(),
33
    isValidated,
34
    validationComment,
35
    validator: req.token.id,
36
  });
37

38
  const populatedDoc = await DocumentService.getPopulatedDocument(id);
6✔
39

40
  if (isValidated) {
6✔
41
    await DocumentService.updateInSearch(populatedDoc);
4✔
42

43
    await NotificationService.notifySubscribers(
4✔
44
      req,
45
      populatedDoc,
46
      req.token.id,
47
      NotificationService.NOTIFICATION_TYPES.VALIDATE,
48
      NotificationService.NOTIFICATION_ENTITIES.DOCUMENT
49
    );
50
  }
51

52
  // Notify author for both acceptance and rejection
53
  await NotificationService.notifyAuthor(
6✔
54
    req,
55
    populatedDoc,
56
    req.token.id,
57
    isValidated
6✔
58
      ? NotificationService.NOTIFICATION_TYPES.VALIDATE
59
      : NotificationService.NOTIFICATION_TYPES.REJECT,
60
    validationComment
61
  ).catch((err) =>
UNCOV
62
    sails.log.error('Document validate notifyAuthor error', err)
×
63
  );
64

65
  const params = {
6✔
66
    controllerMethod: 'DocumentController.validate',
67
    notFoundMessage: `Document of id ${id} not found`,
68
    searchedItem: `Document of id ${id}`,
69
  };
70
  return ControllerService.treatAndConvert(
6✔
71
    req,
72
    null,
73
    populatedDoc,
74
    params,
75
    res,
76
    toDocument
77
  );
78
};
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