tango-app-api-infra 3.0.66-dev → 3.0.68-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.
@@ -4,7 +4,7 @@ import { aggregateTangoTicket } from '../services/tangoTicket.service.js';
4
4
  import { findOneStore } from '../services/store.service.js';
5
5
  import dayjs from 'dayjs';
6
6
  import { findinfraReason } from '../services/infraReason.service.js';
7
- import { signedUrl } from 'tango-app-api-middleware';
7
+ import { signedUrl, appConfig } from 'tango-app-api-middleware';
8
8
  export async function storeTicketList( req, res ) {
9
9
  try {
10
10
  let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
@@ -28,7 +28,20 @@ export async function storeTicketList( req, res ) {
28
28
  ticketId: 1,
29
29
  issueStatus: '$ticketDetails.issueStatus',
30
30
  ticketType: '$ticketDetails.ticketType',
31
- comments: { $size: '$ticketActivity' },
31
+ otherscomment: {
32
+ $filter: {
33
+ input: '$ticketActivity',
34
+ as: 'item',
35
+ cond: { $eq: [ '$$item.actionType', 'comment' ] },
36
+ },
37
+ },
38
+ comments: {
39
+ $filter: {
40
+ input: '$ticketActivity',
41
+ as: 'item',
42
+ cond: { $ne: [ '$$item.actionType', 'statusChange' ] },
43
+ },
44
+ },
32
45
  primaryIssue: {
33
46
  $filter: {
34
47
  input: '$ticketActivity',
@@ -43,11 +56,21 @@ export async function storeTicketList( req, res ) {
43
56
  path: '$primaryIssue', preserveNullAndEmptyArrays: true,
44
57
  },
45
58
  },
59
+ {
60
+ $unwind: {
61
+ path: '$otherscomment', preserveNullAndEmptyArrays: true,
62
+ },
63
+ },
46
64
  {
47
65
  $unwind: {
48
66
  path: '$primaryIssue.reasons', preserveNullAndEmptyArrays: true,
49
67
  },
50
68
  },
69
+ {
70
+ $unwind: {
71
+ path: '$primaryIssue.reasons.secondaryIssue', preserveNullAndEmptyArrays: true,
72
+ },
73
+ },
51
74
  {
52
75
  $project: {
53
76
  storeId: 1,
@@ -57,10 +80,12 @@ export async function storeTicketList( req, res ) {
57
80
  ticketId: 1,
58
81
  issueStatus: 1,
59
82
  ticketType: 1,
60
- comments: 1,
83
+ comments: { $size: '$comments' },
61
84
  issueDate: 1,
85
+ commentText: '$primaryIssue.comment',
62
86
  primaryIssue: '$primaryIssue.reasons.primaryIssue',
63
- secondaryIssue: '$primaryIssue.reasons.secondaryIssue',
87
+ secondaryIssue: '$primaryIssue.reasons.secondaryIssue.name',
88
+ otherscomment: '$otherscomment.comment',
64
89
  },
65
90
  },
66
91
  {
@@ -75,8 +100,11 @@ export async function storeTicketList( req, res ) {
75
100
  issueStatus: { $first: '$issueStatus' },
76
101
  ticketType: { $first: '$ticketType' },
77
102
  comments: { $first: '$comments' },
103
+ commentText: { $last: '$commentText' },
78
104
  primaryIssue: { $last: '$primaryIssue' },
79
105
  secondaryIssue: { $last: '$secondaryIssue' },
106
+ otherscomment: { $last: '$otherscomment' },
107
+
80
108
  },
81
109
  },
82
110
  {
@@ -102,8 +130,10 @@ export async function storeTicketList( req, res ) {
102
130
  'TICKET ID': element.ticketId,
103
131
  'DATE': element.Date,
104
132
  'ISSUE CLOSED DATE': element.issueClosedDate,
105
- 'ISSUE': element.primaryIssue,
133
+ 'PRIMARY ISSUE': element.primaryIssue,
134
+ 'SECONDARY ISSUE': element.secondaryIssue,
106
135
  'STATUS': element.status,
136
+ 'COMMENT': element.otherscomment?element.otherscomment:element.commentText,
107
137
  } );
108
138
  } );
109
139
  await download( exportdata, res );
@@ -337,7 +367,7 @@ export async function edgeAppLogTable( req, res ) {
337
367
  const average = sum / streamwiseDowntime.length;
338
368
  obj.downtime = Math.round( average );
339
369
  } else {
340
- obj.downtime = '';
370
+ obj.downtime ='';
341
371
  }
342
372
  let appStatusQuery = {
343
373
  'size': 1,
@@ -803,7 +833,7 @@ export async function cameraAngleChange( req, res ) {
803
833
  let changeDetected = result.camera_info.filter( ( cam ) => cam.stream == req.body.StreamName );
804
834
  if ( changeDetected.length == 1 ) {
805
835
  let params = {
806
- Bucket: 'tango-client-sandbox',
836
+ Bucket: appConfig.cloud.aws.bucket.cameraAngle,
807
837
  file_path: changeDetected[0].path,
808
838
  };
809
839
  let Image = await signedUrl( params );
@@ -71,6 +71,26 @@ export async function userTakeTicket( req, res ) {
71
71
  }
72
72
  userTicket = await findOneTangoTicket( query );
73
73
  }
74
+ } else if ( req.body.issueType == 'mat' ) {
75
+ let query = {
76
+ 'status': { $ne: 'closed' },
77
+ 'issueType': 'mat',
78
+ 'ticketDetails.addressingUser': { $exists: false },
79
+ };
80
+ if ( assignedClients.length > 0 ) {
81
+ query =( { ...query, ...{ 'basicDetails.clientId': { $in: assignedClients } } } );
82
+ }
83
+ userTicket = await findOneTangoTicket( query );
84
+ } else if ( req.body.issueType == 'dataMismatch' ) {
85
+ let query = {
86
+ 'status': { $ne: 'closed' },
87
+ 'issueType': { $in: [ 'highcount', 'lowcount' ] },
88
+ 'ticketDetails.addressingUser': { $exists: false },
89
+ };
90
+ if ( assignedClients.length > 0 ) {
91
+ query =( { ...query, ...{ 'basicDetails.clientId': { $in: assignedClients } } } );
92
+ }
93
+ userTicket = await findOneTangoTicket( query );
74
94
  }
75
95
  if ( userTicket ) {
76
96
  let assignTicket = await updateOneTangoTicket( { ticketId: userTicket.ticketId }, { 'ticketDetails.addressingUser': req.body.userId } );
@@ -88,15 +108,28 @@ export async function userTakeTicket( req, res ) {
88
108
  export async function userTicketList( req, res ) {
89
109
  try {
90
110
  let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
91
- let query = [ {
92
- $match: {
93
- $and: [
94
-
95
- { issueType: req.body.issueType },
96
- { 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ) },
97
- ],
98
- },
99
- } ];
111
+ let query = [];
112
+ if ( req.body.issueType!='dataMismatch' ) {
113
+ query.push( {
114
+ $match: {
115
+ $and: [
116
+ { 'basicDetails.clientId': { $in: req.body.clientId } },
117
+ { issueType: req.body.issueType },
118
+ { 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ) },
119
+ ],
120
+ },
121
+ } );
122
+ } else {
123
+ query.push( {
124
+ $match: {
125
+ $and: [
126
+ { 'basicDetails.clientId': { $in: req.body.clientId } },
127
+ { issueType: { $in: [ 'highcount', 'lowcount' ] } },
128
+ { 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ) },
129
+ ],
130
+ },
131
+ } );
132
+ }
100
133
  if ( req.body.status != 'closed' || req.body.export ) {
101
134
  query.push( {
102
135
  $match: {
@@ -123,6 +156,7 @@ export async function userTicketList( req, res ) {
123
156
  query.push( {
124
157
  $project: {
125
158
  storeId: '$basicDetails.storeId',
159
+ storeName: '$basicDetails.storeName',
126
160
  Date: { $dateToString: { format: '%d-%m-%Y', date: '$issueDate' } },
127
161
  updatedAt: 1,
128
162
  ticketId: 1,
@@ -153,6 +187,7 @@ export async function userTicketList( req, res ) {
153
187
  {
154
188
  $project: {
155
189
  storeId: 1,
190
+ storeName: 1,
156
191
  updatedAt: 1,
157
192
  Date: 1,
158
193
  ticketId: 1,
@@ -168,6 +203,7 @@ export async function userTicketList( req, res ) {
168
203
  $group: {
169
204
  _id: '$ticketId',
170
205
  storeId: { $first: '$storeId' },
206
+ storeName: { $first: '$storeName' },
171
207
  updatedAt: { $first: '$updatedAt' },
172
208
  Date: { $first: '$Date' },
173
209
  ticketId: { $first: '$ticketId' },
@@ -187,6 +223,7 @@ export async function userTicketList( req, res ) {
187
223
  $or: [
188
224
  { storeId: { $regex: req.body.searchValue, $options: 'i' } },
189
225
  { infraIssue: { $regex: req.body.searchValue, $options: 'i' } },
226
+ { storeName: { $regex: req.body.searchValue, $options: 'i' } },
190
227
  ],
191
228
  },
192
229
  } );
@@ -294,16 +331,30 @@ export async function basicDetails( req, res ) {
294
331
  export async function workHistory( req, res ) {
295
332
  try {
296
333
  let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
297
- let query = [ {
298
- $match: {
299
- $and: [
300
- { 'status': 'closed' },
301
- { issueType: req.body.issueType },
302
- { 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ) },
303
- ],
304
- },
305
- } ];
306
-
334
+ let query = [ ];
335
+ if ( req.body.issueType!='dataMismatch' ) {
336
+ query.push( {
337
+ $match: {
338
+ $and: [
339
+ { 'basicDetails.clientId': { $in: req.body.clientId } },
340
+ { 'status': 'closed' },
341
+ { issueType: req.body.issueType },
342
+ { 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ) },
343
+ ],
344
+ },
345
+ } );
346
+ } else {
347
+ query.push( {
348
+ $match: {
349
+ $and: [
350
+ { 'basicDetails.clientId': { $in: req.body.clientId } },
351
+ { 'status': 'closed' },
352
+ { issueType: { $in: [ 'highcount', 'lowcount' ] } },
353
+ { 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ) },
354
+ ],
355
+ },
356
+ } );
357
+ }
307
358
  if ( req.body.dateFilter && req.body.dateFilter != '' ) {
308
359
  if ( req.body.dateFilter === 'issueIdentifiedDate' ) {
309
360
  query.push(
@@ -364,6 +415,7 @@ export async function workHistory( req, res ) {
364
415
  issueClosedDate: { $dateToString: { format: '%Y-%m-%d', date: '$issueClosedDate' } },
365
416
  issueIdentifiedDate: { $dateToString: { format: '%Y-%m-%d', date: '$ticketDetails.issueIdentifiedDate' } },
366
417
  ticketId: 1,
418
+ status: 1,
367
419
  issueStatus: '$ticketDetails.issueStatus',
368
420
  ticketType: '$ticketDetails.ticketType',
369
421
  primaryIssue: {
@@ -395,6 +447,7 @@ export async function workHistory( req, res ) {
395
447
  issueClosedDate: 1,
396
448
  ticketId: 1,
397
449
  issueStatus: 1,
450
+ status: 1,
398
451
  ticketType: 1,
399
452
  infraIssue: { $ifNull: [ '$primaryIssue.reasons.primaryIssue', '' ] },
400
453
  },
@@ -437,15 +490,15 @@ export async function workHistory( req, res ) {
437
490
  const exportdata = [];
438
491
  result.forEach( ( element ) => {
439
492
  exportdata.push( {
440
- 'CREATED ON': element.createdAt,
493
+ 'CREATED ON': dayjs( element.issueDate ).format( 'DD-MM-YYYY' ),
441
494
  'TICKET ID': element.ticketId,
442
495
  'STORE ID': element.storeId,
443
496
  'STORE NAME': element.storeName,
444
497
  'CLIENT ID': element.clientId,
445
498
  'CLIENT NAME': element.clientName,
446
- 'CREATED STATUS': element.status,
447
499
  'ISSUE IDENTIFIED DATE': element.issueIdentifiedDate,
448
500
  'CLOSED ON': element.issueClosedDate,
501
+ 'ISSUE': element.infraIssue?element.infraIssue:'-',
449
502
  'STATUS': element.status,
450
503
  } );
451
504
  } );
@@ -591,7 +644,7 @@ export async function storeInfraList( req, res ) {
591
644
  if ( installationcheck ) {
592
645
  store.ticketId = installationcheck.ticketId;
593
646
  store.status = installationcheck.ticketDetails.installationStatus;
594
- if ( store.status === 'onboareded' ) {
647
+ if ( store.status === 'onboarded' ) {
595
648
  store.statusDetail = 'Ready to pair';
596
649
  }
597
650
  if ( store.status === 'paired' ) {
@@ -0,0 +1,10 @@
1
+ import express from 'express';
2
+ import { isAllowedSessionHandler, authorize } from 'tango-app-api-middleware';
3
+ import { createTicket } from '../controllers/dataMismatch.controller.js';
4
+ import { validateDetails } from '../validations/infra.validation.js';
5
+ export const dataMismatchTicketRouter = express.Router();
6
+
7
+ dataMismatchTicketRouter.post( '/createTicket', isAllowedSessionHandler, authorize( {
8
+ userType: [ 'client', 'tango' ], access: [
9
+ { featureName: 'manage', name: 'tickets', permissions: [ 'isView', 'isEdit' ] } ],
10
+ } ), validateDetails, createTicket );
@@ -0,0 +1,17 @@
1
+ import { createTicket, updatecomment, activityLog } from '../controllers/employeeTraning.controller.js';
2
+ import { ticketExists, validateDetails } from '../validations/infra.validation.js';
3
+ import express from 'express';
4
+ import { isAllowedSessionHandler, authorize } from 'tango-app-api-middleware';
5
+ export const employeeTrainigRouter = express.Router();
6
+
7
+
8
+ employeeTrainigRouter.post( '/createTicket', validateDetails, createTicket );
9
+ employeeTrainigRouter.post( '/updatecomment', isAllowedSessionHandler, authorize( {
10
+ userType: [ 'tango' ], access: [
11
+ { featureName: 'manage', name: 'tickets', permissions: [ 'isEdit' ] } ],
12
+ } ), ticketExists, updatecomment );
13
+
14
+ employeeTrainigRouter.post( '/activityLog', isAllowedSessionHandler, authorize( {
15
+ userType: [ 'tango' ], access: [
16
+ { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
17
+ } ), ticketExists, activityLog );
@@ -1,11 +1,10 @@
1
1
 
2
2
  import express from 'express';
3
3
  import { isAllowedSessionHandler, authorize, validate } from 'tango-app-api-middleware';
4
- import { validateDetails, bulkvalidateDetails, validateTicket, bulkvalidateTicket, ticketExists, infraReasonExists, InfrastepstoResolve, InfraAlert } from '../validations/infra.validation.js';
5
- import { createTicket, bulkcreateTicket, updateStatus, createReason, PrimaryReasons,
6
- secondaryReason, updateTicketIssue, viewTicket, AlertTicketReply, uploadAttachments,
7
- updateInstallationTicket, emailUserList, saveInfraEmailConfig, invoice,
8
- getInfraIssues } from '../controllers/infra.controllers.js';
4
+ import { validateDetails, bulkvalidateDetails, validateTicket, bulkvalidateTicket, validateTicketstatus, ticketExists, infraReasonExists, InfrastepstoResolve, InfraAlert } from '../validations/infra.validation.js';
5
+ import { createTicket, bulkcreateTicket, updateStatus, createReason, PrimaryReasons, matTable,
6
+ secondaryReason, updateTicketIssue, viewTicket, AlertTicketReply, uploadAttachments, getInfraIssues,
7
+ updateInstallationTicket, emailUserList, saveInfraEmailConfig, invoice, infraTable, storeFilter, assignTicket, installationTable } from '../controllers/infra.controllers.js';
9
8
  import { getInfraIssueValid } from '../dtos/infra.dtos.js';
10
9
 
11
10
 
@@ -31,7 +30,7 @@ infraRouter.post( '/secondaryReason', isAllowedSessionHandler, authorize( {
31
30
  infraRouter.post( '/updateTicketIssue', isAllowedSessionHandler, authorize( {
32
31
  userType: [ 'client', 'tango' ], access: [
33
32
  { featureName: 'manage', name: 'tickets', permissions: [ 'isEdit' ] } ],
34
- } ), ticketExists, infraReasonExists, InfrastepstoResolve, InfraAlert, updateTicketIssue );
33
+ } ), ticketExists, validateTicketstatus, infraReasonExists, InfrastepstoResolve, InfraAlert, updateTicketIssue );
35
34
  infraRouter.post( '/viewTicket', isAllowedSessionHandler, authorize( {
36
35
  userType: [ 'client', 'tango' ], access: [
37
36
  { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
@@ -57,4 +56,27 @@ infraRouter.post( '/saveInfraEmailConfig', isAllowedSessionHandler, authorize( {
57
56
  { featureName: 'settings', name: 'configuration', permissions: [ 'isEdit', 'isView' ] } ],
58
57
  } ), saveInfraEmailConfig );
59
58
  infraRouter.post( '/invoice', invoice );
60
- infraRouter.post( '/get-infra-issues', validate( getInfraIssueValid ), getInfraIssues );
59
+ infraRouter.post( '/infraTable', isAllowedSessionHandler, authorize( {
60
+ userType: [ 'client', 'tango' ], access: [
61
+ { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
62
+ } ), infraTable );
63
+ infraRouter.post( '/installationTable', isAllowedSessionHandler, authorize( {
64
+ userType: [ 'client', 'tango' ], access: [
65
+ { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
66
+ } ), installationTable );
67
+ infraRouter.post( '/matTable', isAllowedSessionHandler, authorize( {
68
+ userType: [ 'client', 'tango' ], access: [
69
+ { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
70
+ } ), matTable );
71
+ infraRouter.post( '/assignTicket', isAllowedSessionHandler, authorize( {
72
+ userType: [ 'client', 'tango' ], access: [
73
+ { featureName: 'manage', name: 'tickets', permissions: [ 'isEdit', 'isView' ] } ],
74
+ } ), assignTicket );
75
+ infraRouter.post( '/storeFilter', isAllowedSessionHandler, authorize( {
76
+ userType: [ 'client', 'tango' ], access: [
77
+ { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
78
+ } ), storeFilter );
79
+ infraRouter.post( '/get-infra-issues', isAllowedSessionHandler, authorize( {
80
+ userType: [ 'client', 'tango' ], access: [
81
+ { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
82
+ } ), validate( getInfraIssueValid ), getInfraIssues );
@@ -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, edgeApplogsCheck, camAngleChangeReport, spocmailchange, emailUserList, infraReportSent,
6
6
  } from '../controllers/internalInfra.controller.js';
7
7
 
8
8
  export const internalInfraRouter = express.Router();
@@ -19,5 +19,8 @@ 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 );
23
+ internalInfraRouter.post( '/camAngleChangeReport', camAngleChangeReport );
24
+ internalInfraRouter.post( '/edgeApplogsCheck', edgeApplogsCheck );
22
25
 
23
26
 
@@ -13,6 +13,9 @@ export async function findOneTangoTicket( query, project ) {
13
13
  export async function updateOneTangoTicket( query, data ) {
14
14
  return await dataModel.tangoTicketModel.updateOne( query, { $set: data } );
15
15
  }
16
+ export async function updateManyTangoTicket( query, data ) {
17
+ return await dataModel.tangoTicketModel.updateMany( query, { $set: data } );
18
+ }
16
19
  export async function countDocumentsTangoTicket( query, data ) {
17
20
  return await dataModel.tangoTicketModel.countDocuments( query );
18
21
  }
@@ -28,17 +28,20 @@ export async function validateDetails( req, res, next ) {
28
28
  clientId: store.clientId,
29
29
  clientName: client.clientName,
30
30
  };
31
-
31
+ req.body.emailAlert = client.ticketConfigs.emailAlert;
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' } );
@@ -59,12 +62,13 @@ export async function validateTicket( req, res, next ) {
59
62
  if ( Ticket ) {
60
63
  return res.sendSuccess( 'Infra Ticket Already Exists for the day' );
61
64
  }
65
+
62
66
  let refreshTicket = await findOneTangoTicket(
63
67
  {
64
68
  'basicDetails.storeId': req.body.basicDetails.storeId,
65
69
  'issueType': 'infra',
66
70
  'status': { $ne: 'closed' },
67
- 'ticketDetails.ticketType': 'refreshticket',
71
+ 'ticketDetails.ticketRefreshTime': { $lte: new Date() },
68
72
  },
69
73
  );
70
74
  if ( refreshTicket ) {
@@ -180,12 +184,45 @@ export async function ticketExists( req, res, next ) {
180
184
  req.body.basicDetails = Ticket.basicDetails;
181
185
  req.body.ticketDetails = Ticket.ticketDetails;
182
186
  req.body.ticketActivity = Ticket.ticketActivity;
187
+ req.body.status = Ticket.status;
188
+ req.body.issueDate = Ticket.issueDate;
189
+
190
+
183
191
  next();
184
192
  } catch ( error ) {
185
193
  logger.error( { error: error, function: 'ticketExists' } );
186
194
  return res.sendError( error, 500 );
187
195
  }
188
196
  };
197
+
198
+ export async function validateTicketstatus( req, res, next ) {
199
+ try {
200
+ if ( req.body.issueType == 'infra' ) {
201
+ if ( req.body.secondary.length>0 ) {
202
+ if ( req.body.status == 'closed' ) {
203
+ return res.sendSuccess( 'Ticket already closed' );
204
+ }
205
+ if ( req.body.ticketDetails.ticketType==='firsttimeticket'&&req.body.ticketDetails.issueStatus==='identified' ) {
206
+ return res.sendSuccess( 'Ticket already Addressed' );
207
+ }
208
+ } else {
209
+ if ( req.body.primary == 'Application Issues' ) {
210
+ if ( req.body.status == 'closed' ) {
211
+ return res.sendSuccess( 'Ticket already closed' );
212
+ }
213
+ if ( req.body.ticketDetails.ticketType==='firsttimeticket'&&req.body.ticketDetails.issueStatus==='identified' ) {
214
+ return res.sendSuccess( 'Ticket already Addressed' );
215
+ }
216
+ }
217
+ }
218
+ }
219
+ next();
220
+ } catch ( error ) {
221
+ logger.error( { error: error, function: 'validateTicket' } );
222
+ return res.sendError( error, 500 );
223
+ }
224
+ }
225
+
189
226
  export async function infraReasonExists( req, res, next ) {
190
227
  try {
191
228
  if ( req.body.primary && req.body.secondary && req.body.secondary.length ) {
@@ -302,15 +339,24 @@ export async function InfrastepstoResolve( req, res, next ) {
302
339
  export async function InfraAlert( req, res, next ) {
303
340
  try {
304
341
  if ( req.body.hibernationDays ) {
305
- req.body.hibernationDays = dayjs().add( req.body.hibernationDays, 'days' ).format( 'YYYY-MM-DD' );
306
- await updateOneStore( { storeId: req.body.basicDetails.storeId }, { 'ticketConfigs.hibernation': new Date( req.body.hibernationDays ) } );
342
+ let actionBy = '';
343
+ if ( req.user.userType == 'tango' ) {
344
+ actionBy = 'Tango';
345
+ } else if ( req.user.userType == 'client' ) {
346
+ actionBy = 'User';
347
+ }
348
+
307
349
  req.body.ticketActivity.push( {
308
350
  actionType: 'statusCheckReply',
309
- actionBy: 'User',
351
+ actionBy: actionBy,
310
352
  timeStamp: new Date(),
353
+ statusCheckReply: 'No',
311
354
  IdentifiedBy: req.user.userName,
312
355
  hibernationDays: req.body.hibernationDays,
313
356
  } );
357
+ req.body.hibernationDays = dayjs().add( req.body.hibernationDays, 'days' ).format( 'YYYY-MM-DD' );
358
+ await updateOneStore( { storeId: req.body.basicDetails.storeId }, { 'ticketConfigs.hibernation': new Date( req.body.hibernationDays ) } );
359
+
314
360
  await updateOneTangoTicket( { ticketId: req.body.ticketId }, { 'hibernation': new Date( req.body.hibernationDays ) } );
315
361
  } else {
316
362
  if ( req.body.issueType == 'infra' ) {