tango-app-api-trax 3.3.1-hotfix-8 → 3.3.1-hotfix-10

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.3.1-hotfix-8",
3
+ "version": "3.3.1-hotfix-10",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -27,7 +27,7 @@
27
27
  "nodemon": "^3.1.4",
28
28
  "path": "^0.12.7",
29
29
  "tango-api-schema": "^2.2.70",
30
- "tango-app-api-middleware": "^3.1.55",
30
+ "tango-app-api-middleware": "^3.1.65",
31
31
  "url": "^0.11.4",
32
32
  "winston": "^3.13.1",
33
33
  "winston-daily-rotate-file": "^5.0.0"
@@ -1644,3 +1644,51 @@ async function getUserToken( clientId, userEmail ) {
1644
1644
  return false;
1645
1645
  }
1646
1646
  }
1647
+
1648
+ export async function internalAISendPushNotification( req, res ) {
1649
+ try {
1650
+ let requestData = req.body;
1651
+ if ( !requestData.clientId ) {
1652
+ return res.sendError( 'clientId is Required', 400 );
1653
+ }
1654
+ if ( !( requestData?.email || requestData?.storeId ) ) {
1655
+ return res.sendError( 'Email or StoreId is Required', 400 );
1656
+ }
1657
+
1658
+ if ( !requestData.title ) {
1659
+ return res.sendError( 'Title is Required', 400 );
1660
+ }
1661
+
1662
+ if ( !requestData.description ) {
1663
+ return res.sendError( 'Description is Required', 400 );
1664
+ }
1665
+
1666
+ let fcmToken;
1667
+ if ( requestData.email && requestData.email !='' ) {
1668
+ fcmToken = await getUserToken( requestData.clientId, requestData.email );
1669
+ } else {
1670
+ let storeData = await storeService.findOne( { clientId: requestData.clientId, storeId: requestData.storeId }, { spocDetails: 1 } );
1671
+ if ( storeData && storeData.spocDetails.length > 0 && storeData.spocDetails[0].email ) {
1672
+ fcmToken = await getUserToken( storeData.spocDetails[0].email );
1673
+ }
1674
+ }
1675
+ if ( !fcmToken ) {
1676
+ return res.sendSuccess( 'Notification Send Successfully' );
1677
+ }
1678
+ let custom = {
1679
+ type: req.body?.type,
1680
+ storeId: req.body?.storeId,
1681
+ date: req.body?.date,
1682
+ };
1683
+ let responseData = await sendPushNotification( requestData.title, requestData.description, fcmToken, custom );
1684
+ if ( responseData ) {
1685
+ return res.sendSuccess( 'Notification Send Successfully' );
1686
+ } else {
1687
+ return res.sendSuccess( 'Notification Send Successfully' );
1688
+ }
1689
+ } catch ( e ) {
1690
+ logger.error( { error: e, function: 'internalAISendPushNotification' } );
1691
+ if ( e.name === 'ValidationError' ) res.sendBadRequest( e );
1692
+ else res.sendError( e, 500 );
1693
+ }
1694
+ };
@@ -2462,7 +2462,7 @@ export async function checklistv1( req, res ) {
2462
2462
  ...projectExtraConditions,
2463
2463
  client_id: { $ifNull: [ '$client_id', '' ] },
2464
2464
  coverage: { $ifNull: [ '$coverage', '' ] },
2465
- taskType: { $ifNull: [ '$type', '' ] },
2465
+ taskType: { $ifNull: [ '$planoType', '' ] },
2466
2466
  },
2467
2467
  },
2468
2468
  ];
@@ -20,6 +20,7 @@ internalTraxRouter
20
20
  .post( '/getPDFCSVChecklistDetails', isAllowedInternalAPIHandler, internalController.getPDFCSVChecklistDetails )
21
21
  .get( '/getOTP', isAllowedInternalAPIHandler, internalController.getOTP )
22
22
  .get( '/getDownloads', isAllowedInternalAPIHandler, internalController.getDownloads )
23
- .post( '/sendPushNotification', isAllowedInternalAPIHandler, internalController.internalSendPushNotification );
23
+ .post( '/sendPushNotification', isAllowedInternalAPIHandler, internalController.internalSendPushNotification )
24
+ .post( '/sendAiPushNotification', isAllowedInternalAPIHandler, internalController.internalAISendPushNotification );
24
25
 
25
26