mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-17 21:05:04 -04:00
Handle removal of mongoose callback API for UserMemberships
GitOrigin-RevId: 0bdfaf4bfb357d75ee05513cf524540eef7fcec4
This commit is contained in:
parent
330868ff0c
commit
4e2bfd58a1
2 changed files with 12 additions and 16 deletions
|
@ -51,11 +51,10 @@ const UserMembershipsHandler = {
|
||||||
}
|
}
|
||||||
const removeOperation = { $pull: {} }
|
const removeOperation = { $pull: {} }
|
||||||
removeOperation.$pull[entityConfig.fields.write] = userId
|
removeOperation.$pull[entityConfig.fields.write] = userId
|
||||||
EntityModels[entityConfig.modelName].updateMany(
|
EntityModels[entityConfig.modelName]
|
||||||
{},
|
.updateMany({}, removeOperation)
|
||||||
removeOperation,
|
.then(result => callback(null, result))
|
||||||
callback
|
.catch(callback)
|
||||||
)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getEntitiesByUser(entityConfig, userId, callback) {
|
getEntitiesByUser(entityConfig, userId, callback) {
|
||||||
|
@ -64,22 +63,19 @@ const UserMembershipsHandler = {
|
||||||
}
|
}
|
||||||
const query = Object.assign({}, entityConfig.baseQuery)
|
const query = Object.assign({}, entityConfig.baseQuery)
|
||||||
query[entityConfig.fields.access] = userId
|
query[entityConfig.fields.access] = userId
|
||||||
EntityModels[entityConfig.modelName].find(
|
EntityModels[entityConfig.modelName]
|
||||||
query,
|
.find(query)
|
||||||
function (error, entities) {
|
.then(entities => {
|
||||||
if (entities == null) {
|
if (entities == null) {
|
||||||
entities = []
|
entities = []
|
||||||
}
|
}
|
||||||
if (error != null) {
|
|
||||||
return callback(error)
|
|
||||||
}
|
|
||||||
async.mapSeries(
|
async.mapSeries(
|
||||||
entities,
|
entities,
|
||||||
(entity, cb) => entity.fetchV1Data(cb),
|
(entity, cb) => entity.fetchV1Data(cb),
|
||||||
callback
|
callback
|
||||||
)
|
)
|
||||||
}
|
})
|
||||||
)
|
.catch(callback)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,9 @@ describe('UserMembershipsHandler', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.user = { _id: new ObjectId() }
|
this.user = { _id: new ObjectId() }
|
||||||
|
|
||||||
this.Institution = { updateMany: sinon.stub().yields(null) }
|
this.Institution = { updateMany: sinon.stub().resolves(null) }
|
||||||
this.Subscription = { updateMany: sinon.stub().yields(null) }
|
this.Subscription = { updateMany: sinon.stub().resolves(null) }
|
||||||
this.Publisher = { updateMany: sinon.stub().yields(null) }
|
this.Publisher = { updateMany: sinon.stub().resolves(null) }
|
||||||
return (this.UserMembershipsHandler = SandboxedModule.require(modulePath, {
|
return (this.UserMembershipsHandler = SandboxedModule.require(modulePath, {
|
||||||
requires: {
|
requires: {
|
||||||
'../../models/Institution': {
|
'../../models/Institution': {
|
||||||
|
|
Loading…
Reference in a new issue