[web] pipe history zip download to history-v1 in CE/SP (#11362)

GitOrigin-RevId: 4ef181d1b79b3d0e2254af698defe0c2fa8c679f
This commit is contained in:
Miguel Serrano 2023-01-23 11:34:58 +01:00 committed by Copybot
parent 2291fd5dae
commit b4e9bf3449
2 changed files with 17 additions and 2 deletions

View file

@ -13,6 +13,7 @@ const ProjectEntityUpdateHandler = require('../Project/ProjectEntityUpdateHandle
const RestoreManager = require('./RestoreManager')
const { pipeline } = require('stream')
const { prepareZipAttachment } = require('../../infrastructure/Response')
const Features = require('../../infrastructure/Features')
module.exports = HistoryController = {
selectHistoryApi(req, res, next) {
@ -344,10 +345,20 @@ module.exports = HistoryController = {
pass: settings.apis.v1_history.pass,
},
json: true,
method: 'post',
url,
}
request(options, function (err, response, body) {
if (!Features.hasFeature('saas')) {
const getReq = request({ ...options, method: 'get' })
getReq.pipe(res)
getReq.on('error', function (err) {
logger.error({ url, err }, 'history API error')
next(err)
})
return
}
request({ ...options, method: 'post' }, function (err, response, body) {
if (err) {
OError.tag(err, 'history API error', {
v1ProjectId,

View file

@ -34,6 +34,10 @@ describe('HistoryController', function () {
(this.ProjectEntityUpdateHandler = {}),
'../User/UserGetter': (this.UserGetter = {}),
'./RestoreManager': (this.RestoreManager = {}),
'../../infrastructure/Features': (this.Features = sinon
.stub()
.withArgs('saas')
.returns(true)),
},
})
return (this.settings.apis = {