Merge pull request #9212 from overleaf/jpa-record-dropbox-file-id

[third-party-datastore] start recording dropbox id for docs/files

GitOrigin-RevId: 699fe63994848b65aa4d9cbc7966b867de56eabf
This commit is contained in:
Jakob Ackermann 2022-08-11 12:04:23 +01:00 committed by Copybot
parent 01627a9369
commit e293c627a1
3 changed files with 29 additions and 0 deletions

View file

@ -23,6 +23,8 @@ async function addDoc(options) {
`/doc/${options.doc_id}`,
'/raw'
)
options.entity_id = options.doc_id
options.entity_type = 'doc'
return addEntity(options)
}
@ -34,6 +36,8 @@ async function addEntity(options) {
const job = {
method: 'post',
headers: {
sl_entity_id: options.entity_id,
sl_entity_type: options.entity_type,
sl_entity_rev: options.rev,
sl_project_id: options.project_id,
sl_all_user_ids: JSON.stringify([userId]),
@ -54,6 +58,8 @@ async function addFile(options) {
options.streamOrigin =
settings.apis.filestore.url +
path.join(`/project/${options.project_id}`, `/file/${options.file_id}`)
options.entity_id = options.file_id
options.entity_type = 'file'
return addEntity(options)
}

View file

@ -38,6 +38,7 @@ async function setupDb() {
db.deletedProjects = internalDb.collection('deletedProjects')
db.deletedSubscriptions = internalDb.collection('deletedSubscriptions')
db.deletedUsers = internalDb.collection('deletedUsers')
db.dropboxEntities = internalDb.collection('dropboxEntities')
db.docHistory = internalDb.collection('docHistory')
db.docHistoryIndex = internalDb.collection('docHistoryIndex')
db.docOps = internalDb.collection('docOps')

View file

@ -0,0 +1,22 @@
const Helpers = require('./lib/helpers')
exports.tags = ['saas']
const indexes = [
{
key: {
entityId: 1,
},
name: 'entityId_1',
},
]
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.dropboxEntities, indexes)
}
exports.rollback = async client => {
const { db } = client
await Helpers.dropIndexesFromCollection(db.dropboxEntities, indexes)
}