Built motion from commit (unavailable).|2.5.1
[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 _0x0f25=['../../config/license/util','../../mysqldb','sendStatus','end','status','json','count','offset','set','Content-Range','apply','reject','save','update','then','stack','name','send','show','model','keys','ChatProactiveAction','query','filters','attributes','intersection','fields','length','include','merge','options','find','create','body','catch','params','eml-format','rimraf','fast-json-patch','moment','mustache','util','path','lodash','squel','crypto','desk.js','to-csv','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment'];(function(_0x2226f8,_0x350f4c){var _0x151cfe=function(_0x3001d9){while(--_0x3001d9){_0x2226f8['push'](_0x2226f8['shift']());}};_0x151cfe(++_0x350f4c);}(_0x0f25,0x1dc));var _0x50f2=function(_0x4769f8,_0x55854a){_0x4769f8=_0x4769f8-0x0;var _0xdc249c=_0x0f25[_0x4769f8];return _0xdc249c;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x50f2('0x0'));var rimraf=require(_0x50f2('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x50f2('0x2'));var rp=require('request-promise');var moment=require(_0x50f2('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x50f2('0x4'));var util=require(_0x50f2('0x5'));var path=require(_0x50f2('0x6'));var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0x50f2('0x7'));var squel=require(_0x50f2('0x8'));var crypto=require(_0x50f2('0x9'));var jsforce=require('jsforce');var deskjs=require(_0x50f2('0xa'));var toCsv=require(_0x50f2('0xb'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x50f2('0xc'));var authService=require('../../components/auth/service');var qs=require(_0x50f2('0xd'));var as=require(_0x50f2('0xe'));var hardwareService=require(_0x50f2('0xf'));var logger=require(_0x50f2('0x10'))('api');var utils=require(_0x50f2('0x11'));var config=require(_0x50f2('0x12'));var licenseUtil=require(_0x50f2('0x13'));var db=require(_0x50f2('0x14'))['db'];function respondWithStatusCode(_0x541097,_0x2c96d9){_0x2c96d9=_0x2c96d9||0xcc;return function(_0x4a3fb4){if(_0x4a3fb4){return _0x541097[_0x50f2('0x15')](_0x2c96d9);}return _0x541097['status'](_0x2c96d9)[_0x50f2('0x16')]();};}function respondWithResult(_0x5da9b6,_0x473b82){_0x473b82=_0x473b82||0xc8;return function(_0x3cc610){if(_0x3cc610){return _0x5da9b6[_0x50f2('0x17')](_0x473b82)[_0x50f2('0x18')](_0x3cc610);}};}function respondWithFilteredResult(_0x161a8a,_0x35d4e5){return function(_0x435cc3){if(_0x435cc3){var _0x29932e=_0x435cc3[_0x50f2('0x19')],_0x351eca=_0x35d4e5[_0x50f2('0x1a')],_0x5103eb=_0x35d4e5['offset']+_0x35d4e5['limit'],_0x28eea5;if(_0x5103eb>=_0x29932e){_0x5103eb=_0x29932e;_0x28eea5=0xc8;}else{_0x28eea5=0xce;}_0x161a8a[_0x50f2('0x17')](_0x28eea5);return _0x161a8a[_0x50f2('0x1b')](_0x50f2('0x1c'),_0x351eca+'-'+_0x5103eb+'/'+_0x29932e)['json'](_0x435cc3);}return null;};}function patchUpdates(_0x3048f9){return function(_0xadcd79){try{jsonpatch[_0x50f2('0x1d')](_0xadcd79,_0x3048f9,!![]);}catch(_0x34ecbc){return BPromise[_0x50f2('0x1e')](_0x34ecbc);}return _0xadcd79[_0x50f2('0x1f')]();};}function saveUpdates(_0x41977c,_0x1f10ec){return function(_0x5e3a70){if(_0x5e3a70){return _0x5e3a70[_0x50f2('0x20')](_0x41977c)[_0x50f2('0x21')](function(_0x525ac8){return _0x525ac8;});}return null;};}function removeEntity(_0x48485d,_0x59ae01){return function(_0x50945d){if(_0x50945d){return _0x50945d['destroy']()[_0x50f2('0x21')](function(){_0x48485d[_0x50f2('0x17')](0xcc)[_0x50f2('0x16')]();});}};}function handleEntityNotFound(_0x172d02,_0x443af4){return function(_0xf5196c){if(!_0xf5196c){_0x172d02[_0x50f2('0x15')](0x194);}return _0xf5196c;};}function handleError(_0x285f76,_0x22f14e){_0x22f14e=_0x22f14e||0x1f4;return function(_0x18b55e){logger['error'](_0x18b55e[_0x50f2('0x22')]);if(_0x18b55e['name']){delete _0x18b55e[_0x50f2('0x23')];}_0x285f76[_0x50f2('0x17')](_0x22f14e)[_0x50f2('0x24')](_0x18b55e);};}exports[_0x50f2('0x25')]=function(_0xe8496f,_0x4bc7b4){var _0x22a83f={'raw':!![],'where':{'id':_0xe8496f['params']['id']}},_0x33faa7={};_0x33faa7[_0x50f2('0x26')]=_[_0x50f2('0x27')](db[_0x50f2('0x28')]['rawAttributes']);_0x33faa7['query']=_['keys'](_0xe8496f[_0x50f2('0x29')]);_0x33faa7[_0x50f2('0x2a')]=_['intersection'](_0x33faa7[_0x50f2('0x26')],_0x33faa7[_0x50f2('0x29')]);_0x22a83f[_0x50f2('0x2b')]=_[_0x50f2('0x2c')](_0x33faa7[_0x50f2('0x26')],qs[_0x50f2('0x2d')](_0xe8496f[_0x50f2('0x29')][_0x50f2('0x2d')]));_0x22a83f[_0x50f2('0x2b')]=_0x22a83f['attributes'][_0x50f2('0x2e')]?_0x22a83f['attributes']:_0x33faa7['model'];if(_0xe8496f[_0x50f2('0x29')]['includeAll']){_0x22a83f[_0x50f2('0x2f')]=[{'all':!![]}];}_0x22a83f=_[_0x50f2('0x30')]({},_0x22a83f,_0xe8496f[_0x50f2('0x31')]);return db[_0x50f2('0x28')][_0x50f2('0x32')](_0x22a83f)['then'](handleEntityNotFound(_0x4bc7b4,null))[_0x50f2('0x21')](respondWithResult(_0x4bc7b4,null))['catch'](handleError(_0x4bc7b4,null));};exports[_0x50f2('0x33')]=function(_0x2770dd,_0xf3e79f){return db[_0x50f2('0x28')][_0x50f2('0x33')](_0x2770dd[_0x50f2('0x34')],{})[_0x50f2('0x21')](respondWithResult(_0xf3e79f,0xc9))[_0x50f2('0x35')](handleError(_0xf3e79f,null));};exports[_0x50f2('0x20')]=function(_0x59c7e2,_0x1072ab){if(_0x59c7e2['body']['id']){delete _0x59c7e2[_0x50f2('0x34')]['id'];}return db[_0x50f2('0x28')][_0x50f2('0x32')]({'where':{'id':_0x59c7e2[_0x50f2('0x36')]['id']}})[_0x50f2('0x21')](handleEntityNotFound(_0x1072ab,null))[_0x50f2('0x21')](saveUpdates(_0x59c7e2[_0x50f2('0x34')],null))['then'](respondWithResult(_0x1072ab,null))[_0x50f2('0x35')](handleError(_0x1072ab,null));};exports['destroy']=function(_0x464bec,_0x133327){return db[_0x50f2('0x28')]['find']({'where':{'id':_0x464bec[_0x50f2('0x36')]['id']}})[_0x50f2('0x21')](handleEntityNotFound(_0x133327,null))[_0x50f2('0x21')](removeEntity(_0x133327,null))[_0x50f2('0x35')](handleError(_0x133327,null));};