@@ -81,7 +81,7 @@ module.exports = (service, endpoint) => {
81
81
} ;
82
82
83
83
// Nonstandard REST; OpenRosa-specific API.
84
- service . post ( path , multipart . any ( ) , multerUtf , endpoint . openRosa ( ( { Forms, Submissions, SubmissionAttachments } , { params, files, auth, query, headers } ) =>
84
+ service . post ( path , multipart . any ( ) , multerUtf , endpoint . openRosa ( ( { Forms, Submissions, SubmissionAttachments } , { params, files, auth, query, userAgent } ) =>
85
85
Submission . fromXml ( findMultipart ( files ) . buffer )
86
86
. then ( ( partial ) => getForm ( auth , params , partial . xmlFormId , Forms , partial . def . version )
87
87
. catch ( forceAuthFailed )
@@ -124,7 +124,7 @@ module.exports = (service, endpoint) => {
124
124
}
125
125
// NEW SUBMISSION REQUEST: create a new submission and attachments.
126
126
return Promise . all ( [
127
- Submissions . createNew ( partial , form , query . deviceID , headers [ 'user-agent' ] ) ,
127
+ Submissions . createNew ( partial , form , query . deviceID , userAgent ) ,
128
128
Forms . getBinaryFields ( form . def . id )
129
129
] ) . then ( ( [ saved , binaryFields ] ) => SubmissionAttachments . create ( saved , form , binaryFields , files ) ) ;
130
130
} ) ;
@@ -177,7 +177,7 @@ module.exports = (service, endpoint) => {
177
177
// and repeated for draft/nondraft.
178
178
179
179
const restSubmission = ( base , draft , getForm ) => {
180
- service . post ( `${ base } /submissions` , endpoint ( ( { Forms, Submissions, SubmissionAttachments } , { params, auth, query, headers } , request ) =>
180
+ service . post ( `${ base } /submissions` , endpoint ( ( { Forms, Submissions, SubmissionAttachments } , { params, auth, query, userAgent } , request ) =>
181
181
Submission . fromXml ( request )
182
182
. then ( ( partial ) => getForm ( params , Forms , partial . def . version )
183
183
. then ( ( form ) => auth . canOrReject ( 'submission.create' , form ) )
@@ -186,15 +186,15 @@ module.exports = (service, endpoint) => {
186
186
return reject ( Problem . user . unexpectedValue ( { field : 'form id' , value : partial . xmlFormId , reason : 'did not match the form ID in the URL' } ) ) ;
187
187
188
188
return Promise . all ( [
189
- Submissions . createNew ( partial , form , query . deviceID , headers [ 'user-agent' ] ) ,
189
+ Submissions . createNew ( partial , form , query . deviceID , userAgent ) ,
190
190
Forms . getBinaryFields ( form . def . id )
191
191
] )
192
192
. then ( ( [ submission , binaryFields ] ) =>
193
193
SubmissionAttachments . create ( submission , form , binaryFields )
194
194
. then ( always ( submission ) ) ) ;
195
195
} ) ) ) ) ;
196
196
197
- service . put ( `${ base } /submissions/:instanceId` , endpoint ( ( { Forms, Submissions, SubmissionAttachments } , { params, auth, query, headers } , request ) =>
197
+ service . put ( `${ base } /submissions/:instanceId` , endpoint ( ( { Forms, Submissions, SubmissionAttachments } , { params, auth, query, userAgent } , request ) =>
198
198
Submission . fromXml ( request ) . then ( ( partial ) => {
199
199
if ( partial . xmlFormId !== params . formId )
200
200
return reject ( Problem . user . unexpectedValue ( { field : 'form id' , value : partial . xmlFormId , reason : 'did not match the form ID in the URL' } ) ) ;
@@ -211,7 +211,7 @@ module.exports = (service, endpoint) => {
211
211
. then ( getOrNotFound ) // this request exists just to check existence and fail the whole request.
212
212
] )
213
213
. then ( ( [ deprecated , form ] ) => Promise . all ( [
214
- Submissions . createVersion ( partial , deprecated , form , query . deviceID , headers [ 'user-agent' ] ) ,
214
+ Submissions . createVersion ( partial , deprecated , form , query . deviceID , userAgent ) ,
215
215
Forms . getBinaryFields ( form . def . id ) ,
216
216
SubmissionAttachments . getForFormAndInstanceId ( form . id , deprecatedId , draft ) ,
217
217
] )
0 commit comments