Built motion from commit (unavailable).|2.5.13
[motion2.git] / server / api / chatOfflineMessage / chatOfflineMessage.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 _0x8f41=['describe','html-pdf','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','sox','to-csv','lodash','squel','crypto','jsforce','desk.js','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','status','json','count','offset','set','Content-Range','apply','reject','save','update','then','destroy','end','sendStatus','error','name','send','index','map','ChatOfflineMessage','rawAttributes','type','key','model','query','keys','filters','intersection','attributes','fields','length','nolimit','limit','sort','pick','filter','where','merge','options','includeAll','findAll','rows','catch','show','params','include','find','create','body'];(function(_0x698207,_0x490d94){var _0x5bd1bc=function(_0x413640){while(--_0x413640){_0x698207['push'](_0x698207['shift']());}};_0x5bd1bc(++_0x490d94);}(_0x8f41,0x1c3));var _0x18f4=function(_0x3ad8fb,_0x5bbadf){_0x3ad8fb=_0x3ad8fb-0x0;var _0x16efa8=_0x8f41[_0x3ad8fb];return _0x16efa8;};'use strict';var pdf=require(_0x18f4('0x0'));var emlformat=require(_0x18f4('0x1'));var rimraf=require('rimraf');var zipdir=require(_0x18f4('0x2'));var jsonpatch=require(_0x18f4('0x3'));var rp=require(_0x18f4('0x4'));var moment=require(_0x18f4('0x5'));var BPromise=require(_0x18f4('0x6'));var Mustache=require('mustache');var util=require(_0x18f4('0x7'));var path=require(_0x18f4('0x8'));var sox=require(_0x18f4('0x9'));var csv=require(_0x18f4('0xa'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x18f4('0xb'));var squel=require(_0x18f4('0xc'));var crypto=require(_0x18f4('0xd'));var jsforce=require(_0x18f4('0xe'));var deskjs=require(_0x18f4('0xf'));var toCsv=require(_0x18f4('0xa'));var querystring=require('querystring');var Papa=require(_0x18f4('0x10'));var Redis=require('ioredis');var authService=require(_0x18f4('0x11'));var qs=require(_0x18f4('0x12'));var as=require(_0x18f4('0x13'));var hardwareService=require(_0x18f4('0x14'));var logger=require(_0x18f4('0x15'))(_0x18f4('0x16'));var utils=require('../../config/utils');var config=require(_0x18f4('0x17'));var licenseUtil=require(_0x18f4('0x18'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x36611a,_0xf5a509){_0xf5a509=_0xf5a509||0xcc;return function(_0x5a0c52){if(_0x5a0c52){return _0x36611a['sendStatus'](_0xf5a509);}return _0x36611a['status'](_0xf5a509)['end']();};}function respondWithResult(_0x336c5c,_0x3c7d26){_0x3c7d26=_0x3c7d26||0xc8;return function(_0x14f374){if(_0x14f374){return _0x336c5c[_0x18f4('0x19')](_0x3c7d26)[_0x18f4('0x1a')](_0x14f374);}};}function respondWithFilteredResult(_0x467083,_0x2d02f8){return function(_0x1ca11b){if(_0x1ca11b){var _0x5628d0=_0x1ca11b[_0x18f4('0x1b')],_0xcbeb56=_0x2d02f8[_0x18f4('0x1c')],_0x1ef08e=_0x2d02f8[_0x18f4('0x1c')]+_0x2d02f8['limit'],_0x31aac5;if(_0x1ef08e>=_0x5628d0){_0x1ef08e=_0x5628d0;_0x31aac5=0xc8;}else{_0x31aac5=0xce;}_0x467083[_0x18f4('0x19')](_0x31aac5);return _0x467083[_0x18f4('0x1d')](_0x18f4('0x1e'),_0xcbeb56+'-'+_0x1ef08e+'/'+_0x5628d0)[_0x18f4('0x1a')](_0x1ca11b);}return null;};}function patchUpdates(_0x3b216d){return function(_0x173583){try{jsonpatch[_0x18f4('0x1f')](_0x173583,_0x3b216d,!![]);}catch(_0x3bee76){return BPromise[_0x18f4('0x20')](_0x3bee76);}return _0x173583[_0x18f4('0x21')]();};}function saveUpdates(_0x7e8452,_0x63fce1){return function(_0x224899){if(_0x224899){return _0x224899[_0x18f4('0x22')](_0x7e8452)[_0x18f4('0x23')](function(_0x1df3c1){return _0x1df3c1;});}return null;};}function removeEntity(_0x5145f3,_0xf2f7a6){return function(_0x420cb3){if(_0x420cb3){return _0x420cb3[_0x18f4('0x24')]()['then'](function(){_0x5145f3['status'](0xcc)[_0x18f4('0x25')]();});}};}function handleEntityNotFound(_0x300ab9,_0x506a1a){return function(_0x2cf648){if(!_0x2cf648){_0x300ab9[_0x18f4('0x26')](0x194);}return _0x2cf648;};}function handleError(_0x5d3b6a,_0x197e94){_0x197e94=_0x197e94||0x1f4;return function(_0x381939){logger[_0x18f4('0x27')](_0x381939['stack']);if(_0x381939[_0x18f4('0x28')]){delete _0x381939[_0x18f4('0x28')];}_0x5d3b6a[_0x18f4('0x19')](_0x197e94)[_0x18f4('0x29')](_0x381939);};}exports[_0x18f4('0x2a')]=function(_0x21f701,_0x197e76){var _0x449430={},_0x471e68={},_0x37a5ba={'count':0x0,'rows':[]};var _0x36211c=_[_0x18f4('0x2b')](db[_0x18f4('0x2c')][_0x18f4('0x2d')],function(_0x1afc65){return{'name':_0x1afc65['fieldName'],'type':_0x1afc65[_0x18f4('0x2e')][_0x18f4('0x2f')]};});_0x471e68[_0x18f4('0x30')]=_[_0x18f4('0x2b')](_0x36211c,_0x18f4('0x28'));_0x471e68[_0x18f4('0x31')]=_[_0x18f4('0x32')](_0x21f701[_0x18f4('0x31')]);_0x471e68[_0x18f4('0x33')]=_[_0x18f4('0x34')](_0x471e68[_0x18f4('0x30')],_0x471e68[_0x18f4('0x31')]);_0x449430[_0x18f4('0x35')]=_['intersection'](_0x471e68[_0x18f4('0x30')],qs[_0x18f4('0x36')](_0x21f701[_0x18f4('0x31')]['fields']));_0x449430[_0x18f4('0x35')]=_0x449430[_0x18f4('0x35')][_0x18f4('0x37')]?_0x449430[_0x18f4('0x35')]:_0x471e68[_0x18f4('0x30')];if(!_0x21f701[_0x18f4('0x31')]['hasOwnProperty'](_0x18f4('0x38'))){_0x449430[_0x18f4('0x39')]=qs[_0x18f4('0x39')](_0x21f701['query'][_0x18f4('0x39')]);_0x449430[_0x18f4('0x1c')]=qs[_0x18f4('0x1c')](_0x21f701[_0x18f4('0x31')][_0x18f4('0x1c')]);}_0x449430['order']=qs[_0x18f4('0x3a')](_0x21f701['query']['sort']);_0x449430['where']=qs[_0x18f4('0x33')](_[_0x18f4('0x3b')](_0x21f701[_0x18f4('0x31')],_0x471e68[_0x18f4('0x33')]),_0x36211c);if(_0x21f701[_0x18f4('0x31')][_0x18f4('0x3c')]){_0x449430[_0x18f4('0x3d')]=_[_0x18f4('0x3e')](_0x449430[_0x18f4('0x3d')],{'$or':_[_0x18f4('0x2b')](_0x36211c,function(_0xd32b3e){if(_0xd32b3e[_0x18f4('0x2e')]!=='VIRTUAL'){var _0x50e356={};_0x50e356[_0xd32b3e[_0x18f4('0x28')]]={'$like':'%'+_0x21f701[_0x18f4('0x31')][_0x18f4('0x3c')]+'%'};return _0x50e356;}})});}_0x449430=_['merge']({},_0x449430,_0x21f701[_0x18f4('0x3f')]);var _0xd8cd68={'where':_0x449430[_0x18f4('0x3d')]};return db[_0x18f4('0x2c')][_0x18f4('0x1b')](_0xd8cd68)[_0x18f4('0x23')](function(_0x2ce3c4){_0x37a5ba[_0x18f4('0x1b')]=_0x2ce3c4;if(_0x21f701[_0x18f4('0x31')][_0x18f4('0x40')]){_0x449430['include']=[{'all':!![]}];}return db[_0x18f4('0x2c')][_0x18f4('0x41')](_0x449430);})[_0x18f4('0x23')](function(_0x4fa683){_0x37a5ba[_0x18f4('0x42')]=_0x4fa683;return _0x37a5ba;})[_0x18f4('0x23')](respondWithFilteredResult(_0x197e76,_0x449430))[_0x18f4('0x43')](handleError(_0x197e76,null));};exports[_0x18f4('0x44')]=function(_0x5bc0be,_0x327def){var _0x4b7222={'raw':!![],'where':{'id':_0x5bc0be[_0x18f4('0x45')]['id']}},_0x4b15a4={};_0x4b15a4[_0x18f4('0x30')]=_['keys'](db[_0x18f4('0x2c')][_0x18f4('0x2d')]);_0x4b15a4['query']=_['keys'](_0x5bc0be[_0x18f4('0x31')]);_0x4b15a4[_0x18f4('0x33')]=_[_0x18f4('0x34')](_0x4b15a4[_0x18f4('0x30')],_0x4b15a4['query']);_0x4b7222['attributes']=_[_0x18f4('0x34')](_0x4b15a4['model'],qs[_0x18f4('0x36')](_0x5bc0be['query'][_0x18f4('0x36')]));_0x4b7222[_0x18f4('0x35')]=_0x4b7222[_0x18f4('0x35')][_0x18f4('0x37')]?_0x4b7222[_0x18f4('0x35')]:_0x4b15a4[_0x18f4('0x30')];if(_0x5bc0be['query'][_0x18f4('0x40')]){_0x4b7222[_0x18f4('0x46')]=[{'all':!![]}];}_0x4b7222=_[_0x18f4('0x3e')]({},_0x4b7222,_0x5bc0be[_0x18f4('0x3f')]);return db['ChatOfflineMessage'][_0x18f4('0x47')](_0x4b7222)['then'](handleEntityNotFound(_0x327def,null))[_0x18f4('0x23')](respondWithResult(_0x327def,null))[_0x18f4('0x43')](handleError(_0x327def,null));};exports[_0x18f4('0x48')]=function(_0x12bbda,_0x188a1d){return db[_0x18f4('0x2c')][_0x18f4('0x48')](_0x12bbda[_0x18f4('0x49')],{})[_0x18f4('0x23')](respondWithResult(_0x188a1d,0xc9))['catch'](handleError(_0x188a1d,null));};exports[_0x18f4('0x22')]=function(_0x565499,_0x5dc30a){if(_0x565499[_0x18f4('0x49')]['id']){delete _0x565499['body']['id'];}return db[_0x18f4('0x2c')][_0x18f4('0x47')]({'where':{'id':_0x565499[_0x18f4('0x45')]['id']}})[_0x18f4('0x23')](handleEntityNotFound(_0x5dc30a,null))[_0x18f4('0x23')](saveUpdates(_0x565499[_0x18f4('0x49')],null))[_0x18f4('0x23')](respondWithResult(_0x5dc30a,null))[_0x18f4('0x43')](handleError(_0x5dc30a,null));};exports[_0x18f4('0x24')]=function(_0x334c91,_0x224980){return db[_0x18f4('0x2c')][_0x18f4('0x47')]({'where':{'id':_0x334c91['params']['id']}})[_0x18f4('0x23')](handleEntityNotFound(_0x224980,null))[_0x18f4('0x23')](removeEntity(_0x224980,null))[_0x18f4('0x43')](handleError(_0x224980,null));};exports[_0x18f4('0x4a')]=function(_0x3cff54,_0x2e6b73){return db[_0x18f4('0x2c')][_0x18f4('0x4a')]()[_0x18f4('0x23')](respondWithResult(_0x2e6b73,null))[_0x18f4('0x43')](handleError(_0x2e6b73,null));};