2026-09-06 12:39:55 +02:00
|
|
|
// Provenance: ZUENS2020/overleaf-with-claude exportProject (fixed).
|
2026-09-05 09:27:22 +02:00
|
|
|
// repo: ZUENS2020/overleaf-with-claude
|
|
|
|
|
// commit: 3980b9e5806defb63e45ae2696e6c1899f3a8431
|
|
|
|
|
// parent: 5a886aa9fb9fe4e2203f3cb1d62c91f4be0525ed
|
|
|
|
|
// commit_url: https://github.com/ZUENS2020/overleaf-with-claude/commit/3980b9e5806defb63e45ae2696e6c1899f3a8431
|
|
|
|
|
// cve:
|
|
|
|
|
// license: AGPL-3.0
|
|
|
|
|
// function: exportProject
|
|
|
|
|
// relpath: services/web/app/src/Features/Exports/ExportsController.mjs
|
|
|
|
|
// provenance: agent
|
|
|
|
|
// mechanism: identity_from_request_body
|
2026-09-06 12:39:55 +02:00
|
|
|
// upstream_start: 1
|
2026-09-05 09:27:22 +02:00
|
|
|
|
2026-09-06 12:39:55 +02:00
|
|
|
from '@overleaf/promise-utils'
|
2026-09-05 09:27:22 +02:00
|
|
|
import SessionManager from '../Authentication/SessionManager.mjs'
|
|
|
|
|
import logger from '@overleaf/logger'
|
|
|
|
|
import OError from '@overleaf/o-error'
|
|
|
|
|
import settings from '@overleaf/settings'
|
|
|
|
|
|
|
|
|
|
async function exportProject(req, res, next) {
|
|
|
|
|
const { project_id: projectId, brand_variation_id: brandVariationId } =
|
|
|
|
|
req.params
|
|
|
|
|
const userId = SessionManager.getLoggedInUserId(req.session)
|
|
|
|
|
const exportParams = {
|
|
|
|
|
project_id: projectId,
|
|
|
|
|
brand_variation_id: brandVariationId,
|
|
|
|
|
user_id: userId,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (req.body) {
|
|
|
|
|
if (req.body.firstName) {
|
|
|
|
|
exportParams.first_name = req.body.firstName.trim()
|
|
|
|
|
}
|
|
|
|
|
if (req.body.lastName) {
|
|
|
|
|
exportParams.last_name = req.body.lastName.trim()
|
|
|
|
|
}
|
|
|
|
|
// additional parameters for gallery exports
|
|
|
|
|
if (req.body.title) {
|
|
|
|
|
exportParams.title = req.body.title.trim()
|
|
|
|
|
}
|
|
|
|
|
if (req.body.description) {
|
|
|
|
|
exportParams.description = req.body.description.trim()
|
|
|
|
|
}
|
|
|
|
|
if (req.body.author) {
|
|
|
|
|
exportParams.author = req.body.author.trim()
|
|
|
|
|
}
|
|
|
|
|
if (req.body.license) {
|
|
|
|
|
exportParams.license = req.body.license.trim()
|
|
|
|
|
}
|
|
|
|
|
if (req.body.showSource != null) {
|
|
|
|
|
exportParams.show_source = req.body.showSource
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const exportData = await ExportsHandler.exportProject(exportParams)
|
|
|
|
|
logger.debug(
|
|
|
|
|
{
|
|
|
|
|
userId,
|
|
|
|
|
projectId,
|
|
|
|
|
brandVariationId,
|
|
|
|
|
exportV1Id: exportData.v1_id,
|
|
|
|
|
},
|
|
|
|
|
'exported project'
|
|
|
|
|
)
|
|
|
|
|
return res.json({
|
|
|
|
|
export_v1_id: exportData.v1_id,
|
|
|
|
|
token: exportData.token,
|
|
|
|
|
message: exportData.message,
|
|
|
|
|
})
|
|
|
|
|
} catch (err) {
|
|
|
|
|
const info = OError.getFullInfo(err)
|
|
|
|
|
if (info?.forwardResponse) {
|
|
|
|
|
logger.debug(
|
|
|
|
|
{ responseError: info.forwardResponse },
|
|
|
|
|
'forwarding response'
|
|
|
|
|
)
|
|
|
|
|
const statusCode = info.forwardResponse.status || 500
|
|
|
|
|
return res.status(statusCode).json(info.forwardResponse)
|
|
|
|
|
}
|
|
|
|
|
throw err
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-09-06 12:39:55 +02:00
|
|
|
|
|
|
|
|
exportProject: expressify(exportProject),
|