Built motion from commit (unavailable).|2.5.19
[motion2.git] / server / api / chatApplication / chatApplication.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 _0x1cc5=['intersection','fields','length','includeAll','include','merge','options','find','update','body','catch','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','to-csv','ejs','lodash','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','end','json','count','offset','set','Content-Range','reject','save','then','error','stack','name','send','show','params','keys','ChatApplication','query','filters','model','attributes'];(function(_0x288884,_0x40e0b5){var _0x5c00d0=function(_0x413487){while(--_0x413487){_0x288884['push'](_0x288884['shift']());}};_0x5c00d0(++_0x40e0b5);}(_0x1cc5,0x132));var _0x51cc=function(_0x3dc55d,_0xd07e93){_0x3dc55d=_0x3dc55d-0x0;var _0x3aa7f3=_0x1cc5[_0x3dc55d];return _0x3aa7f3;};'use strict';var pdf=require(_0x51cc('0x0'));var emlformat=require(_0x51cc('0x1'));var rimraf=require(_0x51cc('0x2'));var zipdir=require(_0x51cc('0x3'));var jsonpatch=require(_0x51cc('0x4'));var rp=require(_0x51cc('0x5'));var moment=require(_0x51cc('0x6'));var BPromise=require(_0x51cc('0x7'));var Mustache=require(_0x51cc('0x8'));var util=require('util');var path=require(_0x51cc('0x9'));var sox=require('sox');var csv=require(_0x51cc('0xa'));var ejs=require(_0x51cc('0xb'));var fs=require('fs');var _=require(_0x51cc('0xc'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x51cc('0xd'));var deskjs=require(_0x51cc('0xe'));var toCsv=require(_0x51cc('0xa'));var querystring=require(_0x51cc('0xf'));var Papa=require('papaparse');var Redis=require(_0x51cc('0x10'));var authService=require(_0x51cc('0x11'));var qs=require(_0x51cc('0x12'));var as=require(_0x51cc('0x13'));var hardwareService=require(_0x51cc('0x14'));var logger=require('../../config/logger')(_0x51cc('0x15'));var utils=require(_0x51cc('0x16'));var config=require('../../config/environment');var licenseUtil=require(_0x51cc('0x17'));var db=require(_0x51cc('0x18'))['db'];function respondWithStatusCode(_0x4cb758,_0x522b30){_0x522b30=_0x522b30||0xcc;return function(_0x1ee610){if(_0x1ee610){return _0x4cb758[_0x51cc('0x19')](_0x522b30);}return _0x4cb758[_0x51cc('0x1a')](_0x522b30)[_0x51cc('0x1b')]();};}function respondWithResult(_0x421d45,_0x40124e){_0x40124e=_0x40124e||0xc8;return function(_0x467ea7){if(_0x467ea7){return _0x421d45['status'](_0x40124e)[_0x51cc('0x1c')](_0x467ea7);}};}function respondWithFilteredResult(_0x2f670e,_0x21f74a){return function(_0x4ddd0f){if(_0x4ddd0f){var _0x156c22=_0x4ddd0f[_0x51cc('0x1d')],_0x22bcf6=_0x21f74a[_0x51cc('0x1e')],_0x29c701=_0x21f74a[_0x51cc('0x1e')]+_0x21f74a['limit'],_0x3509bb;if(_0x29c701>=_0x156c22){_0x29c701=_0x156c22;_0x3509bb=0xc8;}else{_0x3509bb=0xce;}_0x2f670e[_0x51cc('0x1a')](_0x3509bb);return _0x2f670e[_0x51cc('0x1f')](_0x51cc('0x20'),_0x22bcf6+'-'+_0x29c701+'/'+_0x156c22)['json'](_0x4ddd0f);}return null;};}function patchUpdates(_0x416f9b){return function(_0x3eada4){try{jsonpatch['apply'](_0x3eada4,_0x416f9b,!![]);}catch(_0x28d821){return BPromise[_0x51cc('0x21')](_0x28d821);}return _0x3eada4[_0x51cc('0x22')]();};}function saveUpdates(_0x238615,_0x1b9c49){return function(_0x2de9de){if(_0x2de9de){return _0x2de9de['update'](_0x238615)[_0x51cc('0x23')](function(_0x4a4324){return _0x4a4324;});}return null;};}function removeEntity(_0x1403be,_0x4c3a79){return function(_0x5ba3fc){if(_0x5ba3fc){return _0x5ba3fc['destroy']()[_0x51cc('0x23')](function(){_0x1403be[_0x51cc('0x1a')](0xcc)['end']();});}};}function handleEntityNotFound(_0x381d44,_0x33eb8d){return function(_0x545502){if(!_0x545502){_0x381d44[_0x51cc('0x19')](0x194);}return _0x545502;};}function handleError(_0x18f7e2,_0x54291f){_0x54291f=_0x54291f||0x1f4;return function(_0x5f5979){logger[_0x51cc('0x24')](_0x5f5979[_0x51cc('0x25')]);if(_0x5f5979[_0x51cc('0x26')]){delete _0x5f5979[_0x51cc('0x26')];}_0x18f7e2[_0x51cc('0x1a')](_0x54291f)[_0x51cc('0x27')](_0x5f5979);};}exports[_0x51cc('0x28')]=function(_0x3d5eee,_0x3caebe){var _0x53b7ea={'raw':!![],'where':{'id':_0x3d5eee[_0x51cc('0x29')]['id']}},_0x2a43cf={};_0x2a43cf['model']=_[_0x51cc('0x2a')](db[_0x51cc('0x2b')]['rawAttributes']);_0x2a43cf[_0x51cc('0x2c')]=_[_0x51cc('0x2a')](_0x3d5eee['query']);_0x2a43cf[_0x51cc('0x2d')]=_['intersection'](_0x2a43cf[_0x51cc('0x2e')],_0x2a43cf['query']);_0x53b7ea[_0x51cc('0x2f')]=_[_0x51cc('0x30')](_0x2a43cf['model'],qs['fields'](_0x3d5eee[_0x51cc('0x2c')][_0x51cc('0x31')]));_0x53b7ea[_0x51cc('0x2f')]=_0x53b7ea[_0x51cc('0x2f')][_0x51cc('0x32')]?_0x53b7ea[_0x51cc('0x2f')]:_0x2a43cf[_0x51cc('0x2e')];if(_0x3d5eee[_0x51cc('0x2c')][_0x51cc('0x33')]){_0x53b7ea[_0x51cc('0x34')]=[{'all':!![]}];}_0x53b7ea=_[_0x51cc('0x35')]({},_0x53b7ea,_0x3d5eee[_0x51cc('0x36')]);return db[_0x51cc('0x2b')][_0x51cc('0x37')](_0x53b7ea)['then'](handleEntityNotFound(_0x3caebe,null))[_0x51cc('0x23')](respondWithResult(_0x3caebe,null))['catch'](handleError(_0x3caebe,null));};exports[_0x51cc('0x38')]=function(_0x5742ea,_0xf8da15){if(_0x5742ea[_0x51cc('0x39')]['id']){delete _0x5742ea['body']['id'];}return db['ChatApplication'][_0x51cc('0x37')]({'where':{'id':_0x5742ea[_0x51cc('0x29')]['id']}})['then'](handleEntityNotFound(_0xf8da15,null))[_0x51cc('0x23')](saveUpdates(_0x5742ea[_0x51cc('0x39')],null))[_0x51cc('0x23')](respondWithResult(_0xf8da15,null))[_0x51cc('0x3a')](handleError(_0xf8da15,null));};exports['destroy']=function(_0x18733c,_0x1980d3){return db['ChatApplication']['find']({'where':{'id':_0x18733c[_0x51cc('0x29')]['id']}})['then'](handleEntityNotFound(_0x1980d3,null))[_0x51cc('0x23')](removeEntity(_0x1980d3,null))[_0x51cc('0x3a')](handleError(_0x1980d3,null));};