tango-app-api-trax 3.6.0-sec-7 → 3.6.0-sec-8

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.6.0-sec-7",
3
+ "version": "3.6.0-sec-8",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -2462,3 +2462,43 @@ export async function storecheckExists( data ) {
2462
2462
  logger.error( { error: error, function: 'internalAISendPushNotification' } );
2463
2463
  }
2464
2464
  }
2465
+
2466
+ export async function insertAINotification( req, res ) {
2467
+ try {
2468
+ let requestData = req.body;
2469
+ let insertData= [];
2470
+ let findAllUser = await userService.find( { clientId: requestData.clientId, isActive: true } );
2471
+ for ( let user of findAllUser ) {
2472
+ let data= {};
2473
+ data.userId = user._id;
2474
+ data.storeId = requestData.storeId;
2475
+ data.storeName = requestData.storeName;
2476
+ data.captureTime = requestData.captureTime;
2477
+ data.clientId = requestData.clientId;
2478
+ data.sourceCheckList_id = requestData.sourceCheckList_id;
2479
+ data.checkListName = requestData.checkListName;
2480
+ data.notificationType = requestData.notificationType;
2481
+ let payload = {
2482
+ userType: user.userType,
2483
+ role: user.role,
2484
+ assignedStores: user.assignedStores,
2485
+ clientId: user.clientId,
2486
+ email: user.email,
2487
+ };
2488
+ let result = await storecheckExists( payload );
2489
+ if ( result ) {
2490
+ insertData.push( data );
2491
+ }
2492
+ }
2493
+ // console.log( 'insertData =>', insertData );
2494
+ let create = await notificationModel.insertManynotificationModel( insertData );
2495
+ // console.log( 'create =>', create );
2496
+ if ( create ) {
2497
+ return res.sendSuccess( 'updated successfully' );
2498
+ }
2499
+ } catch ( e ) {
2500
+ logger.error( { error: e, function: 'insertAINotification' } );
2501
+ if ( e.name === 'ValidationError' ) res.sendBadRequest( e );
2502
+ else res.sendError( e, 500 );
2503
+ }
2504
+ }
@@ -24,6 +24,7 @@ internalTraxRouter
24
24
  .post( '/sendPushNotification', isAllowedInternalAPIHandler, internalController.internalSendPushNotification )
25
25
  .post( '/sendAiPushNotification', isAllowedInternalAPIHandler, internalController.internalAISendPushNotification )
26
26
  .post( '/getLiveChecklistClients', isAllowedInternalAPIHandler, internalController.getLiveChecklistClients )
27
- .post( '/notificationCreate', isAllowedInternalAPIHandler, internalController.notificationCreate );
27
+ .post( '/notificationCreate', isAllowedInternalAPIHandler, internalController.notificationCreate )
28
+ .post( '/insertAINotification', isAllowedInternalAPIHandler, internalController.insertAINotification );
28
29
 
29
30