mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #17106 from overleaf/jpa-x-update-source-1
[misc] remove ShareLaTeX branding from X-Update-Source header 1/2 GitOrigin-RevId: 435924b8f0f50016fe5bb1df7b960707babbb286
This commit is contained in:
parent
4804cd68a5
commit
5889aa1c1b
2 changed files with 58 additions and 9 deletions
|
@ -38,7 +38,10 @@ async function createProject(req, res) {
|
||||||
async function mergeUpdate(req, res) {
|
async function mergeUpdate(req, res) {
|
||||||
metrics.inc('tpds.merge-update')
|
metrics.inc('tpds.merge-update')
|
||||||
const { filePath, userId, projectId, projectName } = parseParams(req)
|
const { filePath, userId, projectId, projectName } = parseParams(req)
|
||||||
const source = req.headers['x-sl-update-source'] || 'unknown'
|
const source =
|
||||||
|
req.headers['x-sl-update-source'] ||
|
||||||
|
req.headers['x-update-source'] ||
|
||||||
|
'unknown'
|
||||||
|
|
||||||
let metadata
|
let metadata
|
||||||
try {
|
try {
|
||||||
|
@ -92,7 +95,10 @@ async function mergeUpdate(req, res) {
|
||||||
async function deleteUpdate(req, res) {
|
async function deleteUpdate(req, res) {
|
||||||
metrics.inc('tpds.delete-update')
|
metrics.inc('tpds.delete-update')
|
||||||
const { filePath, userId, projectId, projectName } = parseParams(req)
|
const { filePath, userId, projectId, projectName } = parseParams(req)
|
||||||
const source = req.headers['x-sl-update-source'] || 'unknown'
|
const source =
|
||||||
|
req.headers['x-sl-update-source'] ||
|
||||||
|
req.headers['x-update-source'] ||
|
||||||
|
'unknown'
|
||||||
|
|
||||||
await TpdsUpdateHandler.promises.deleteUpdate(
|
await TpdsUpdateHandler.promises.deleteUpdate(
|
||||||
userId,
|
userId,
|
||||||
|
@ -141,7 +147,10 @@ async function updateFolder(req, res) {
|
||||||
async function updateProjectContents(req, res, next) {
|
async function updateProjectContents(req, res, next) {
|
||||||
const projectId = req.params.project_id
|
const projectId = req.params.project_id
|
||||||
const path = `/${req.params[0]}` // UpdateMerger expects leading slash
|
const path = `/${req.params[0]}` // UpdateMerger expects leading slash
|
||||||
const source = req.headers['x-sl-update-source'] || 'unknown'
|
const source =
|
||||||
|
req.headers['x-sl-update-source'] ||
|
||||||
|
req.headers['x-update-source'] ||
|
||||||
|
'unknown'
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await UpdateMerger.promises.mergeUpdate(null, projectId, path, req, source)
|
await UpdateMerger.promises.mergeUpdate(null, projectId, path, req, source)
|
||||||
|
@ -158,7 +167,10 @@ async function updateProjectContents(req, res, next) {
|
||||||
async function deleteProjectContents(req, res, next) {
|
async function deleteProjectContents(req, res, next) {
|
||||||
const projectId = req.params.project_id
|
const projectId = req.params.project_id
|
||||||
const path = `/${req.params[0]}` // UpdateMerger expects leading slash
|
const path = `/${req.params[0]}` // UpdateMerger expects leading slash
|
||||||
const source = req.headers['x-sl-update-source'] || 'unknown'
|
const source =
|
||||||
|
req.headers['x-sl-update-source'] ||
|
||||||
|
req.headers['x-update-source'] ||
|
||||||
|
'unknown'
|
||||||
|
|
||||||
await UpdateMerger.promises.deleteUpdate(null, projectId, path, source)
|
await UpdateMerger.promises.deleteUpdate(null, projectId, path, source)
|
||||||
res.sendStatus(200)
|
res.sendStatus(200)
|
||||||
|
|
|
@ -103,6 +103,19 @@ describe('TpdsController', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.projectName = 'projectName'
|
this.projectName = 'projectName'
|
||||||
this.path = '/here.txt'
|
this.path = '/here.txt'
|
||||||
|
this.req = {
|
||||||
|
params: {
|
||||||
|
0: `${this.projectName}${this.path}`,
|
||||||
|
user_id: this.user_id,
|
||||||
|
project_id: '',
|
||||||
|
},
|
||||||
|
headers: {
|
||||||
|
'x-update-source': (this.source = 'dropbox'),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should process the update with the update receiver by name and old header', function (done) {
|
||||||
this.req = {
|
this.req = {
|
||||||
params: {
|
params: {
|
||||||
0: `${this.projectName}${this.path}`,
|
0: `${this.projectName}${this.path}`,
|
||||||
|
@ -113,6 +126,30 @@ describe('TpdsController', function () {
|
||||||
'x-sl-update-source': (this.source = 'dropbox'),
|
'x-sl-update-source': (this.source = 'dropbox'),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
const res = {
|
||||||
|
json: payload => {
|
||||||
|
expect(payload).to.deep.equal({
|
||||||
|
status: 'applied',
|
||||||
|
projectId: this.metadata.projectId.toString(),
|
||||||
|
entityId: this.metadata.entityId.toString(),
|
||||||
|
folderId: this.metadata.folderId.toString(),
|
||||||
|
entityType: this.metadata.entityType,
|
||||||
|
rev: this.metadata.rev.toString(),
|
||||||
|
})
|
||||||
|
this.TpdsUpdateHandler.promises.newUpdate
|
||||||
|
.calledWith(
|
||||||
|
this.user_id,
|
||||||
|
'', // projectId
|
||||||
|
this.projectName,
|
||||||
|
this.path,
|
||||||
|
this.req,
|
||||||
|
this.source
|
||||||
|
)
|
||||||
|
.should.equal(true)
|
||||||
|
done()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
this.TpdsController.mergeUpdate(this.req, res)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should process the update with the update receiver by name', function (done) {
|
it('should process the update with the update receiver by name', function (done) {
|
||||||
|
@ -162,7 +199,7 @@ describe('TpdsController', function () {
|
||||||
destroy() {},
|
destroy() {},
|
||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
'x-sl-update-source': (this.source = 'dropbox'),
|
'x-update-source': (this.source = 'dropbox'),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
const res = {
|
const res = {
|
||||||
|
@ -232,7 +269,7 @@ describe('TpdsController', function () {
|
||||||
destroy() {},
|
destroy() {},
|
||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
'x-sl-update-source': (this.source = 'dropbox'),
|
'x-update-source': (this.source = 'dropbox'),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
const res = {
|
const res = {
|
||||||
|
@ -260,7 +297,7 @@ describe('TpdsController', function () {
|
||||||
destroy() {},
|
destroy() {},
|
||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
'x-sl-update-source': (this.source = 'dropbox'),
|
'x-update-source': (this.source = 'dropbox'),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
const res = {
|
const res = {
|
||||||
|
@ -379,7 +416,7 @@ describe('TpdsController', function () {
|
||||||
destroy: sinon.stub(),
|
destroy: sinon.stub(),
|
||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
'x-sl-update-source': (this.source = 'github'),
|
'x-update-source': (this.source = 'github'),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
this.res = {
|
this.res = {
|
||||||
|
@ -419,7 +456,7 @@ describe('TpdsController', function () {
|
||||||
destroy: sinon.stub(),
|
destroy: sinon.stub(),
|
||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
'x-sl-update-source': (this.source = 'github'),
|
'x-update-source': (this.source = 'github'),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
this.res = {
|
this.res = {
|
||||||
|
|
Loading…
Reference in a new issue