[dsmp] Add acceptChanges notification (#27555)

* [dsmp] moved redis functions to RedisStreamManager

* use getEventStream generator function

* [dsmp] moved redis functions to RedisStreamManager

* [dsmp] Add acceptChanges notification

* rename to acceptedChanges

* cleanup after rebasing parent branch

GitOrigin-RevId: c7e100f55503e52b146bcc07deb3e483250b66f8
This commit is contained in:
Domagoj Kriskovic
2025-08-08 10:31:59 +02:00
committed by Copybot
parent 60f1f9ca5c
commit da7092bfb9
2 changed files with 18 additions and 7 deletions
@@ -5,11 +5,12 @@ const _ = require('lodash')
const async = require('async')
const logger = require('@overleaf/logger')
const metrics = require('@overleaf/metrics')
const { promisify } = require('util')
const { promisify, callbackify } = require('util')
const { promisifyMultiResult } = require('@overleaf/promise-utils')
const ProjectGetter = require('../Project/ProjectGetter')
const FileStoreHandler = require('../FileStore/FileStoreHandler')
const Features = require('../../infrastructure/Features')
const Modules = require('../../infrastructure/Modules')
function getProjectLastUpdatedAt(projectId, callback) {
_makeRequest(
@@ -233,17 +234,18 @@ function clearProjectState(projectId, callback) {
* @param {string[]} changeIds
* @param {Callback} callback
*/
function acceptChanges(projectId, docId, changeIds, callback) {
_makeRequest(
async function acceptChanges(projectId, docId, changeIds) {
await _makeRequestAsync(
{
path: `/project/${projectId}/doc/${docId}/change/accept`,
json: { change_ids: changeIds },
method: 'POST',
},
projectId,
'accept-changes',
callback
'accept-changes'
)
await Modules.promises.hooks.fire('acceptedChanges', projectId, docId)
}
/**
@@ -538,6 +540,8 @@ function _makeRequest(options, projectId, metricsKey, callback) {
)
}
const _makeRequestAsync = promisify(_makeRequest)
function _getUpdates(
entityType,
oldEntities,
@@ -648,7 +652,7 @@ module.exports = {
appendToDocument,
getProjectDocsIfMatch,
clearProjectState,
acceptChanges,
acceptChanges: callbackify(acceptChanges),
rejectChanges,
resolveThread,
reopenThread,
@@ -674,7 +678,7 @@ module.exports = {
getProjectDocsIfMatch: promisify(getProjectDocsIfMatch),
getProjectLastUpdatedAt: promisify(getProjectLastUpdatedAt),
clearProjectState: promisify(clearProjectState),
acceptChanges: promisify(acceptChanges),
acceptChanges,
rejectChanges: promisify(rejectChanges),
resolveThread: promisify(resolveThread),
reopenThread: promisify(reopenThread),
@@ -60,6 +60,13 @@ describe('DocumentUpdaterHandler', function () {
return `http://filestore/project/${projectId}/file/${fileId}`
}),
},
'../../infrastructure/Modules': {
promises: {
hooks: {
fire: sinon.stub().resolves(),
},
},
},
},
})
this.ProjectGetter.getProjectWithoutLock