Built motion from commit (unavailable).|2.5.23
[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 _0xe086=['Content-Range','json','apply','reject','update','then','end','error','stack','name','send','show','params','model','ChatApplication','rawAttributes','query','keys','intersection','fields','attributes','length','merge','options','find','catch','body','html-pdf','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','crypto','desk.js','querystring','papaparse','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','offset','limit'];(function(_0x5cdad2,_0x129d32){var _0x508c9b=function(_0x481bd5){while(--_0x481bd5){_0x5cdad2['push'](_0x5cdad2['shift']());}};_0x508c9b(++_0x129d32);}(_0xe086,0x15f));var _0x6e08=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xe086[_0x3dd15e];return _0x231fd0;};'use strict';var pdf=require(_0x6e08('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x6e08('0x1'));var zipdir=require(_0x6e08('0x2'));var jsonpatch=require(_0x6e08('0x3'));var rp=require(_0x6e08('0x4'));var moment=require('moment');var BPromise=require(_0x6e08('0x5'));var Mustache=require(_0x6e08('0x6'));var util=require(_0x6e08('0x7'));var path=require(_0x6e08('0x8'));var sox=require(_0x6e08('0x9'));var csv=require(_0x6e08('0xa'));var ejs=require(_0x6e08('0xb'));var fs=require('fs');var _=require(_0x6e08('0xc'));var squel=require('squel');var crypto=require(_0x6e08('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x6e08('0xe'));var toCsv=require('to-csv');var querystring=require(_0x6e08('0xf'));var Papa=require(_0x6e08('0x10'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x6e08('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x6e08('0x12'));var logger=require('../../config/logger')(_0x6e08('0x13'));var utils=require(_0x6e08('0x14'));var config=require('../../config/environment');var licenseUtil=require(_0x6e08('0x15'));var db=require(_0x6e08('0x16'))['db'];function respondWithStatusCode(_0x4327cc,_0x59fc4a){_0x59fc4a=_0x59fc4a||0xcc;return function(_0x5c8cf3){if(_0x5c8cf3){return _0x4327cc[_0x6e08('0x17')](_0x59fc4a);}return _0x4327cc[_0x6e08('0x18')](_0x59fc4a)['end']();};}function respondWithResult(_0x3705df,_0x20bd37){_0x20bd37=_0x20bd37||0xc8;return function(_0x1427e8){if(_0x1427e8){return _0x3705df['status'](_0x20bd37)['json'](_0x1427e8);}};}function respondWithFilteredResult(_0x14e0eb,_0x5ec840){return function(_0x34039c){if(_0x34039c){var _0x1e103b=_0x34039c['count'],_0x3a8613=_0x5ec840[_0x6e08('0x19')],_0x38d5a4=_0x5ec840[_0x6e08('0x19')]+_0x5ec840[_0x6e08('0x1a')],_0x4747f0;if(_0x38d5a4>=_0x1e103b){_0x38d5a4=_0x1e103b;_0x4747f0=0xc8;}else{_0x4747f0=0xce;}_0x14e0eb[_0x6e08('0x18')](_0x4747f0);return _0x14e0eb['set'](_0x6e08('0x1b'),_0x3a8613+'-'+_0x38d5a4+'/'+_0x1e103b)[_0x6e08('0x1c')](_0x34039c);}return null;};}function patchUpdates(_0x3124c0){return function(_0x221057){try{jsonpatch[_0x6e08('0x1d')](_0x221057,_0x3124c0,!![]);}catch(_0x51743b){return BPromise[_0x6e08('0x1e')](_0x51743b);}return _0x221057['save']();};}function saveUpdates(_0x3100e4,_0x8d2903){return function(_0x4deb7a){if(_0x4deb7a){return _0x4deb7a[_0x6e08('0x1f')](_0x3100e4)[_0x6e08('0x20')](function(_0x1e088d){return _0x1e088d;});}return null;};}function removeEntity(_0x81a9a7,_0x388b32){return function(_0x445847){if(_0x445847){return _0x445847['destroy']()[_0x6e08('0x20')](function(){_0x81a9a7[_0x6e08('0x18')](0xcc)[_0x6e08('0x21')]();});}};}function handleEntityNotFound(_0x480880,_0x347680){return function(_0x3aeafc){if(!_0x3aeafc){_0x480880['sendStatus'](0x194);}return _0x3aeafc;};}function handleError(_0x328c79,_0x410b3a){_0x410b3a=_0x410b3a||0x1f4;return function(_0x2220be){logger[_0x6e08('0x22')](_0x2220be[_0x6e08('0x23')]);if(_0x2220be['name']){delete _0x2220be[_0x6e08('0x24')];}_0x328c79[_0x6e08('0x18')](_0x410b3a)[_0x6e08('0x25')](_0x2220be);};}exports[_0x6e08('0x26')]=function(_0x25b99a,_0x3786aa){var _0xed94b6={'raw':!![],'where':{'id':_0x25b99a[_0x6e08('0x27')]['id']}},_0x30b369={};_0x30b369[_0x6e08('0x28')]=_['keys'](db[_0x6e08('0x29')][_0x6e08('0x2a')]);_0x30b369[_0x6e08('0x2b')]=_[_0x6e08('0x2c')](_0x25b99a[_0x6e08('0x2b')]);_0x30b369['filters']=_[_0x6e08('0x2d')](_0x30b369[_0x6e08('0x28')],_0x30b369[_0x6e08('0x2b')]);_0xed94b6['attributes']=_['intersection'](_0x30b369['model'],qs[_0x6e08('0x2e')](_0x25b99a[_0x6e08('0x2b')][_0x6e08('0x2e')]));_0xed94b6[_0x6e08('0x2f')]=_0xed94b6[_0x6e08('0x2f')][_0x6e08('0x30')]?_0xed94b6[_0x6e08('0x2f')]:_0x30b369[_0x6e08('0x28')];if(_0x25b99a[_0x6e08('0x2b')]['includeAll']){_0xed94b6['include']=[{'all':!![]}];}_0xed94b6=_[_0x6e08('0x31')]({},_0xed94b6,_0x25b99a[_0x6e08('0x32')]);return db[_0x6e08('0x29')][_0x6e08('0x33')](_0xed94b6)[_0x6e08('0x20')](handleEntityNotFound(_0x3786aa,null))[_0x6e08('0x20')](respondWithResult(_0x3786aa,null))[_0x6e08('0x34')](handleError(_0x3786aa,null));};exports[_0x6e08('0x1f')]=function(_0x1ba602,_0x108cde){if(_0x1ba602[_0x6e08('0x35')]['id']){delete _0x1ba602['body']['id'];}return db[_0x6e08('0x29')]['find']({'where':{'id':_0x1ba602['params']['id']}})[_0x6e08('0x20')](handleEntityNotFound(_0x108cde,null))[_0x6e08('0x20')](saveUpdates(_0x1ba602['body'],null))['then'](respondWithResult(_0x108cde,null))[_0x6e08('0x34')](handleError(_0x108cde,null));};exports['destroy']=function(_0x577899,_0x491a53){return db['ChatApplication'][_0x6e08('0x33')]({'where':{'id':_0x577899[_0x6e08('0x27')]['id']}})[_0x6e08('0x20')](handleEntityNotFound(_0x491a53,null))[_0x6e08('0x20')](removeEntity(_0x491a53,null))[_0x6e08('0x34')](handleError(_0x491a53,null));};