tango-app-api-trax 3.2.1-beta-1 → 3.2.1-beta-2
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-2",
|
|
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;
|
|
@@ -2478,7 +2478,7 @@ export async function questionList( req, res ) {
|
|
|
2478
2478
|
if ( answer.validationAnswer && answer.validationAnswer !='' ) {
|
|
2479
2479
|
checkvalidation = await signedUrl( { file_path: decodeURIComponent( answer.validationAnswer ), Bucket: bucket.sop } );
|
|
2480
2480
|
}
|
|
2481
|
-
Multianswer.push( { 'answer': answer.answer, '
|
|
2481
|
+
Multianswer.push( { 'answer': answer.answer, 'no': ansIndex, 'validationAnswer': checkvalidation } );
|
|
2482
2482
|
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].index = ansIndex;
|
|
2483
2483
|
}
|
|
2484
2484
|
if ( answer.referenceImage != '' ) {
|
|
@@ -2508,7 +2508,7 @@ export async function questionList( req, res ) {
|
|
|
2508
2508
|
if ( question.answerType == 'multipleImage' ) {
|
|
2509
2509
|
if ( userAns && userAns.answer && userAns.answer !='' ) {
|
|
2510
2510
|
let manswer = await signedUrl( { file_path: decodeURIComponent( userAns.answer ), Bucket: bucket.sop } );
|
|
2511
|
-
Multianswer.push( { 'answer': manswer, '
|
|
2511
|
+
Multianswer.push( { 'answer': manswer, 'no': userAnsIndex, 'validationAnswer': '' } );
|
|
2512
2512
|
} else {
|
|
2513
2513
|
|
|
2514
2514
|
}
|
|
@@ -2531,7 +2531,7 @@ export async function questionList( req, res ) {
|
|
|
2531
2531
|
if ( Multianswer.length ) {
|
|
2532
2532
|
question.Multianswer = Multianswer;
|
|
2533
2533
|
} else {
|
|
2534
|
-
Multianswer.push( { 'answer': null, '
|
|
2534
|
+
Multianswer.push( { 'answer': null, 'no': 0, 'validationAnswer': null } );
|
|
2535
2535
|
question.Multianswer = Multianswer;
|
|
2536
2536
|
}
|
|
2537
2537
|
}
|
|
@@ -2812,7 +2812,7 @@ export async function taskQuestionList( req, res ) {
|
|
|
2812
2812
|
if ( answer.validationAnswer && answer.validationAnswer != '' ) {
|
|
2813
2813
|
checkvalidation = await signedUrl( { file_path: decodeURIComponent( answer.validationAnswer ), Bucket: bucket.sop } );
|
|
2814
2814
|
}
|
|
2815
|
-
Multianswer.push( { 'answer': answer.answer, '
|
|
2815
|
+
Multianswer.push( { 'answer': answer.answer, 'no': ansIndex, 'validationAnswer': checkvalidation } );
|
|
2816
2816
|
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].index = ansIndex;
|
|
2817
2817
|
}
|
|
2818
2818
|
if ( ( answer.validationType == 'Capture Image' || answer.validationType == 'Capture Video' ) && answer.validationAnswer && answer.validationAnswer != '' ) {
|
|
@@ -2852,7 +2852,7 @@ export async function taskQuestionList( req, res ) {
|
|
|
2852
2852
|
if ( question.answerType == 'multipleImage' ) {
|
|
2853
2853
|
if ( userAns && userAns.answer && userAns.answer != '' ) {
|
|
2854
2854
|
let manswer = await signedUrl( { file_path: decodeURIComponent( userAns.answer ), Bucket: bucket.sop } );
|
|
2855
|
-
Multianswer.push( { 'answer': manswer, '
|
|
2855
|
+
Multianswer.push( { 'answer': manswer, 'no': userAnsIndex, 'validationAnswer': '' } );
|
|
2856
2856
|
} else {
|
|
2857
2857
|
|
|
2858
2858
|
}
|
|
@@ -2875,7 +2875,7 @@ export async function taskQuestionList( req, res ) {
|
|
|
2875
2875
|
if ( Multianswer.length ) {
|
|
2876
2876
|
question.Multianswer = Multianswer;
|
|
2877
2877
|
} else {
|
|
2878
|
-
Multianswer.push( { 'answer': null, '
|
|
2878
|
+
Multianswer.push( { 'answer': null, 'no': 0, 'validationAnswer': null } );
|
|
2879
2879
|
question.Multianswer = Multianswer;
|
|
2880
2880
|
}
|
|
2881
2881
|
}
|
|
@@ -3282,3 +3282,24 @@ export async function checkVersion( req, res ) {
|
|
|
3282
3282
|
return res.sendError( e, 500 );
|
|
3283
3283
|
}
|
|
3284
3284
|
}
|
|
3285
|
+
|
|
3286
|
+
export async function clientConfig( req, res ) {
|
|
3287
|
+
try {
|
|
3288
|
+
let requestData = req.body;
|
|
3289
|
+
if ( requestData.clientId && requestData.clientId !='' ) {
|
|
3290
|
+
let getClientData = await clientService.findOne( { clientId: requestData.clientId }, { traxRAWImageUpload: 1, clientId: 1, clientName: 1 } );
|
|
3291
|
+
console.log( ' getClientData=>', getClientData );
|
|
3292
|
+
if ( getClientData ) {
|
|
3293
|
+
return res.sendSuccess( getClientData );
|
|
3294
|
+
} else {
|
|
3295
|
+
return res.sendError( 'Invalid clientId', 400 );
|
|
3296
|
+
}
|
|
3297
|
+
} else {
|
|
3298
|
+
return res.sendError( 'clientId is Required', 400 );
|
|
3299
|
+
}
|
|
3300
|
+
} catch ( e ) {
|
|
3301
|
+
console.log( 'e =>', e );
|
|
3302
|
+
logger.error( { error: e, function: 'clientConfig' } );
|
|
3303
|
+
return res.sendError( e, 500 );
|
|
3304
|
+
}
|
|
3305
|
+
}
|
|
@@ -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
|
|