tango-app-api-trax 3.2.1-beta-1 → 3.2.1-beta-3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-trax",
|
|
3
|
-
"version": "3.2.1-beta-
|
|
3
|
+
"version": "3.2.1-beta-3",
|
|
4
4
|
"description": "Trax",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"mongodb": "^6.8.0",
|
|
27
27
|
"nodemon": "^3.1.4",
|
|
28
28
|
"path": "^0.12.7",
|
|
29
|
-
"tango-api-schema": "^2.2.
|
|
29
|
+
"tango-api-schema": "^2.2.24",
|
|
30
30
|
"tango-app-api-middleware": "^3.1.50",
|
|
31
31
|
"url": "^0.11.4",
|
|
32
32
|
"winston": "^3.13.1",
|
|
@@ -1421,3 +1421,70 @@ export async function taskPushNotification( req, res ) {
|
|
|
1421
1421
|
return res.sendError( e, 500 );
|
|
1422
1422
|
}
|
|
1423
1423
|
}
|
|
1424
|
+
|
|
1425
|
+
export async function internalSendPushNotification( req, res ) {
|
|
1426
|
+
try {
|
|
1427
|
+
let requestHeader = req.headers;
|
|
1428
|
+
if ( !( requestHeader.clientid ) ) {
|
|
1429
|
+
return res.sendError( 'clientid is Required', 400 );
|
|
1430
|
+
}
|
|
1431
|
+
if ( !( requestHeader.email || requestHeader.storeid ) ) {
|
|
1432
|
+
return res.sendError( 'Email or Storeid is Required', 400 );
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
let requestData = req.body;
|
|
1436
|
+
if ( !requestData.title ) {
|
|
1437
|
+
return res.sendError( 'Title is Required', 400 );
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
if ( !requestData.description ) {
|
|
1441
|
+
return res.sendError( 'Description is Required', 400 );
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
let fcmToken;
|
|
1445
|
+
// fcmToken = 'dwm2tz9WfUq1jdz1H8hfSf:APA91bF9BhTsG9ZDnutQfseGueXk7FZ4RhB8v3G_xJOZhkiZz8vsw3SUWk5su8ZN37lx3-H50eouBKinbwg4zE_br6f483jUswA_44f1XG8k7Sok995f77M';
|
|
1446
|
+
if ( requestHeader.email && requestHeader.email !='' ) {
|
|
1447
|
+
fcmToken = await getUserToken( requestHeader.clientid, requestHeader.email );
|
|
1448
|
+
} else {
|
|
1449
|
+
let storeData = await storeService.findOne( { clientId: requestHeader.clientid, storeId: requestHeader.storeid }, { spocDetails: 1 } );
|
|
1450
|
+
if ( storeData && storeData.spocDetails.length > 0 && storeData.spocDetails[0].email ) {
|
|
1451
|
+
fcmToken = await getUserToken( storeData.spocDetails[0].email );
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
// console.log( 'fcmToken =>', fcmToken );
|
|
1455
|
+
if ( !fcmToken ) {
|
|
1456
|
+
// return res.sendError( 'Token not found', 400 );
|
|
1457
|
+
return res.sendSuccess( 'Notification Send Successfully' );
|
|
1458
|
+
}
|
|
1459
|
+
let responseData = await sendPushNotification( requestData.title, requestData.description, fcmToken );
|
|
1460
|
+
// console.log( 'responseData =>', responseData );
|
|
1461
|
+
if ( responseData ) {
|
|
1462
|
+
return res.sendSuccess( 'Notification Send Successfully' );
|
|
1463
|
+
} else {
|
|
1464
|
+
// return res.sendError( 'Token not found', 400 );
|
|
1465
|
+
return res.sendSuccess( 'Notification Send Successfully' );
|
|
1466
|
+
}
|
|
1467
|
+
} catch ( e ) {
|
|
1468
|
+
logger.error( { error: e, function: 'internalSendPushNotification' } );
|
|
1469
|
+
if ( e.name === 'ValidationError' ) res.sendBadRequest( e );
|
|
1470
|
+
else res.sendError( e, 500 );
|
|
1471
|
+
}
|
|
1472
|
+
};
|
|
1473
|
+
|
|
1474
|
+
async function getUserToken( clientId, userEmail ) {
|
|
1475
|
+
try {
|
|
1476
|
+
if ( clientId && clientId !='' && userEmail && userEmail !='' ) {
|
|
1477
|
+
let userData = await userService.findOne( { clientId: requestHeader.clientid, email: userEmail }, { fcmToken: 1 } );
|
|
1478
|
+
if ( userData && userData.fcmToken && userData.fcmToken !='' ) {
|
|
1479
|
+
return userData.fcmToken;
|
|
1480
|
+
} else {
|
|
1481
|
+
return false;
|
|
1482
|
+
}
|
|
1483
|
+
} else {
|
|
1484
|
+
return false;
|
|
1485
|
+
}
|
|
1486
|
+
} catch ( e ) {
|
|
1487
|
+
logger.error( { error: e, function: 'getUserToken' } );
|
|
1488
|
+
return false;
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
@@ -127,7 +127,7 @@ export async function startChecklist( req, res ) {
|
|
|
127
127
|
let Multianswer = [];
|
|
128
128
|
if ( question.answers.length > 0 ) {
|
|
129
129
|
question.answers.forEach( ( answer, ansIndex ) => {
|
|
130
|
-
Multianswer.push( { 'answer': null, '
|
|
130
|
+
Multianswer.push( { 'answer': null, 'no': ansIndex, 'validationAnswer': null } );
|
|
131
131
|
answer.index = ansIndex;
|
|
132
132
|
} );
|
|
133
133
|
question.Multianswer = Multianswer;
|
|
@@ -136,7 +136,7 @@ export async function startChecklist( req, res ) {
|
|
|
136
136
|
let Multianswer = [];
|
|
137
137
|
if ( question.answers.length > 0 ) {
|
|
138
138
|
question.answers.forEach( ( answer, ansIndex ) => {
|
|
139
|
-
Multianswer.push( { 'answer': null, '
|
|
139
|
+
Multianswer.push( { 'answer': null, 'no': ansIndex, 'validationAnswer': null } );
|
|
140
140
|
answer.index = ansIndex;
|
|
141
141
|
} );
|
|
142
142
|
question.Multianswer = Multianswer;
|
|
@@ -1792,7 +1792,9 @@ export async function submitChecklist( req, res ) {
|
|
|
1792
1792
|
// createdAt: createdAtDate,
|
|
1793
1793
|
// };
|
|
1794
1794
|
// await detectionService.create( detectionData );
|
|
1795
|
-
|
|
1795
|
+
if ( requestData.submittype == 'submit' ) {
|
|
1796
|
+
updateOpenSearch( req.user, requestData );
|
|
1797
|
+
}
|
|
1796
1798
|
|
|
1797
1799
|
return res.sendSuccess( 'Checklist Updated Successfully' );
|
|
1798
1800
|
} else {
|
|
@@ -1956,7 +1958,9 @@ export async function submitTask( req, res ) {
|
|
|
1956
1958
|
};
|
|
1957
1959
|
await checklistLogs.create( logInsertData );
|
|
1958
1960
|
|
|
1959
|
-
|
|
1961
|
+
if ( submittype == 'submit' ) {
|
|
1962
|
+
updateOpenSearchTask( user, requestData );
|
|
1963
|
+
}
|
|
1960
1964
|
|
|
1961
1965
|
return res.sendSuccess( 'Task Updated Successfully' );
|
|
1962
1966
|
} else {
|
|
@@ -2478,7 +2482,7 @@ export async function questionList( req, res ) {
|
|
|
2478
2482
|
if ( answer.validationAnswer && answer.validationAnswer !='' ) {
|
|
2479
2483
|
checkvalidation = await signedUrl( { file_path: decodeURIComponent( answer.validationAnswer ), Bucket: bucket.sop } );
|
|
2480
2484
|
}
|
|
2481
|
-
Multianswer.push( { 'answer': answer.answer, '
|
|
2485
|
+
Multianswer.push( { 'answer': answer.answer, 'no': ansIndex, 'validationAnswer': checkvalidation } );
|
|
2482
2486
|
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].index = ansIndex;
|
|
2483
2487
|
}
|
|
2484
2488
|
if ( answer.referenceImage != '' ) {
|
|
@@ -2508,7 +2512,7 @@ export async function questionList( req, res ) {
|
|
|
2508
2512
|
if ( question.answerType == 'multipleImage' ) {
|
|
2509
2513
|
if ( userAns && userAns.answer && userAns.answer !='' ) {
|
|
2510
2514
|
let manswer = await signedUrl( { file_path: decodeURIComponent( userAns.answer ), Bucket: bucket.sop } );
|
|
2511
|
-
Multianswer.push( { 'answer': manswer, '
|
|
2515
|
+
Multianswer.push( { 'answer': manswer, 'no': userAnsIndex, 'validationAnswer': '' } );
|
|
2512
2516
|
} else {
|
|
2513
2517
|
|
|
2514
2518
|
}
|
|
@@ -2531,7 +2535,7 @@ export async function questionList( req, res ) {
|
|
|
2531
2535
|
if ( Multianswer.length ) {
|
|
2532
2536
|
question.Multianswer = Multianswer;
|
|
2533
2537
|
} else {
|
|
2534
|
-
Multianswer.push( { 'answer': null, '
|
|
2538
|
+
Multianswer.push( { 'answer': null, 'no': 0, 'validationAnswer': null } );
|
|
2535
2539
|
question.Multianswer = Multianswer;
|
|
2536
2540
|
}
|
|
2537
2541
|
}
|
|
@@ -2812,7 +2816,7 @@ export async function taskQuestionList( req, res ) {
|
|
|
2812
2816
|
if ( answer.validationAnswer && answer.validationAnswer != '' ) {
|
|
2813
2817
|
checkvalidation = await signedUrl( { file_path: decodeURIComponent( answer.validationAnswer ), Bucket: bucket.sop } );
|
|
2814
2818
|
}
|
|
2815
|
-
Multianswer.push( { 'answer': answer.answer, '
|
|
2819
|
+
Multianswer.push( { 'answer': answer.answer, 'no': ansIndex, 'validationAnswer': checkvalidation } );
|
|
2816
2820
|
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].index = ansIndex;
|
|
2817
2821
|
}
|
|
2818
2822
|
if ( ( answer.validationType == 'Capture Image' || answer.validationType == 'Capture Video' ) && answer.validationAnswer && answer.validationAnswer != '' ) {
|
|
@@ -2852,7 +2856,7 @@ export async function taskQuestionList( req, res ) {
|
|
|
2852
2856
|
if ( question.answerType == 'multipleImage' ) {
|
|
2853
2857
|
if ( userAns && userAns.answer && userAns.answer != '' ) {
|
|
2854
2858
|
let manswer = await signedUrl( { file_path: decodeURIComponent( userAns.answer ), Bucket: bucket.sop } );
|
|
2855
|
-
Multianswer.push( { 'answer': manswer, '
|
|
2859
|
+
Multianswer.push( { 'answer': manswer, 'no': userAnsIndex, 'validationAnswer': '' } );
|
|
2856
2860
|
} else {
|
|
2857
2861
|
|
|
2858
2862
|
}
|
|
@@ -2875,7 +2879,7 @@ export async function taskQuestionList( req, res ) {
|
|
|
2875
2879
|
if ( Multianswer.length ) {
|
|
2876
2880
|
question.Multianswer = Multianswer;
|
|
2877
2881
|
} else {
|
|
2878
|
-
Multianswer.push( { 'answer': null, '
|
|
2882
|
+
Multianswer.push( { 'answer': null, 'no': 0, 'validationAnswer': null } );
|
|
2879
2883
|
question.Multianswer = Multianswer;
|
|
2880
2884
|
}
|
|
2881
2885
|
}
|
|
@@ -3282,3 +3286,24 @@ export async function checkVersion( req, res ) {
|
|
|
3282
3286
|
return res.sendError( e, 500 );
|
|
3283
3287
|
}
|
|
3284
3288
|
}
|
|
3289
|
+
|
|
3290
|
+
export async function clientConfig( req, res ) {
|
|
3291
|
+
try {
|
|
3292
|
+
let requestData = req.body;
|
|
3293
|
+
if ( requestData.clientId && requestData.clientId !='' ) {
|
|
3294
|
+
let getClientData = await clientService.findOne( { clientId: requestData.clientId }, { traxRAWImageUpload: 1, clientId: 1, clientName: 1 } );
|
|
3295
|
+
console.log( ' getClientData=>', getClientData );
|
|
3296
|
+
if ( getClientData ) {
|
|
3297
|
+
return res.sendSuccess( getClientData );
|
|
3298
|
+
} else {
|
|
3299
|
+
return res.sendError( 'Invalid clientId', 400 );
|
|
3300
|
+
}
|
|
3301
|
+
} else {
|
|
3302
|
+
return res.sendError( 'clientId is Required', 400 );
|
|
3303
|
+
}
|
|
3304
|
+
} catch ( e ) {
|
|
3305
|
+
console.log( 'e =>', e );
|
|
3306
|
+
logger.error( { error: e, function: 'clientConfig' } );
|
|
3307
|
+
return res.sendError( e, 500 );
|
|
3308
|
+
}
|
|
3309
|
+
}
|
|
@@ -2237,15 +2237,27 @@ async function insertPCBulkV3( getCLconfig, checklistId, currentdate, updatedche
|
|
|
2237
2237
|
await processedchecklist.insertMany( submitUser );
|
|
2238
2238
|
}
|
|
2239
2239
|
} else {
|
|
2240
|
-
let
|
|
2240
|
+
let deleteInprogressQuery = {
|
|
2241
2241
|
date_string: insertdata.date_string,
|
|
2242
2242
|
date_iso: insertdata.date_iso,
|
|
2243
2243
|
client_id: insertdata.client_id,
|
|
2244
2244
|
checkListId: updatedchecklist._id,
|
|
2245
|
-
checklistStatus: { $nin: [ 'submit' ] },
|
|
2245
|
+
checklistStatus: { $nin: [ 'submit', 'inprogress' ] },
|
|
2246
2246
|
};
|
|
2247
|
-
await processedchecklist.deleteMany(
|
|
2248
|
-
|
|
2247
|
+
await processedchecklist.deleteMany( deleteInprogressQuery );
|
|
2248
|
+
deleteInprogressQuery.checklistStatus = 'inprogress';
|
|
2249
|
+
let getInprogressData = await processedchecklist.find( deleteInprogressQuery, { userId: 1, store_id: 1 } );
|
|
2250
|
+
if ( getInprogressData ) {
|
|
2251
|
+
allQuestion = allQuestion.filter( ( item ) => {
|
|
2252
|
+
let inprogressData = getInprogressData.find( ( ele ) => ele.userId.toString() == item.userId.toString() && ele.store_id == item.store_id );
|
|
2253
|
+
if ( !inprogressData ) {
|
|
2254
|
+
return item;
|
|
2255
|
+
}
|
|
2256
|
+
} );
|
|
2257
|
+
}
|
|
2258
|
+
if ( allQuestion.length ) {
|
|
2259
|
+
await processedchecklist.insertMany( allQuestion );
|
|
2260
|
+
}
|
|
2249
2261
|
}
|
|
2250
2262
|
} else {
|
|
2251
2263
|
let unAssignedList = allQuestion.reduce( ( acc, item ) => {
|
|
@@ -19,6 +19,7 @@ internalTraxRouter
|
|
|
19
19
|
.get( '/checklist', isAllowedInternalAPIHandler, internalController.internalAPIChecklist )
|
|
20
20
|
.post( '/getPDFCSVChecklistDetails', isAllowedInternalAPIHandler, internalController.getPDFCSVChecklistDetails )
|
|
21
21
|
.get( '/getOTP', isAllowedInternalAPIHandler, internalController.getOTP )
|
|
22
|
-
.get( '/getDownloads', isAllowedInternalAPIHandler, internalController.getDownloads )
|
|
22
|
+
.get( '/getDownloads', isAllowedInternalAPIHandler, internalController.getDownloads )
|
|
23
|
+
.post( '/sendPushNotification', isAllowedInternalAPIHandler, internalController.internalSendPushNotification );
|
|
23
24
|
|
|
24
25
|
|
|
@@ -24,5 +24,6 @@ mobileRouter
|
|
|
24
24
|
.post( '/appVersion', mobileController.updateappVersion )
|
|
25
25
|
.post( '/verifylocation', isAllowedSessionHandler, mobileController.getStoreLocation, mobileController.location )
|
|
26
26
|
.post( '/login', mobileController.login )
|
|
27
|
-
.post( '/checkUpdateVersion', mobileController.checkVersion )
|
|
27
|
+
.post( '/checkUpdateVersion', mobileController.checkVersion )
|
|
28
|
+
.post( '/checkClientConfig', isAllowedSessionHandler, mobileController.clientConfig );
|
|
28
29
|
|