tango-app-api-infra 3.0.50-dev → 3.0.51-dev

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-infra",
3
- "version": "3.0.50-dev",
3
+ "version": "3.0.51-dev",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -75,9 +75,9 @@ export async function createTicket( req, res ) {
75
75
  let Uidomain = `${appConfig.url.domain}/manage/stores/infra-ticket?storeId=${req.body.basicDetails.storeId}`;
76
76
 
77
77
  const html = htmlContent( { ...req.body, Uidomain: Uidomain, domain: appConfig.url.apiDomain, date: dayjs( req.body.issueDate ).format( 'YYYY-MM-DD' ), downtimetotal: downtimetotal, Timestamp: Timestamp } );
78
- await sendEmailWithSES( req.body.spocEmail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
79
-
80
-
78
+ if ( req.body.spocEmail&&req.body.issueType == 'infra' ) {
79
+ await sendEmailWithSES( req.body.spocEmail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
80
+ }
81
81
  if ( create ) {
82
82
  res.sendSuccess( 'Ticket Created Successfully' );
83
83
  }
@@ -86,7 +86,7 @@ export async function clientList( req, res ) {
86
86
  export async function basicList( req, res ) {
87
87
  try {
88
88
  let storeList = await findStore( { status: 'active' },
89
- { 'storeName': 1, 'storeId': 1, 'clientId': 1, 'storeProfile.open': 1, 'storeProfile.close': 1, 'storeProfile.timeZone': 1 } );
89
+ { 'storeName': 1, 'storeId': 1, 'ticketConfigs': 1, 'clientId': 1, 'storeProfile.open': 1, 'storeProfile.close': 1, 'storeProfile.timeZone': 1 } );
90
90
  res.sendSuccess( storeList );
91
91
  } catch ( error ) {
92
92
  logger.error( { error: error, function: 'basicList' } );
@@ -201,7 +201,9 @@ export async function updateRefreshTicket( req, res ) {
201
201
  }
202
202
  let Uidomain = `${appConfig.url.domain}/manage/stores/infra-ticket?storeId=${getTicket.basicDetails.storeId}`;
203
203
  const html = htmlContent( { ...getTicket, Uidomain: Uidomain, primary: primaryIssue, storeName: getTicket.basicDetails.storeName, hibernation: '', spocName: spocName, date: dayjs( getTicket.issueDate ).format( 'YYYY-MM-DD' ), downtimetotal: downtimetotal, Timestamp: Timestamp, domain: appConfig.url.apiDomain } );
204
- await sendEmailWithSES( spocEmail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
204
+ if ( spocEmail ) {
205
+ await sendEmailWithSES( spocEmail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
206
+ }
205
207
  }
206
208
  }
207
209
 
@@ -280,7 +282,7 @@ export async function closeTicket( req, res ) {
280
282
  let spocName = store.spocDetails[0].name;
281
283
  let Uidomain = `${appConfig.url.domain}/manage/stores/infra-ticket?storeId=${getTicket.basicDetails.storeId}`;
282
284
  const html = htmlContent( { ...getTicket, Uidomain: Uidomain, primaryIssue: primaryIssue, storeName: getTicket.basicDetails.storeName, spocName: spocName, date: dayjs( getTicket.issueDate ).format( 'YYYY-MM-DD HH:mm' ), downtimetotal: downtimetotal, Timestamp: Timestamp, domain: appConfig.url.apiDomain } );
283
- if ( spocEmail ) {
285
+ if ( spocEmail && spocEmail != '' &&spocEmail!='none'&& spocEmail != undefined ) {
284
286
  await sendEmailWithSES( spocEmail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
285
287
  }
286
288
  }
@@ -527,7 +529,7 @@ export async function infraReportSent( req, res ) {
527
529
  'Status ': element.status,
528
530
  'Responded By': clientuser && clientuser.userName ? clientuser.userName : '-',
529
531
  'Resolved By': tangouser && tangouser.userName ? tangouser.userName : '-',
530
- 'Closed Date & Time': element.issueClosedDate?dayjs( element.issueClosedDate ).format( 'YYYY-MM-DD HH:mm A' ):'-',
532
+ 'Closed Date & Time': element.issueClosedDate ? dayjs( element.issueClosedDate ).format( 'YYYY-MM-DD HH:mm A' ) : '-',
531
533
  'Latest Comment': '',
532
534
  'Activity Log': '',
533
535
  } );
@@ -541,7 +543,7 @@ export async function infraReportSent( req, res ) {
541
543
  ],
542
544
  } );
543
545
  let client = await findOneClient( { clientId: req.body.clientId } );
544
- let avgDownTime = client.ticketConfigs.infraDownTime*60;
546
+ let avgDownTime = client.ticketConfigs.infraDownTime * 60;
545
547
  let issueList = await findinfraReason( { parentId: { '$exists': false } } );
546
548
  const categoryCounts = {};
547
549
  let response;
@@ -565,8 +567,8 @@ export async function infraReportSent( req, res ) {
565
567
  } ) );
566
568
  }
567
569
  let reportdate = dayjs().format( 'YYYY-MM-DD' );
568
- let attachments= null;
569
- if ( exportdata.length>0 ) {
570
+ let attachments = null;
571
+ if ( exportdata.length > 0 ) {
570
572
  const wb = new xl.Workbook();
571
573
  const ws = wb.addWorksheet( 'Daily report' );
572
574
  const headers = Object.keys( exportdata[0] );
@@ -605,3 +607,16 @@ export async function infraReportSent( req, res ) {
605
607
  res.sendError( error, 500 );
606
608
  }
607
609
  }
610
+ export async function spocmailchange() {
611
+ let storelist = await findStore( {} );
612
+ for ( let store of storelist ) {
613
+ if ( store && store.spocDetails ) {
614
+ let spoclist = [];
615
+ for ( let spoc of store.spocDetails ) {
616
+ spoc.email = spoc.email.replace( '@', '1@' ),
617
+ spoclist.push( spoc );
618
+ }
619
+ await updateOneStore( { storeId: store.storeId }, { spocDetails: spoclist } );
620
+ }
621
+ }
622
+ }
@@ -2,7 +2,7 @@
2
2
  import express from 'express';
3
3
  import {
4
4
  migrateClient, migrateStores, basicList, clientList, setTicketTime, downStoresList,
5
- openTicketList, assigntoUser, updateRefreshTicket, closeTicket, emailUserList, infraReportSent,
5
+ openTicketList, assigntoUser, updateRefreshTicket, closeTicket, spocmailchange, emailUserList, infraReportSent,
6
6
  } from '../controllers/internalInfra.controller.js';
7
7
 
8
8
  export const internalInfraRouter = express.Router();
@@ -19,5 +19,6 @@ internalInfraRouter.post( '/updateRefreshTicket', updateRefreshTicket );
19
19
  internalInfraRouter.post( '/closeTicket', closeTicket );
20
20
  internalInfraRouter.get( '/emailUserList', emailUserList );
21
21
  internalInfraRouter.post( '/infraReportSent', infraReportSent );
22
+ internalInfraRouter.post( '/spocmailchange', spocmailchange );
22
23
 
23
24
 
@@ -30,15 +30,18 @@ export async function validateDetails( req, res, next ) {
30
30
  };
31
31
 
32
32
  if ( req.body.issueType == 'infra' ) {
33
+ let refreshdate = dayjs().add( client.ticketConfigs.refreshAlert, 'days' );
33
34
  req.body.ticketDetails = {
34
- ticketRefreshTime: dayjs().add( client.ticketConfigs.refreshAlert, 'days' ),
35
+ ticketRefreshTime: new Date( dayjs( refreshdate ).format( 'YYYY-MM-DD' ) ),
35
36
  };
36
37
  } else if ( req.body.issueType == 'installation' ) {
38
+ let refreshdate = dayjs().add( client.ticketConfigs.installationReAssign, 'days' );
37
39
  req.body.ticketDetails = {
38
- ticketRefreshTime: dayjs().add( client.ticketConfigs.installationReAssign, 'days' ),
40
+ ticketRefreshTime: new Date( dayjs( refreshdate ).format( 'YYYY-MM-DD' ) ),
39
41
  };
40
42
  }
41
43
 
44
+
42
45
  next();
43
46
  } catch ( error ) {
44
47
  logger.error( { error: error, function: 'validateDetails' } );
@@ -64,6 +67,7 @@ export async function validateTicket( req, res, next ) {
64
67
  'basicDetails.storeId': req.body.basicDetails.storeId,
65
68
  'issueType': 'infra',
66
69
  'status': { $ne: 'closed' },
70
+ 'ticketDetails.ticketRefreshTime': { $lte: new Date() },
67
71
  'ticketDetails.ticketType': 'refreshticket',
68
72
  },
69
73
  );