tango-app-api-infra 3.0.52-dev → 3.0.53-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
|
@@ -75,7 +75,7 @@ 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
|
-
if ( req.body.spocEmail&&req.body.issueType == 'infra' ) {
|
|
78
|
+
if ( req.body.spocEmail&&req.body.issueType == 'infra'&&isValidEmail( req.body.spocEmail ) ) {
|
|
79
79
|
await sendEmailWithSES( req.body.spocEmail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
|
|
80
80
|
}
|
|
81
81
|
if ( create ) {
|
|
@@ -86,6 +86,10 @@ export async function createTicket( req, res ) {
|
|
|
86
86
|
return res.sendError( error, 500 );
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
+
function isValidEmail( email ) {
|
|
90
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
91
|
+
return emailRegex.test( email );
|
|
92
|
+
}
|
|
89
93
|
export async function bulkcreateTicket( req, res ) {
|
|
90
94
|
try {
|
|
91
95
|
let response = {};
|
|
@@ -201,7 +201,7 @@ 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
|
-
if ( spocEmail ) {
|
|
204
|
+
if ( spocEmail && isValidEmail( spocEmail ) ) {
|
|
205
205
|
await sendEmailWithSES( spocEmail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
|
|
206
206
|
}
|
|
207
207
|
}
|
|
@@ -221,6 +221,7 @@ export async function closeTicket( req, res ) {
|
|
|
221
221
|
if ( ticket.status == 'closed' ) {
|
|
222
222
|
getTicket.ticketActivity.push( {
|
|
223
223
|
actionType: 'dataRecived',
|
|
224
|
+
timeStamp: new Date(),
|
|
224
225
|
actionBy: 'Tango',
|
|
225
226
|
} );
|
|
226
227
|
}
|
|
@@ -282,7 +283,7 @@ export async function closeTicket( req, res ) {
|
|
|
282
283
|
let spocName = store.spocDetails[0].name;
|
|
283
284
|
let Uidomain = `${appConfig.url.domain}/manage/stores/infra-ticket?storeId=${getTicket.basicDetails.storeId}`;
|
|
284
285
|
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 } );
|
|
285
|
-
if ( spocEmail &&
|
|
286
|
+
if ( spocEmail && isValidEmail( spocEmail ) ) {
|
|
286
287
|
await sendEmailWithSES( spocEmail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
|
|
287
288
|
}
|
|
288
289
|
}
|
|
@@ -295,6 +296,10 @@ export async function closeTicket( req, res ) {
|
|
|
295
296
|
res.sendError( error, 500 );
|
|
296
297
|
}
|
|
297
298
|
}
|
|
299
|
+
function isValidEmail( email ) {
|
|
300
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
301
|
+
return emailRegex.test( email );
|
|
302
|
+
}
|
|
298
303
|
export async function emailUserList( req, res ) {
|
|
299
304
|
try {
|
|
300
305
|
let clientList = await aggregateClient( [
|
|
@@ -600,7 +605,10 @@ export async function infraReportSent( req, res ) {
|
|
|
600
605
|
|
|
601
606
|
|
|
602
607
|
const html = htmlContent( { ...req.body, Uidomain: Uidomain, issueCount: issueCount, avgDownTime: avgDownTime, reportdate: reportdate, content: response, date: date, domain: appConfig.url.apiDomain } );
|
|
603
|
-
|
|
608
|
+
if ( isValidEmail( req.body.email ) ) {
|
|
609
|
+
const result = await sendEmailWithSES( req.body.email, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
|
|
610
|
+
res.sendSuccess( result );
|
|
611
|
+
}
|
|
604
612
|
res.sendSuccess( result );
|
|
605
613
|
} catch ( error ) {
|
|
606
614
|
logger.error( { error: error, function: 'infraReportSent' } );
|