Send operations to project-history when deleting comments (#17198) (#17494)

* Make Operation.fromRaw parse AddComment operations

* Send operations to project-history when deleting comments

* remove RedisManager.updateDocument call

* format fix

* Revert "remove RedisManager.updateDocument call"

This reverts commit 5d45f34b5919bf5a85e8475e5a450bcb213d3f82.

* remove versions from deleteComment op

* pass userId to deleteComment operation

* revert userId from chat service

* revert userid from chat tests

* format:fix

* document updater fix tests

* format:fix

* fix web unit test

* deleteThread test fix

* send only if historyRangesSupport is true

* use headers to pass userId

* set historyRangesSupport in tests

* optional headers

* Revert "use headers to pass userId"

This reverts commit e916c469f95b1ac166e30e12e735171eb814af01.

---------

Co-authored-by: Eric Mc Sween <5454374+emcsween@users.noreply.github.com>
GitOrigin-RevId: 14c10669e43d76883dbaaa8ab55e102b5ebadd38
This commit is contained in:
Domagoj Kriskovic
2024-03-11 17:24:43 +01:00
committed by Copybot
parent 7edcf80cb1
commit b215a06df9
8 changed files with 125 additions and 18 deletions
@@ -11,6 +11,7 @@ describe('HttpController', function () {
'./HistoryManager': (this.HistoryManager = {
flushProjectChangesAsync: sinon.stub(),
}),
'./ProjectHistoryRedisManager': (this.ProjectHistoryRedisManager = {}),
'./ProjectManager': (this.ProjectManager = {}),
'./ProjectFlusher': { flushAllProjects() {} },
'./DeleteQueueManager': (this.DeleteQueueManager = {}),
@@ -651,6 +652,7 @@ describe('HttpController', function () {
describe('deleteComment', function () {
beforeEach(function () {
this.user_id = 'user-id-123'
this.req = {
params: {
project_id: this.project_id,
@@ -658,7 +660,9 @@ describe('HttpController', function () {
comment_id: (this.comment_id = 'mock-comment-id'),
},
query: {},
body: {},
body: {
user_id: this.user_id,
},
}
})
@@ -666,13 +670,20 @@ describe('HttpController', function () {
beforeEach(function () {
this.DocumentManager.deleteCommentWithLock = sinon
.stub()
.callsArgWith(3)
.callsArgWith(4)
this.ProjectHistoryRedisManager.queueOps = sinon.stub()
this.HttpController.deleteComment(this.req, this.res, this.next)
})
it('should accept the change', function () {
this.DocumentManager.deleteCommentWithLock
.calledWith(this.project_id, this.doc_id, this.comment_id)
.calledWith(
this.project_id,
this.doc_id,
this.comment_id,
this.user_id
)
.should.equal(true)
})
@@ -702,7 +713,7 @@ describe('HttpController', function () {
beforeEach(function () {
this.DocumentManager.deleteCommentWithLock = sinon
.stub()
.callsArgWith(3, new Error('oops'))
.callsArgWith(4, new Error('oops'))
this.HttpController.deleteComment(this.req, this.res, this.next)
})