Merge pull request #3008 from overleaf/as-sd-undelete-to-user

Add endpoint to allow undeleted project to be assigned to a user

GitOrigin-RevId: 884af4abfa19c82296f83e792319458909d23b3c
This commit is contained in:
Alasdair Smith 2020-07-15 09:49:23 +01:00 committed by Copybot
parent 2556fded1e
commit c660497859

View file

@ -260,7 +260,7 @@ async function deleteProject(projectId, options = {}) {
logger.log({ project_id: projectId }, 'successfully deleted project') logger.log({ project_id: projectId }, 'successfully deleted project')
} }
async function undeleteProject(projectId) { async function undeleteProject(projectId, options = {}) {
let deletedProject = await DeletedProject.findOne({ let deletedProject = await DeletedProject.findOne({
'deleterData.deletedProjectId': projectId 'deleterData.deletedProjectId': projectId
}).exec() }).exec()
@ -275,6 +275,10 @@ async function undeleteProject(projectId) {
let restored = new Project(deletedProject.project) let restored = new Project(deletedProject.project)
if (options.userId) {
restored.owner_ref = options.userId
}
// if we're undeleting, we want the document to show up // if we're undeleting, we want the document to show up
restored.name = await ProjectDetailsHandler.promises.generateUniqueName( restored.name = await ProjectDetailsHandler.promises.generateUniqueName(
deletedProject.deleterData.deletedProjectOwnerId, deletedProject.deleterData.deletedProjectOwnerId,