Merge pull request #10677 from overleaf/em-history-id-string

Represent history ids as strings instead of integers

GitOrigin-RevId: 18977195b65492836e570c571ec7e8c7e088612b
This commit is contained in:
Eric Mc Sween
2022-12-02 09:04:29 +00:00
committed by Copybot
parent 0e30718892
commit 5083060fbb
10 changed files with 26 additions and 33 deletions
@@ -11,7 +11,7 @@ async function initializeProject() {
settings.apis.project_history.initializeHistoryForNewProjects
)
) {
return
return null
}
const response = await fetch(`${settings.apis.project_history.url}/project`, {
method: 'POST',
@@ -25,11 +25,11 @@ async function initializeProject() {
})
}
const body = await response.json()
const overleafId = body && body.project && body.project.id
if (!overleafId) {
const historyId = body && body.project && body.project.id
if (!historyId) {
throw new OError('project-history did not provide an id', { body })
}
return { overleaf_id: overleafId }
return historyId
}
async function flushProject(projectId) {
@@ -153,9 +153,11 @@ async function _createBlankProject(
await ProjectDetailsHandler.promises.validateProjectName(projectName)
if (!attributes.overleaf) {
const history = await HistoryManager.promises.initializeProject()
attributes.overleaf = {
history: { id: history ? history.overleaf_id : undefined },
const historyId = await HistoryManager.promises.initializeProject()
if (historyId != null) {
attributes.overleaf = {
history: { id: historyId },
}
}
}
@@ -154,16 +154,16 @@ const ProjectHistoryHandler = {
if (history_id != null) {
return callback()
} // history already exists, success
return HistoryManager.initializeProject(function (err, history) {
return HistoryManager.initializeProject(function (err, historyId) {
if (err != null) {
return callback(err)
}
if (!(history != null ? history.overleaf_id : undefined)) {
if (historyId == null) {
return callback(new Error('failed to initialize history id'))
}
return ProjectHistoryHandler.setHistoryId(
project_id,
history.overleaf_id,
historyId,
function (err) {
if (err != null) {
return callback(err)