Built motion from commit (unavailable).|2.5.25
[motion2.git] / server / api / chatProactiveAction / chatProactiveAction.controller.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x96f7=['api','../../config/utils','../../config/environment','status','json','count','offset','limit','set','apply','reject','update','destroy','sendStatus','error','stack','name','send','params','model','ChatProactiveAction','rawAttributes','query','keys','intersection','attributes','fields','includeAll','include','options','find','then','catch','create','body','html-pdf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','ejs','lodash','squel','crypto','jsforce','desk.js','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware'];(function(_0x3bbde7,_0x344127){var _0x117992=function(_0x1d0170){while(--_0x1d0170){_0x3bbde7['push'](_0x3bbde7['shift']());}};_0x117992(++_0x344127);}(_0x96f7,0x91));var _0x796f=function(_0x182b41,_0x3710ca){_0x182b41=_0x182b41-0x0;var _0x39e4dc=_0x96f7[_0x182b41];return _0x39e4dc;};'use strict';var pdf=require(_0x796f('0x0'));var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x796f('0x1'));var jsonpatch=require(_0x796f('0x2'));var rp=require(_0x796f('0x3'));var moment=require('moment');var BPromise=require(_0x796f('0x4'));var Mustache=require(_0x796f('0x5'));var util=require(_0x796f('0x6'));var path=require(_0x796f('0x7'));var sox=require(_0x796f('0x8'));var csv=require('to-csv');var ejs=require(_0x796f('0x9'));var fs=require('fs');var _=require(_0x796f('0xa'));var squel=require(_0x796f('0xb'));var crypto=require(_0x796f('0xc'));var jsforce=require(_0x796f('0xd'));var deskjs=require(_0x796f('0xe'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x796f('0xf'));var Redis=require('ioredis');var authService=require(_0x796f('0x10'));var qs=require(_0x796f('0x11'));var as=require(_0x796f('0x12'));var hardwareService=require(_0x796f('0x13'));var logger=require('../../config/logger')(_0x796f('0x14'));var utils=require(_0x796f('0x15'));var config=require(_0x796f('0x16'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x45834d,_0x12c577){_0x12c577=_0x12c577||0xcc;return function(_0xf79746){if(_0xf79746){return _0x45834d['sendStatus'](_0x12c577);}return _0x45834d[_0x796f('0x17')](_0x12c577)['end']();};}function respondWithResult(_0x5e0856,_0x654b8d){_0x654b8d=_0x654b8d||0xc8;return function(_0x4c5fe1){if(_0x4c5fe1){return _0x5e0856[_0x796f('0x17')](_0x654b8d)[_0x796f('0x18')](_0x4c5fe1);}};}function respondWithFilteredResult(_0x446594,_0x1c9df7){return function(_0x1e4cbc){if(_0x1e4cbc){var _0x438001=_0x1e4cbc[_0x796f('0x19')],_0x13417d=_0x1c9df7[_0x796f('0x1a')],_0x4630e7=_0x1c9df7[_0x796f('0x1a')]+_0x1c9df7[_0x796f('0x1b')],_0x40f2e5;if(_0x4630e7>=_0x438001){_0x4630e7=_0x438001;_0x40f2e5=0xc8;}else{_0x40f2e5=0xce;}_0x446594['status'](_0x40f2e5);return _0x446594[_0x796f('0x1c')]('Content-Range',_0x13417d+'-'+_0x4630e7+'/'+_0x438001)[_0x796f('0x18')](_0x1e4cbc);}return null;};}function patchUpdates(_0x2ae9d0){return function(_0xb2399){try{jsonpatch[_0x796f('0x1d')](_0xb2399,_0x2ae9d0,!![]);}catch(_0x4d14e2){return BPromise[_0x796f('0x1e')](_0x4d14e2);}return _0xb2399['save']();};}function saveUpdates(_0x2bd881,_0x133e32){return function(_0xa2f35){if(_0xa2f35){return _0xa2f35[_0x796f('0x1f')](_0x2bd881)['then'](function(_0x2913d7){return _0x2913d7;});}return null;};}function removeEntity(_0x4f94fc,_0x57393b){return function(_0x470d84){if(_0x470d84){return _0x470d84[_0x796f('0x20')]()['then'](function(){_0x4f94fc['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x3c2c47,_0x3a2442){return function(_0x193298){if(!_0x193298){_0x3c2c47[_0x796f('0x21')](0x194);}return _0x193298;};}function handleError(_0x8643e8,_0x57dd01){_0x57dd01=_0x57dd01||0x1f4;return function(_0x20248a){logger[_0x796f('0x22')](_0x20248a[_0x796f('0x23')]);if(_0x20248a[_0x796f('0x24')]){delete _0x20248a[_0x796f('0x24')];}_0x8643e8['status'](_0x57dd01)[_0x796f('0x25')](_0x20248a);};}exports['show']=function(_0x22be57,_0x52958c){var _0x410e17={'raw':!![],'where':{'id':_0x22be57[_0x796f('0x26')]['id']}},_0x571a77={};_0x571a77[_0x796f('0x27')]=_['keys'](db[_0x796f('0x28')][_0x796f('0x29')]);_0x571a77[_0x796f('0x2a')]=_[_0x796f('0x2b')](_0x22be57[_0x796f('0x2a')]);_0x571a77['filters']=_[_0x796f('0x2c')](_0x571a77[_0x796f('0x27')],_0x571a77[_0x796f('0x2a')]);_0x410e17[_0x796f('0x2d')]=_[_0x796f('0x2c')](_0x571a77[_0x796f('0x27')],qs[_0x796f('0x2e')](_0x22be57['query'][_0x796f('0x2e')]));_0x410e17[_0x796f('0x2d')]=_0x410e17[_0x796f('0x2d')]['length']?_0x410e17[_0x796f('0x2d')]:_0x571a77[_0x796f('0x27')];if(_0x22be57[_0x796f('0x2a')][_0x796f('0x2f')]){_0x410e17[_0x796f('0x30')]=[{'all':!![]}];}_0x410e17=_['merge']({},_0x410e17,_0x22be57[_0x796f('0x31')]);return db['ChatProactiveAction'][_0x796f('0x32')](_0x410e17)['then'](handleEntityNotFound(_0x52958c,null))[_0x796f('0x33')](respondWithResult(_0x52958c,null))[_0x796f('0x34')](handleError(_0x52958c,null));};exports[_0x796f('0x35')]=function(_0x4ade3e,_0x2188f6){return db[_0x796f('0x28')][_0x796f('0x35')](_0x4ade3e[_0x796f('0x36')],{})[_0x796f('0x33')](respondWithResult(_0x2188f6,0xc9))[_0x796f('0x34')](handleError(_0x2188f6,null));};exports[_0x796f('0x1f')]=function(_0x1a1efd,_0x33a30f){if(_0x1a1efd[_0x796f('0x36')]['id']){delete _0x1a1efd[_0x796f('0x36')]['id'];}return db[_0x796f('0x28')]['find']({'where':{'id':_0x1a1efd[_0x796f('0x26')]['id']}})[_0x796f('0x33')](handleEntityNotFound(_0x33a30f,null))['then'](saveUpdates(_0x1a1efd[_0x796f('0x36')],null))[_0x796f('0x33')](respondWithResult(_0x33a30f,null))['catch'](handleError(_0x33a30f,null));};exports['destroy']=function(_0x2b5441,_0x563c35){return db[_0x796f('0x28')][_0x796f('0x32')]({'where':{'id':_0x2b5441[_0x796f('0x26')]['id']}})[_0x796f('0x33')](handleEntityNotFound(_0x563c35,null))[_0x796f('0x33')](removeEntity(_0x563c35,null))['catch'](handleError(_0x563c35,null));};