mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #2014 from overleaf/spd-deleted-project-collab-ids
Store and backfill collaborator and overleaf history IDs in deleted projects GitOrigin-RevId: 34950e29d6910c22f1f6f153f8035a96a1ea8360
This commit is contained in:
parent
285edfff36
commit
d7bee9a7d8
4 changed files with 71 additions and 51 deletions
|
@ -180,6 +180,13 @@ async function deleteProject(project_id, options = {}) {
|
|||
deletedProjectReadOnlyIds: project.readOnly_refs,
|
||||
deletedProjectReadWriteTokenAccessIds:
|
||||
project.tokenAccessReadAndWrite_refs,
|
||||
deletedProjectOverleafId: project.overleaf
|
||||
? project.overleaf.id
|
||||
: undefined,
|
||||
deletedProjectOverleafHistoryId:
|
||||
project.overleaf && project.overleaf.history
|
||||
? project.overleaf.history.id
|
||||
: undefined,
|
||||
deletedProjectReadOnlyTokenAccessIds: project.tokenAccessReadOnly_refs,
|
||||
deletedProjectReadWriteToken: project.tokens.readAndWrite,
|
||||
deletedProjectReadOnlyToken: project.tokens.readOnly,
|
||||
|
|
|
@ -19,7 +19,9 @@ const DeleterDataSchema = new Schema({
|
|||
deletedProjectReadOnlyTokenAccessIds: [{ type: ObjectId, ref: 'User' }],
|
||||
deletedProjectReadWriteToken: { type: String },
|
||||
deletedProjectReadOnlyToken: { type: String },
|
||||
deletedProjectLastUpdatedAt: { type: Date }
|
||||
deletedProjectLastUpdatedAt: { type: Date },
|
||||
deletedProjectOverleafId: { type: Number },
|
||||
deletedProjectOverleafHistoryId: { type: Number }
|
||||
})
|
||||
|
||||
const DeletedProjectSchema = new Schema(
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
const { DeletedProject } = require('../app/src/models/DeletedProject')
|
||||
const Async = require('async')
|
||||
|
||||
DeletedProject.find(
|
||||
{},
|
||||
{ 'project._id': 1, 'project.owner_ref': 1 },
|
||||
(error, deletedProjects) => {
|
||||
DeletedProject.find({}, (error, deletedProjects) => {
|
||||
if (error) {
|
||||
throw error
|
||||
}
|
||||
|
@ -27,6 +24,13 @@ DeletedProject.find(
|
|||
'deleterData.deletedProjectReadWriteToken': src.tokens
|
||||
? src.tokens.readAndWrite
|
||||
: undefined,
|
||||
'deleterData.deletedProjectOverleafId': src.overleaf
|
||||
? src.overleaf.id
|
||||
: undefined,
|
||||
'deleterData.deletedProjectOverleafHistoryId':
|
||||
src.overleaf && src.overleaf.history
|
||||
? src.overleaf.history.id
|
||||
: undefined,
|
||||
'deleterData.deletedProjectReadOnlyToken': src.tokens
|
||||
? src.tokens.readOnly
|
||||
: undefined,
|
||||
|
@ -50,5 +54,4 @@ DeletedProject.find(
|
|||
process.exit(0)
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
})
|
||||
|
|
|
@ -27,6 +27,12 @@ describe('ProjectDeleter', () => {
|
|||
readOnly: 'wombat',
|
||||
readAndWrite: 'potato'
|
||||
},
|
||||
overleaf: {
|
||||
id: 1234,
|
||||
history: {
|
||||
id: 5678
|
||||
}
|
||||
},
|
||||
name: 'a very scientific analysis of spooky ghosts'
|
||||
}
|
||||
|
||||
|
@ -238,6 +244,8 @@ describe('ProjectDeleter', () => {
|
|||
.tokenAccessReadOnly_refs,
|
||||
deletedProjectReadWriteToken: this.project.tokens.readAndWrite,
|
||||
deletedProjectReadOnlyToken: this.project.tokens.readOnly,
|
||||
deletedProjectOverleafId: this.project.overleaf.id,
|
||||
deletedProjectOverleafHistoryId: this.project.overleaf.history.id,
|
||||
deletedProjectLastUpdatedAt: this.project.lastUpdated
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue