tango-app-api-infra 3.0.32-dev → 3.0.34-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.32-dev",
3
+ "version": "3.0.34-dev",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -23,7 +23,7 @@
23
23
  "mongodb": "^6.4.0",
24
24
  "nodemon": "^3.1.0",
25
25
  "tango-api-schema": "^2.0.66",
26
- "tango-app-api-middleware": "^1.0.51-dev",
26
+ "tango-app-api-middleware": "^1.0.52-dev",
27
27
  "winston": "^3.12.0",
28
28
  "winston-daily-rotate-file": "^5.0.0"
29
29
  },
@@ -234,7 +234,8 @@ export async function AlertTicketReply( req, res ) {
234
234
  export async function uploadAttachments( req, res ) {
235
235
  try {
236
236
  if ( req.files.img && req.files.img.length > 0 ) {
237
- let attachments = [];
237
+ let oldticket = await findOneTangoTicket( { ticketId: req.params.ticketId } );
238
+ let attachments = oldticket.attachments;
238
239
  for ( let singleImg in req.files.img ) {
239
240
  if ( req.files.img.hasOwnProperty( singleImg ) ) {
240
241
  let params = {
@@ -259,7 +260,27 @@ export async function uploadAttachments( req, res ) {
259
260
  res.sendSuccess( 'Uploaded successfully' );
260
261
  }
261
262
  } else {
262
-
263
+ let oldticket = await findOneTangoTicket( { ticketId: req.params.ticketId } );
264
+ let attachments = oldticket.attachments;
265
+ let params = {
266
+ Bucket: 'tango-client-sandbox',
267
+ Key: req.params.ticketId + '/',
268
+ ContentType: 'multipart/form-data',
269
+ body: req.files.img.data,
270
+ fileName: req.files.img.name,
271
+ };
272
+ let upload = await fileUpload( params );
273
+ if ( upload ) {
274
+ let getObject = {
275
+ fileName: req.files.img.name,
276
+ filePath: req.params.ticketId + '/' + req.files.img.name,
277
+ };
278
+ attachments.push( getObject );
279
+ }
280
+ let updateTicket = await updateOneTangoTicket( { ticketId: req.params.ticketId }, { attachments: attachments } );
281
+ if ( updateTicket ) {
282
+ res.sendSuccess( 'Uploaded successfully' );
283
+ }
263
284
  }
264
285
  } catch ( error ) {
265
286
  logger.error( { error: error, function: 'uploadAttachments' } );