Built motion from commit (unavailable).|2.5.22
[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 _0xefd7=['../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','json','offset','limit','apply','reject','save','update','destroy','end','error','stack','name','send','show','params','model','ChatApplication','keys','query','filters','intersection','attributes','fields','include','merge','options','find','then','catch','body','html-pdf','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','papaparse','ioredis'];(function(_0x1a783e,_0x22c1f2){var _0x56376d=function(_0x27c23f){while(--_0x27c23f){_0x1a783e['push'](_0x1a783e['shift']());}};_0x56376d(++_0x22c1f2);}(_0xefd7,0x99));var _0x7efd=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0xefd7[_0x14add3];return _0x4a174f;};'use strict';var pdf=require(_0x7efd('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x7efd('0x1'));var zipdir=require(_0x7efd('0x2'));var jsonpatch=require(_0x7efd('0x3'));var rp=require('request-promise');var moment=require(_0x7efd('0x4'));var BPromise=require(_0x7efd('0x5'));var Mustache=require(_0x7efd('0x6'));var util=require(_0x7efd('0x7'));var path=require('path');var sox=require(_0x7efd('0x8'));var csv=require(_0x7efd('0x9'));var ejs=require(_0x7efd('0xa'));var fs=require('fs');var _=require(_0x7efd('0xb'));var squel=require(_0x7efd('0xc'));var crypto=require(_0x7efd('0xd'));var jsforce=require(_0x7efd('0xe'));var deskjs=require(_0x7efd('0xf'));var toCsv=require(_0x7efd('0x9'));var querystring=require('querystring');var Papa=require(_0x7efd('0x10'));var Redis=require(_0x7efd('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x7efd('0x12'));var as=require(_0x7efd('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x7efd('0x14'))(_0x7efd('0x15'));var utils=require('../../config/utils');var config=require(_0x7efd('0x16'));var licenseUtil=require(_0x7efd('0x17'));var db=require(_0x7efd('0x18'))['db'];function respondWithStatusCode(_0x57269e,_0x5e017c){_0x5e017c=_0x5e017c||0xcc;return function(_0x424da9){if(_0x424da9){return _0x57269e[_0x7efd('0x19')](_0x5e017c);}return _0x57269e[_0x7efd('0x1a')](_0x5e017c)['end']();};}function respondWithResult(_0x17c1f4,_0x37e9f2){_0x37e9f2=_0x37e9f2||0xc8;return function(_0x237323){if(_0x237323){return _0x17c1f4['status'](_0x37e9f2)[_0x7efd('0x1b')](_0x237323);}};}function respondWithFilteredResult(_0x143cb2,_0x5280a2){return function(_0x196674){if(_0x196674){var _0x5affe3=_0x196674['count'],_0x34d13f=_0x5280a2[_0x7efd('0x1c')],_0x112555=_0x5280a2[_0x7efd('0x1c')]+_0x5280a2[_0x7efd('0x1d')],_0x1e6344;if(_0x112555>=_0x5affe3){_0x112555=_0x5affe3;_0x1e6344=0xc8;}else{_0x1e6344=0xce;}_0x143cb2[_0x7efd('0x1a')](_0x1e6344);return _0x143cb2['set']('Content-Range',_0x34d13f+'-'+_0x112555+'/'+_0x5affe3)[_0x7efd('0x1b')](_0x196674);}return null;};}function patchUpdates(_0x59ecda){return function(_0x58c994){try{jsonpatch[_0x7efd('0x1e')](_0x58c994,_0x59ecda,!![]);}catch(_0x176600){return BPromise[_0x7efd('0x1f')](_0x176600);}return _0x58c994[_0x7efd('0x20')]();};}function saveUpdates(_0x5db31e,_0x4330dc){return function(_0x298374){if(_0x298374){return _0x298374[_0x7efd('0x21')](_0x5db31e)['then'](function(_0xaa80d5){return _0xaa80d5;});}return null;};}function removeEntity(_0x45cc61,_0xbdd9f8){return function(_0x230714){if(_0x230714){return _0x230714[_0x7efd('0x22')]()['then'](function(){_0x45cc61[_0x7efd('0x1a')](0xcc)[_0x7efd('0x23')]();});}};}function handleEntityNotFound(_0x127c86,_0x35bdb6){return function(_0xf40c96){if(!_0xf40c96){_0x127c86[_0x7efd('0x19')](0x194);}return _0xf40c96;};}function handleError(_0x3e3b74,_0x2a8088){_0x2a8088=_0x2a8088||0x1f4;return function(_0x4e604a){logger[_0x7efd('0x24')](_0x4e604a[_0x7efd('0x25')]);if(_0x4e604a[_0x7efd('0x26')]){delete _0x4e604a['name'];}_0x3e3b74[_0x7efd('0x1a')](_0x2a8088)[_0x7efd('0x27')](_0x4e604a);};}exports[_0x7efd('0x28')]=function(_0x500b6e,_0x433588){var _0x563b1f={'raw':!![],'where':{'id':_0x500b6e[_0x7efd('0x29')]['id']}},_0x3a07b6={};_0x3a07b6[_0x7efd('0x2a')]=_['keys'](db[_0x7efd('0x2b')]['rawAttributes']);_0x3a07b6['query']=_[_0x7efd('0x2c')](_0x500b6e[_0x7efd('0x2d')]);_0x3a07b6[_0x7efd('0x2e')]=_[_0x7efd('0x2f')](_0x3a07b6[_0x7efd('0x2a')],_0x3a07b6[_0x7efd('0x2d')]);_0x563b1f[_0x7efd('0x30')]=_[_0x7efd('0x2f')](_0x3a07b6[_0x7efd('0x2a')],qs[_0x7efd('0x31')](_0x500b6e['query'][_0x7efd('0x31')]));_0x563b1f[_0x7efd('0x30')]=_0x563b1f[_0x7efd('0x30')]['length']?_0x563b1f['attributes']:_0x3a07b6['model'];if(_0x500b6e[_0x7efd('0x2d')]['includeAll']){_0x563b1f[_0x7efd('0x32')]=[{'all':!![]}];}_0x563b1f=_[_0x7efd('0x33')]({},_0x563b1f,_0x500b6e[_0x7efd('0x34')]);return db[_0x7efd('0x2b')][_0x7efd('0x35')](_0x563b1f)[_0x7efd('0x36')](handleEntityNotFound(_0x433588,null))['then'](respondWithResult(_0x433588,null))[_0x7efd('0x37')](handleError(_0x433588,null));};exports['update']=function(_0x440a24,_0x2ecc77){if(_0x440a24['body']['id']){delete _0x440a24['body']['id'];}return db['ChatApplication']['find']({'where':{'id':_0x440a24[_0x7efd('0x29')]['id']}})['then'](handleEntityNotFound(_0x2ecc77,null))['then'](saveUpdates(_0x440a24[_0x7efd('0x38')],null))[_0x7efd('0x36')](respondWithResult(_0x2ecc77,null))[_0x7efd('0x37')](handleError(_0x2ecc77,null));};exports['destroy']=function(_0x24f5ff,_0x1d1c9a){return db[_0x7efd('0x2b')][_0x7efd('0x35')]({'where':{'id':_0x24f5ff[_0x7efd('0x29')]['id']}})[_0x7efd('0x36')](handleEntityNotFound(_0x1d1c9a,null))[_0x7efd('0x36')](removeEntity(_0x1d1c9a,null))[_0x7efd('0x37')](handleError(_0x1d1c9a,null));};