Built motion from commit (unavailable).|2.3.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 _0x0a09=['set','Content-Range','apply','reject','then','destroy','error','stack','name','show','params','keys','rawAttributes','query','filters','attributes','intersection','model','fields','length','includeAll','include','merge','options','ChatProactiveAction','find','catch','update','body','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','util','path','to-csv','ejs','lodash','squel','desk.js','querystring','papaparse','../../components/auth/service','../../config/license/hardware','ioredis','../../components/parsers/qs','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','offset','limit'];(function(_0x44a70c,_0x549413){var _0x559765=function(_0x381c08){while(--_0x381c08){_0x44a70c['push'](_0x44a70c['shift']());}};_0x559765(++_0x549413);}(_0x0a09,0x1ed));var _0x90a0=function(_0x4e6eb2,_0x16a451){_0x4e6eb2=_0x4e6eb2-0x0;var _0x4e0c1c=_0x0a09[_0x4e6eb2];return _0x4e0c1c;};'use strict';var pdf=require(_0x90a0('0x0'));var emlformat=require(_0x90a0('0x1'));var rimraf=require(_0x90a0('0x2'));var zipdir=require(_0x90a0('0x3'));var jsonpatch=require(_0x90a0('0x4'));var rp=require(_0x90a0('0x5'));var moment=require('moment');var BPromise=require(_0x90a0('0x6'));var Mustache=require('mustache');var util=require(_0x90a0('0x7'));var path=require(_0x90a0('0x8'));var sox=require('sox');var csv=require(_0x90a0('0x9'));var ejs=require(_0x90a0('0xa'));var fs=require('fs');var _=require(_0x90a0('0xb'));var squel=require(_0x90a0('0xc'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x90a0('0xd'));var toCsv=require(_0x90a0('0x9'));var querystring=require(_0x90a0('0xe'));var Papa=require(_0x90a0('0xf'));var authService=require(_0x90a0('0x10'));var hardwareService=require(_0x90a0('0x11'));var Redis=require(_0x90a0('0x12'));var qs=require(_0x90a0('0x13'));var logger=require(_0x90a0('0x14'))('api');var utils=require(_0x90a0('0x15'));var config=require(_0x90a0('0x16'));var db=require(_0x90a0('0x17'))['db'];function respondWithStatusCode(_0x51bf90,_0x80cea2){_0x80cea2=_0x80cea2||0xcc;return function(_0x455c38){if(_0x455c38){return _0x51bf90[_0x90a0('0x18')](_0x80cea2);}return _0x51bf90[_0x90a0('0x19')](_0x80cea2)[_0x90a0('0x1a')]();};}function respondWithResult(_0x1fbb08,_0x5b4741){_0x5b4741=_0x5b4741||0xc8;return function(_0xe05726){if(_0xe05726){return _0x1fbb08[_0x90a0('0x19')](_0x5b4741)['json'](_0xe05726);}};}function respondWithFilteredResult(_0xa990e5,_0x58e9a2){return function(_0x5db5dd){if(_0x5db5dd){var _0x2406f4=_0x5db5dd['count'],_0x235d19=_0x58e9a2[_0x90a0('0x1b')],_0x347666=_0x58e9a2[_0x90a0('0x1b')]+_0x58e9a2[_0x90a0('0x1c')],_0xbfff86;if(_0x347666>=_0x2406f4){_0x347666=_0x2406f4;_0xbfff86=0xc8;}else{_0xbfff86=0xce;}_0xa990e5['status'](_0xbfff86);return _0xa990e5[_0x90a0('0x1d')](_0x90a0('0x1e'),_0x235d19+'-'+_0x347666+'/'+_0x2406f4)['json'](_0x5db5dd);}return null;};}function patchUpdates(_0x1a2264){return function(_0x6f659a){try{jsonpatch[_0x90a0('0x1f')](_0x6f659a,_0x1a2264,!![]);}catch(_0x18125a){return BPromise[_0x90a0('0x20')](_0x18125a);}return _0x6f659a['save']();};}function saveUpdates(_0x3ffb5d,_0x2556a9){return function(_0x444581){if(_0x444581){return _0x444581['update'](_0x3ffb5d)[_0x90a0('0x21')](function(_0x20b918){return _0x20b918;});}return null;};}function removeEntity(_0x35462a,_0xc664e1){return function(_0x16d0bc){if(_0x16d0bc){return _0x16d0bc[_0x90a0('0x22')]()[_0x90a0('0x21')](function(){_0x35462a['status'](0xcc)[_0x90a0('0x1a')]();});}};}function handleEntityNotFound(_0xaff968,_0x68e765){return function(_0x3106eb){if(!_0x3106eb){_0xaff968[_0x90a0('0x18')](0x194);}return _0x3106eb;};}function handleError(_0x1ca192,_0x3b79ee){_0x3b79ee=_0x3b79ee||0x1f4;return function(_0x4e10c5){logger[_0x90a0('0x23')](_0x4e10c5[_0x90a0('0x24')]);if(_0x4e10c5[_0x90a0('0x25')]){delete _0x4e10c5[_0x90a0('0x25')];}_0x1ca192[_0x90a0('0x19')](_0x3b79ee)['send'](_0x4e10c5);};}exports[_0x90a0('0x26')]=function(_0x2d2d66,_0x56b563){var _0x6d57b8={'raw':!![],'where':{'id':_0x2d2d66[_0x90a0('0x27')]['id']}},_0x208763={};_0x208763['model']=_[_0x90a0('0x28')](db['ChatProactiveAction'][_0x90a0('0x29')]);_0x208763[_0x90a0('0x2a')]=_[_0x90a0('0x28')](_0x2d2d66['query']);_0x208763[_0x90a0('0x2b')]=_['intersection'](_0x208763['model'],_0x208763[_0x90a0('0x2a')]);_0x6d57b8[_0x90a0('0x2c')]=_[_0x90a0('0x2d')](_0x208763[_0x90a0('0x2e')],qs[_0x90a0('0x2f')](_0x2d2d66[_0x90a0('0x2a')][_0x90a0('0x2f')]));_0x6d57b8[_0x90a0('0x2c')]=_0x6d57b8['attributes'][_0x90a0('0x30')]?_0x6d57b8[_0x90a0('0x2c')]:_0x208763[_0x90a0('0x2e')];if(_0x2d2d66['query'][_0x90a0('0x31')]){_0x6d57b8[_0x90a0('0x32')]=[{'all':!![]}];}_0x6d57b8=_[_0x90a0('0x33')]({},_0x6d57b8,_0x2d2d66[_0x90a0('0x34')]);return db[_0x90a0('0x35')][_0x90a0('0x36')](_0x6d57b8)[_0x90a0('0x21')](handleEntityNotFound(_0x56b563,null))[_0x90a0('0x21')](respondWithResult(_0x56b563,null))[_0x90a0('0x37')](handleError(_0x56b563,null));};exports['create']=function(_0x45735e,_0x463c74){return db[_0x90a0('0x35')]['create'](_0x45735e['body'],{})[_0x90a0('0x21')](respondWithResult(_0x463c74,0xc9))[_0x90a0('0x37')](handleError(_0x463c74,null));};exports[_0x90a0('0x38')]=function(_0x3a74e0,_0x412461){if(_0x3a74e0[_0x90a0('0x39')]['id']){delete _0x3a74e0[_0x90a0('0x39')]['id'];}return db['ChatProactiveAction'][_0x90a0('0x36')]({'where':{'id':_0x3a74e0[_0x90a0('0x27')]['id']}})[_0x90a0('0x21')](handleEntityNotFound(_0x412461,null))[_0x90a0('0x21')](saveUpdates(_0x3a74e0['body'],null))[_0x90a0('0x21')](respondWithResult(_0x412461,null))['catch'](handleError(_0x412461,null));};exports['destroy']=function(_0xf835ab,_0x454d3c){return db[_0x90a0('0x35')]['find']({'where':{'id':_0xf835ab[_0x90a0('0x27')]['id']}})['then'](handleEntityNotFound(_0x454d3c,null))[_0x90a0('0x21')](removeEntity(_0x454d3c,null))[_0x90a0('0x37')](handleError(_0x454d3c,null));};