WebApiManager.js 851 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // @ts-check
  2. const Settings = require('@overleaf/settings')
  3. const { fetchNothing } = require('@overleaf/fetch-utils')
  4. const MAX_HTTP_REQUEST_LENGTH = 5000
  5. /**
  6. * @param {string} projectId
  7. * @param {string} docId
  8. * @param {string[]} rejectedChangeAuthorIds
  9. * @param {string | undefined} userId
  10. */
  11. async function notifyTrackChangesRejected(
  12. projectId,
  13. docId,
  14. rejectedChangeAuthorIds,
  15. userId
  16. ) {
  17. const url = new URL(
  18. `/project/${projectId}/doc/${docId}/changes/reject`,
  19. Settings.apis.web.url
  20. )
  21. await fetchNothing(url, {
  22. method: 'POST',
  23. json: { rejectedChangeAuthorIds, userId },
  24. basicAuth: {
  25. user: Settings.apis.web.user,
  26. password: Settings.apis.web.pass,
  27. },
  28. signal: AbortSignal.timeout(MAX_HTTP_REQUEST_LENGTH),
  29. })
  30. }
  31. module.exports = {
  32. promises: {
  33. notifyTrackChangesRejected,
  34. },
  35. }