Jelajahi Sumber

Merge pull request #720 from sharelatex/mm-export-v1projectid

Include project's and user's v1 ID in export requests
Hugh O'Brien 8 tahun lalu
induk
melakukan
a230b5efab

+ 3 - 1
services/web/app/coffee/Features/Exports/ExportsHandler.coffee

@@ -31,7 +31,7 @@ module.exports = ExportsHandler = self =
 				ProjectLocator.findRootDoc {project: results.project, project_id: project_id}, cb
 				ProjectLocator.findRootDoc {project: results.project, project_id: project_id}, cb
 			]
 			]
 			user: (cb) ->
 			user: (cb) ->
-				UserGetter.getUser user_id, {first_name: 1, last_name: 1, email: 1}, cb
+				UserGetter.getUser user_id, {first_name: 1, last_name: 1, email: 1, overleaf: 1}, cb
 			historyVersion: (cb) ->
 			historyVersion: (cb) ->
 				self._requestVersion project_id, cb
 				self._requestVersion project_id, cb
 
 
@@ -56,12 +56,14 @@ module.exports = ExportsHandler = self =
 					rootDocPath: rootDoc[1]?.fileSystem
 					rootDocPath: rootDoc[1]?.fileSystem
 					historyId: project.overleaf?.history?.id
 					historyId: project.overleaf?.history?.id
 					historyVersion: historyVersion
 					historyVersion: historyVersion
+					v1ProjectId: project.overleaf?.id
 				user:
 				user:
 					id: user_id
 					id: user_id
 					firstName: user.first_name
 					firstName: user.first_name
 					lastName: user.last_name
 					lastName: user.last_name
 					email: user.email
 					email: user.email
 					orcidId: null # until v2 gets ORCID
 					orcidId: null # until v2 gets ORCID
+					v1UserId: user.overleaf?.id
 				destination:
 				destination:
 					brandVariationId: brand_variation_id
 					brandVariationId: brand_variation_id
 				options:
 				options:

+ 8 - 1
services/web/test/unit/coffee/Exports/ExportsHandlerTests.coffee

@@ -64,6 +64,7 @@ describe 'ExportsHandler', ->
 			@project =
 			@project =
 				id: @project_id
 				id: @project_id
 				overleaf:
 				overleaf:
+					id: @project_history_id # for projects imported from v1
 					history:
 					history:
 						id: @project_history_id
 						id: @project_history_id
 			@user =
 			@user =
@@ -71,6 +72,8 @@ describe 'ExportsHandler', ->
 				first_name: 'Arthur'
 				first_name: 'Arthur'
 				last_name: 'Author'
 				last_name: 'Author'
 				email: 'arthur.author@arthurauthoring.org'
 				email: 'arthur.author@arthurauthoring.org'
+				overleaf:
+					id: 876
 			@rootDocPath = 'main.tex'
 			@rootDocPath = 'main.tex'
 			@historyVersion = 777
 			@historyVersion = 777
 			@ProjectGetter.getProject = sinon.stub().yields(null, @project)
 			@ProjectGetter.getProject = sinon.stub().yields(null, @project)
@@ -90,18 +93,20 @@ describe 'ExportsHandler', ->
 				.should.equal true
 				.should.equal true
 
 
 			it "should return export data", ->
 			it "should return export data", ->
-				expected_export_data = 
+				expected_export_data =
 					project:
 					project:
 						id: @project_id
 						id: @project_id
 						rootDocPath: @rootDocPath
 						rootDocPath: @rootDocPath
 						historyId: @project_history_id
 						historyId: @project_history_id
 						historyVersion: @historyVersion
 						historyVersion: @historyVersion
+						v1ProjectId: @project_history_id
 					user:
 					user:
 						id: @user_id
 						id: @user_id
 						firstName: @user.first_name
 						firstName: @user.first_name
 						lastName: @user.last_name
 						lastName: @user.last_name
 						email: @user.email
 						email: @user.email
 						orcidId: null
 						orcidId: null
+						v1UserId: 876
 					destination:
 					destination:
 						brandVariationId: @brand_variation_id
 						brandVariationId: @brand_variation_id
 					options:
 					options:
@@ -126,12 +131,14 @@ describe 'ExportsHandler', ->
 						rootDocPath: @rootDocPath
 						rootDocPath: @rootDocPath
 						historyId: @project_history_id
 						historyId: @project_history_id
 						historyVersion: @historyVersion
 						historyVersion: @historyVersion
+						v1ProjectId: @project_history_id
 					user:
 					user:
 						id: @user_id
 						id: @user_id
 						firstName: @custom_first_name
 						firstName: @custom_first_name
 						lastName: @custom_last_name
 						lastName: @custom_last_name
 						email: @user.email
 						email: @user.email
 						orcidId: null
 						orcidId: null
+						v1UserId: 876
 					destination:
 					destination:
 						brandVariationId: @brand_variation_id
 						brandVariationId: @brand_variation_id
 					options:
 					options: