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,
|
deletedProjectReadOnlyIds: project.readOnly_refs,
|
||||||
deletedProjectReadWriteTokenAccessIds:
|
deletedProjectReadWriteTokenAccessIds:
|
||||||
project.tokenAccessReadAndWrite_refs,
|
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,
|
deletedProjectReadOnlyTokenAccessIds: project.tokenAccessReadOnly_refs,
|
||||||
deletedProjectReadWriteToken: project.tokens.readAndWrite,
|
deletedProjectReadWriteToken: project.tokens.readAndWrite,
|
||||||
deletedProjectReadOnlyToken: project.tokens.readOnly,
|
deletedProjectReadOnlyToken: project.tokens.readOnly,
|
||||||
|
|
|
@ -19,7 +19,9 @@ const DeleterDataSchema = new Schema({
|
||||||
deletedProjectReadOnlyTokenAccessIds: [{ type: ObjectId, ref: 'User' }],
|
deletedProjectReadOnlyTokenAccessIds: [{ type: ObjectId, ref: 'User' }],
|
||||||
deletedProjectReadWriteToken: { type: String },
|
deletedProjectReadWriteToken: { type: String },
|
||||||
deletedProjectReadOnlyToken: { type: String },
|
deletedProjectReadOnlyToken: { type: String },
|
||||||
deletedProjectLastUpdatedAt: { type: Date }
|
deletedProjectLastUpdatedAt: { type: Date },
|
||||||
|
deletedProjectOverleafId: { type: Number },
|
||||||
|
deletedProjectOverleafHistoryId: { type: Number }
|
||||||
})
|
})
|
||||||
|
|
||||||
const DeletedProjectSchema = new Schema(
|
const DeletedProjectSchema = new Schema(
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
const { DeletedProject } = require('../app/src/models/DeletedProject')
|
const { DeletedProject } = require('../app/src/models/DeletedProject')
|
||||||
const Async = require('async')
|
const Async = require('async')
|
||||||
|
|
||||||
DeletedProject.find(
|
DeletedProject.find({}, (error, deletedProjects) => {
|
||||||
{},
|
|
||||||
{ 'project._id': 1, 'project.owner_ref': 1 },
|
|
||||||
(error, deletedProjects) => {
|
|
||||||
if (error) {
|
if (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
|
@ -27,6 +24,13 @@ DeletedProject.find(
|
||||||
'deleterData.deletedProjectReadWriteToken': src.tokens
|
'deleterData.deletedProjectReadWriteToken': src.tokens
|
||||||
? src.tokens.readAndWrite
|
? src.tokens.readAndWrite
|
||||||
: undefined,
|
: 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
|
'deleterData.deletedProjectReadOnlyToken': src.tokens
|
||||||
? src.tokens.readOnly
|
? src.tokens.readOnly
|
||||||
: undefined,
|
: undefined,
|
||||||
|
@ -50,5 +54,4 @@ DeletedProject.find(
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
})
|
||||||
)
|
|
||||||
|
|
|
@ -27,6 +27,12 @@ describe('ProjectDeleter', () => {
|
||||||
readOnly: 'wombat',
|
readOnly: 'wombat',
|
||||||
readAndWrite: 'potato'
|
readAndWrite: 'potato'
|
||||||
},
|
},
|
||||||
|
overleaf: {
|
||||||
|
id: 1234,
|
||||||
|
history: {
|
||||||
|
id: 5678
|
||||||
|
}
|
||||||
|
},
|
||||||
name: 'a very scientific analysis of spooky ghosts'
|
name: 'a very scientific analysis of spooky ghosts'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,6 +244,8 @@ describe('ProjectDeleter', () => {
|
||||||
.tokenAccessReadOnly_refs,
|
.tokenAccessReadOnly_refs,
|
||||||
deletedProjectReadWriteToken: this.project.tokens.readAndWrite,
|
deletedProjectReadWriteToken: this.project.tokens.readAndWrite,
|
||||||
deletedProjectReadOnlyToken: this.project.tokens.readOnly,
|
deletedProjectReadOnlyToken: this.project.tokens.readOnly,
|
||||||
|
deletedProjectOverleafId: this.project.overleaf.id,
|
||||||
|
deletedProjectOverleafHistoryId: this.project.overleaf.history.id,
|
||||||
deletedProjectLastUpdatedAt: this.project.lastUpdated
|
deletedProjectLastUpdatedAt: this.project.lastUpdated
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue