Built motion from commit (unavailable).|2.5.12
[motion2.git] / server / api / mailSubstatus / mailSubstatus.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 _0xf352=['ejs','lodash','squel','crypto','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','count','offset','limit','Content-Range','save','update','then','destroy','name','send','index','map','MailSubstatus','rawAttributes','fieldName','model','keys','query','intersection','attributes','fields','hasOwnProperty','order','sort','where','filters','pick','filter','merge','VIRTUAL','options','includeAll','findAll','rows','params','length','find','catch','create','body','describe','eml-format','rimraf','request-promise','bluebird','mustache','sox','to-csv'];(function(_0x1694f5,_0x49b7c3){var _0x5b4321=function(_0x58c183){while(--_0x58c183){_0x1694f5['push'](_0x1694f5['shift']());}};_0x5b4321(++_0x49b7c3);}(_0xf352,0x81));var _0x2f35=function(_0x539175,_0x526379){_0x539175=_0x539175-0x0;var _0x2ea870=_0xf352[_0x539175];return _0x2ea870;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x2f35('0x0'));var rimraf=require(_0x2f35('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x2f35('0x2'));var moment=require('moment');var BPromise=require(_0x2f35('0x3'));var Mustache=require(_0x2f35('0x4'));var util=require('util');var path=require('path');var sox=require(_0x2f35('0x5'));var csv=require(_0x2f35('0x6'));var ejs=require(_0x2f35('0x7'));var fs=require('fs');var _=require(_0x2f35('0x8'));var squel=require(_0x2f35('0x9'));var crypto=require(_0x2f35('0xa'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x2f35('0x6'));var querystring=require(_0x2f35('0xb'));var Papa=require(_0x2f35('0xc'));var Redis=require(_0x2f35('0xd'));var authService=require(_0x2f35('0xe'));var qs=require(_0x2f35('0xf'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x2f35('0x10'));var logger=require(_0x2f35('0x11'))(_0x2f35('0x12'));var utils=require(_0x2f35('0x13'));var config=require(_0x2f35('0x14'));var licenseUtil=require(_0x2f35('0x15'));var db=require(_0x2f35('0x16'))['db'];function respondWithStatusCode(_0x34e6b7,_0x2a004b){_0x2a004b=_0x2a004b||0xcc;return function(_0x3255d1){if(_0x3255d1){return _0x34e6b7[_0x2f35('0x17')](_0x2a004b);}return _0x34e6b7[_0x2f35('0x18')](_0x2a004b)[_0x2f35('0x19')]();};}function respondWithResult(_0x50298d,_0x17f9a4){_0x17f9a4=_0x17f9a4||0xc8;return function(_0x57c44e){if(_0x57c44e){return _0x50298d['status'](_0x17f9a4)[_0x2f35('0x1a')](_0x57c44e);}};}function respondWithFilteredResult(_0x59ce76,_0x20f08a){return function(_0x21af5c){if(_0x21af5c){var _0x156b19=_0x21af5c[_0x2f35('0x1b')],_0x18cac9=_0x20f08a[_0x2f35('0x1c')],_0x22de17=_0x20f08a[_0x2f35('0x1c')]+_0x20f08a[_0x2f35('0x1d')],_0x4ed1bc;if(_0x22de17>=_0x156b19){_0x22de17=_0x156b19;_0x4ed1bc=0xc8;}else{_0x4ed1bc=0xce;}_0x59ce76[_0x2f35('0x18')](_0x4ed1bc);return _0x59ce76['set'](_0x2f35('0x1e'),_0x18cac9+'-'+_0x22de17+'/'+_0x156b19)[_0x2f35('0x1a')](_0x21af5c);}return null;};}function patchUpdates(_0x38821d){return function(_0xecad74){try{jsonpatch['apply'](_0xecad74,_0x38821d,!![]);}catch(_0x27ef0c){return BPromise['reject'](_0x27ef0c);}return _0xecad74[_0x2f35('0x1f')]();};}function saveUpdates(_0xd1aacd,_0x3c4ed8){return function(_0x3544d0){if(_0x3544d0){return _0x3544d0[_0x2f35('0x20')](_0xd1aacd)[_0x2f35('0x21')](function(_0x2b7656){return _0x2b7656;});}return null;};}function removeEntity(_0x170d6e,_0x160d5d){return function(_0x38a80d){if(_0x38a80d){return _0x38a80d[_0x2f35('0x22')]()['then'](function(){_0x170d6e[_0x2f35('0x18')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2389b9,_0x5c9424){return function(_0x7e3d5c){if(!_0x7e3d5c){_0x2389b9[_0x2f35('0x17')](0x194);}return _0x7e3d5c;};}function handleError(_0x55ea3e,_0x4208f9){_0x4208f9=_0x4208f9||0x1f4;return function(_0x9af768){logger['error'](_0x9af768['stack']);if(_0x9af768[_0x2f35('0x23')]){delete _0x9af768[_0x2f35('0x23')];}_0x55ea3e[_0x2f35('0x18')](_0x4208f9)[_0x2f35('0x24')](_0x9af768);};}exports[_0x2f35('0x25')]=function(_0x4c96aa,_0x19d80d){var _0x2612c4={},_0x127ca5={},_0x5ed123={'count':0x0,'rows':[]};var _0x3b83de=_[_0x2f35('0x26')](db[_0x2f35('0x27')][_0x2f35('0x28')],function(_0x3d0de6){return{'name':_0x3d0de6[_0x2f35('0x29')],'type':_0x3d0de6['type']['key']};});_0x127ca5[_0x2f35('0x2a')]=_[_0x2f35('0x26')](_0x3b83de,_0x2f35('0x23'));_0x127ca5['query']=_[_0x2f35('0x2b')](_0x4c96aa[_0x2f35('0x2c')]);_0x127ca5['filters']=_[_0x2f35('0x2d')](_0x127ca5[_0x2f35('0x2a')],_0x127ca5[_0x2f35('0x2c')]);_0x2612c4[_0x2f35('0x2e')]=_['intersection'](_0x127ca5[_0x2f35('0x2a')],qs[_0x2f35('0x2f')](_0x4c96aa[_0x2f35('0x2c')]['fields']));_0x2612c4[_0x2f35('0x2e')]=_0x2612c4[_0x2f35('0x2e')]['length']?_0x2612c4[_0x2f35('0x2e')]:_0x127ca5['model'];if(!_0x4c96aa[_0x2f35('0x2c')][_0x2f35('0x30')]('nolimit')){_0x2612c4['limit']=qs[_0x2f35('0x1d')](_0x4c96aa[_0x2f35('0x2c')][_0x2f35('0x1d')]);_0x2612c4['offset']=qs[_0x2f35('0x1c')](_0x4c96aa[_0x2f35('0x2c')][_0x2f35('0x1c')]);}_0x2612c4[_0x2f35('0x31')]=qs[_0x2f35('0x32')](_0x4c96aa[_0x2f35('0x2c')][_0x2f35('0x32')]);_0x2612c4[_0x2f35('0x33')]=qs[_0x2f35('0x34')](_[_0x2f35('0x35')](_0x4c96aa[_0x2f35('0x2c')],_0x127ca5[_0x2f35('0x34')]),_0x3b83de);if(_0x4c96aa[_0x2f35('0x2c')][_0x2f35('0x36')]){_0x2612c4[_0x2f35('0x33')]=_[_0x2f35('0x37')](_0x2612c4[_0x2f35('0x33')],{'$or':_[_0x2f35('0x26')](_0x3b83de,function(_0x434926){if(_0x434926['type']!==_0x2f35('0x38')){var _0x28719a={};_0x28719a[_0x434926[_0x2f35('0x23')]]={'$like':'%'+_0x4c96aa[_0x2f35('0x2c')]['filter']+'%'};return _0x28719a;}})});}_0x2612c4=_[_0x2f35('0x37')]({},_0x2612c4,_0x4c96aa[_0x2f35('0x39')]);var _0x31d524={'where':_0x2612c4[_0x2f35('0x33')]};return db[_0x2f35('0x27')]['count'](_0x31d524)[_0x2f35('0x21')](function(_0x10695a){_0x5ed123['count']=_0x10695a;if(_0x4c96aa[_0x2f35('0x2c')][_0x2f35('0x3a')]){_0x2612c4['include']=[{'all':!![]}];}return db[_0x2f35('0x27')][_0x2f35('0x3b')](_0x2612c4);})['then'](function(_0x4ccdbc){_0x5ed123[_0x2f35('0x3c')]=_0x4ccdbc;return _0x5ed123;})['then'](respondWithFilteredResult(_0x19d80d,_0x2612c4))['catch'](handleError(_0x19d80d,null));};exports['show']=function(_0x51178a,_0x4d01a1){var _0x1bff80={'raw':!![],'where':{'id':_0x51178a[_0x2f35('0x3d')]['id']}},_0x174e78={};_0x174e78[_0x2f35('0x2a')]=_['keys'](db[_0x2f35('0x27')]['rawAttributes']);_0x174e78['query']=_[_0x2f35('0x2b')](_0x51178a[_0x2f35('0x2c')]);_0x174e78[_0x2f35('0x34')]=_['intersection'](_0x174e78[_0x2f35('0x2a')],_0x174e78[_0x2f35('0x2c')]);_0x1bff80[_0x2f35('0x2e')]=_[_0x2f35('0x2d')](_0x174e78[_0x2f35('0x2a')],qs[_0x2f35('0x2f')](_0x51178a['query']['fields']));_0x1bff80[_0x2f35('0x2e')]=_0x1bff80[_0x2f35('0x2e')][_0x2f35('0x3e')]?_0x1bff80['attributes']:_0x174e78['model'];if(_0x51178a[_0x2f35('0x2c')][_0x2f35('0x3a')]){_0x1bff80['include']=[{'all':!![]}];}_0x1bff80=_[_0x2f35('0x37')]({},_0x1bff80,_0x51178a[_0x2f35('0x39')]);return db['MailSubstatus'][_0x2f35('0x3f')](_0x1bff80)[_0x2f35('0x21')](handleEntityNotFound(_0x4d01a1,null))['then'](respondWithResult(_0x4d01a1,null))[_0x2f35('0x40')](handleError(_0x4d01a1,null));};exports['create']=function(_0x39e1ed,_0x2958e4){return db[_0x2f35('0x27')][_0x2f35('0x41')](_0x39e1ed['body'],{})[_0x2f35('0x21')](respondWithResult(_0x2958e4,0xc9))['catch'](handleError(_0x2958e4,null));};exports['update']=function(_0x4953e7,_0x44838a){if(_0x4953e7['body']['id']){delete _0x4953e7[_0x2f35('0x42')]['id'];}return db['MailSubstatus'][_0x2f35('0x3f')]({'where':{'id':_0x4953e7[_0x2f35('0x3d')]['id']}})['then'](handleEntityNotFound(_0x44838a,null))['then'](saveUpdates(_0x4953e7[_0x2f35('0x42')],null))['then'](respondWithResult(_0x44838a,null))[_0x2f35('0x40')](handleError(_0x44838a,null));};exports['destroy']=function(_0xa22f76,_0xac457e){return db[_0x2f35('0x27')][_0x2f35('0x3f')]({'where':{'id':_0xa22f76['params']['id']}})[_0x2f35('0x21')](handleEntityNotFound(_0xac457e,null))[_0x2f35('0x21')](removeEntity(_0xac457e,null))[_0x2f35('0x40')](handleError(_0xac457e,null));};exports[_0x2f35('0x43')]=function(_0x6eb83c,_0x1dee2a){return db[_0x2f35('0x27')][_0x2f35('0x43')]()[_0x2f35('0x21')](respondWithResult(_0x1dee2a,null))['catch'](handleError(_0x1dee2a,null));};