Merge pull request #13000 from overleaf/em-revert-delete-git-bridge-data

Revert "Delete git bridge data when a project is expired"

GitOrigin-RevId: a8674e040c9ccce3937b6ce244a82cd190c32c97
This commit is contained in:
Eric Mc Sween 2023-05-08 12:18:40 -04:00 committed by Copybot
parent c19fa74aa4
commit 9528eab43e
5 changed files with 1 additions and 82 deletions

View file

@ -1,6 +1,5 @@
const _ = require('lodash')
const { db, ObjectId } = require('../../infrastructure/mongodb')
const Modules = require('../../infrastructure/Modules')
const { callbackify } = require('util')
const { Project } = require('../../models/Project')
const { DeletedProject } = require('../../models/DeletedProject')
@ -388,7 +387,6 @@ async function expireDeletedProject(projectId) {
ChatApiHandler.promises.destroyProject(deletedProject.project._id),
hardDeleteDeletedFiles(deletedProject.project._id),
ProjectAuditLogEntry.deleteMany({ projectId }),
Modules.promises.hooks.fire('projectExpired', deletedProject.project._id),
])
await DeletedProject.updateOne(

View file

@ -90,9 +90,6 @@ module.exports = {
webpack: {
url: 'http://localhost:23808',
},
gitBridge: {
url: 'http://localhost:28000',
},
},
// for registration via SL, set enableLegacyRegistration to true

View file

@ -4,19 +4,16 @@ const async = require('async')
const { expect } = require('chai')
const settings = require('@overleaf/settings')
const { db, ObjectId } = require('../../../app/src/infrastructure/mongodb')
const Features = require('../../../app/src/infrastructure/Features')
const MockDocstoreApiClass = require('./mocks/MockDocstoreApi')
const MockFilestoreApiClass = require('./mocks/MockFilestoreApi')
const MockChatApiClass = require('./mocks/MockChatApi')
const MockGitBridgeApiClass = require('./mocks/MockGitBridgeApi')
let MockDocstoreApi, MockFilestoreApi, MockChatApi, MockGitBridgeApi
let MockDocstoreApi, MockFilestoreApi, MockChatApi
before(function () {
MockDocstoreApi = MockDocstoreApiClass.instance()
MockFilestoreApi = MockFilestoreApiClass.instance()
MockChatApi = MockChatApiClass.instance()
MockGitBridgeApi = MockGitBridgeApiClass.instance()
})
describe('Deleting a user', function () {
@ -316,11 +313,6 @@ describe('Deleting a project', function () {
dummyFile: 'wombat',
}
MockChatApi.projects[this.projectId.toString()] = ['message']
if (Features.hasFeature('git-bridge')) {
MockGitBridgeApi.projects[this.projectId.toString()] = {
data: 'some-data',
}
}
})
})
@ -445,46 +437,4 @@ describe('Deleting a project', function () {
})
})
})
if (Features.hasFeature('git-bridge')) {
describe('When the project has git-bridge data', function () {
beforeEach(function () {
MockGitBridgeApi.projects[this.projectId.toString()] = {
data: 'some-data',
}
})
describe('When the deleted project is expired', function () {
beforeEach(function (done) {
this.user.deleteProject(this.projectId, error => {
if (error) {
return done(error)
}
request.post(
`/internal/project/${this.projectId}/expire-deleted-project`,
{
auth: {
user: settings.apis.web.user,
pass: settings.apis.web.pass,
sendImmediately: true,
},
},
(error, res) => {
if (error) {
return done(error)
}
expect(res.statusCode).to.equal(200)
done()
}
)
})
})
it('should delete the git-bridge data', function () {
expect(MockGitBridgeApi.projects[this.projectId.toString()]).not.to
.exist
})
})
})
}
})

View file

@ -7,7 +7,6 @@ const MockClsiApi = require('./mocks/MockClsiApi')
const MockDocstoreApi = require('./mocks/MockDocstoreApi')
const MockDocUpdaterApi = require('./mocks/MockDocUpdaterApi')
const MockFilestoreApi = require('./mocks/MockFilestoreApi')
const MockGitBridgeApi = require('./mocks/MockGitBridgeApi')
const MockNotificationsApi = require('./mocks/MockNotificationsApi')
const MockProjectHistoryApi = require('./mocks/MockProjectHistoryApi')
const MockSpellingApi = require('./mocks/MockSpellingApi')
@ -36,7 +35,3 @@ if (Features.hasFeature('saas')) {
MockV1Api.initialize(25000, mockOpts)
MockThirdPartyDataStoreApi.initialize(23002, mockOpts)
}
if (Features.hasFeature('git-bridge')) {
MockGitBridgeApi.initialize(28000, mockOpts)
}

View file

@ -1,21 +0,0 @@
const AbstractMockApi = require('./AbstractMockApi')
class MockGitBridgeApi extends AbstractMockApi {
reset() {
this.projects = {}
}
applyRoutes() {
this.app.delete('/api/projects/:projectId', (req, res) => {
this.deleteProject(req, res)
})
}
deleteProject(req, res) {
const projectId = req.params.projectId
delete this.projects[projectId]
res.sendStatus(204)
}
}
module.exports = MockGitBridgeApi