Built motion from commit (unavailable).|2.5.4
[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 _0x2b8b=['moment','bluebird','mustache','util','sox','to-csv','lodash','crypto','jsforce','desk.js','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','sendStatus','status','end','json','offset','limit','set','Content-Range','apply','reject','save','update','then','stack','name','index','map','MailSubstatus','rawAttributes','fieldName','type','key','model','keys','query','attributes','length','nolimit','order','sort','filters','pick','filter','where','merge','VIRTUAL','count','includeAll','include','findAll','catch','show','params','intersection','fields','find','create','body','destroy','describe','rimraf','zip-dir','fast-json-patch','request-promise'];(function(_0x332264,_0x15ad59){var _0x214cd2=function(_0xfd3d65){while(--_0xfd3d65){_0x332264['push'](_0x332264['shift']());}};_0x214cd2(++_0x15ad59);}(_0x2b8b,0xce));var _0xb2b8=function(_0x2641f9,_0x26715f){_0x2641f9=_0x2641f9-0x0;var _0x585741=_0x2b8b[_0x2641f9];return _0x585741;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require(_0xb2b8('0x0'));var zipdir=require(_0xb2b8('0x1'));var jsonpatch=require(_0xb2b8('0x2'));var rp=require(_0xb2b8('0x3'));var moment=require(_0xb2b8('0x4'));var BPromise=require(_0xb2b8('0x5'));var Mustache=require(_0xb2b8('0x6'));var util=require(_0xb2b8('0x7'));var path=require('path');var sox=require(_0xb2b8('0x8'));var csv=require(_0xb2b8('0x9'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xb2b8('0xa'));var squel=require('squel');var crypto=require(_0xb2b8('0xb'));var jsforce=require(_0xb2b8('0xc'));var deskjs=require(_0xb2b8('0xd'));var toCsv=require(_0xb2b8('0x9'));var querystring=require('querystring');var Papa=require(_0xb2b8('0xe'));var Redis=require('ioredis');var authService=require(_0xb2b8('0xf'));var qs=require(_0xb2b8('0x10'));var as=require(_0xb2b8('0x11'));var hardwareService=require(_0xb2b8('0x12'));var logger=require('../../config/logger')('api');var utils=require(_0xb2b8('0x13'));var config=require('../../config/environment');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x1d226c,_0x3b08e7){_0x3b08e7=_0x3b08e7||0xcc;return function(_0x255e73){if(_0x255e73){return _0x1d226c[_0xb2b8('0x14')](_0x3b08e7);}return _0x1d226c[_0xb2b8('0x15')](_0x3b08e7)[_0xb2b8('0x16')]();};}function respondWithResult(_0x2bbfb,_0x44639f){_0x44639f=_0x44639f||0xc8;return function(_0x6e914c){if(_0x6e914c){return _0x2bbfb[_0xb2b8('0x15')](_0x44639f)[_0xb2b8('0x17')](_0x6e914c);}};}function respondWithFilteredResult(_0x3a675c,_0x34ca0a){return function(_0x467b89){if(_0x467b89){var _0x33ed53=_0x467b89['count'],_0x3fea04=_0x34ca0a[_0xb2b8('0x18')],_0x163b83=_0x34ca0a[_0xb2b8('0x18')]+_0x34ca0a[_0xb2b8('0x19')],_0x5c55af;if(_0x163b83>=_0x33ed53){_0x163b83=_0x33ed53;_0x5c55af=0xc8;}else{_0x5c55af=0xce;}_0x3a675c[_0xb2b8('0x15')](_0x5c55af);return _0x3a675c[_0xb2b8('0x1a')](_0xb2b8('0x1b'),_0x3fea04+'-'+_0x163b83+'/'+_0x33ed53)[_0xb2b8('0x17')](_0x467b89);}return null;};}function patchUpdates(_0x4e8943){return function(_0x46273c){try{jsonpatch[_0xb2b8('0x1c')](_0x46273c,_0x4e8943,!![]);}catch(_0x4ebb81){return BPromise[_0xb2b8('0x1d')](_0x4ebb81);}return _0x46273c[_0xb2b8('0x1e')]();};}function saveUpdates(_0x393725,_0x568201){return function(_0x552ff2){if(_0x552ff2){return _0x552ff2[_0xb2b8('0x1f')](_0x393725)[_0xb2b8('0x20')](function(_0x1af211){return _0x1af211;});}return null;};}function removeEntity(_0x101d50,_0x4761aa){return function(_0x37227c){if(_0x37227c){return _0x37227c['destroy']()[_0xb2b8('0x20')](function(){_0x101d50[_0xb2b8('0x15')](0xcc)[_0xb2b8('0x16')]();});}};}function handleEntityNotFound(_0x3d6771,_0x4235ed){return function(_0x3f4188){if(!_0x3f4188){_0x3d6771[_0xb2b8('0x14')](0x194);}return _0x3f4188;};}function handleError(_0x439f67,_0x441cb4){_0x441cb4=_0x441cb4||0x1f4;return function(_0x5365c5){logger['error'](_0x5365c5[_0xb2b8('0x21')]);if(_0x5365c5[_0xb2b8('0x22')]){delete _0x5365c5[_0xb2b8('0x22')];}_0x439f67[_0xb2b8('0x15')](_0x441cb4)['send'](_0x5365c5);};}exports[_0xb2b8('0x23')]=function(_0x539968,_0x265e54){var _0x1dc786={},_0x2dffe2={},_0x18c2bc={'count':0x0,'rows':[]};var _0xd6e93e=_[_0xb2b8('0x24')](db[_0xb2b8('0x25')][_0xb2b8('0x26')],function(_0x52de08){return{'name':_0x52de08[_0xb2b8('0x27')],'type':_0x52de08[_0xb2b8('0x28')][_0xb2b8('0x29')]};});_0x2dffe2[_0xb2b8('0x2a')]=_[_0xb2b8('0x24')](_0xd6e93e,_0xb2b8('0x22'));_0x2dffe2['query']=_[_0xb2b8('0x2b')](_0x539968['query']);_0x2dffe2['filters']=_['intersection'](_0x2dffe2[_0xb2b8('0x2a')],_0x2dffe2[_0xb2b8('0x2c')]);_0x1dc786[_0xb2b8('0x2d')]=_['intersection'](_0x2dffe2[_0xb2b8('0x2a')],qs['fields'](_0x539968[_0xb2b8('0x2c')]['fields']));_0x1dc786[_0xb2b8('0x2d')]=_0x1dc786[_0xb2b8('0x2d')][_0xb2b8('0x2e')]?_0x1dc786[_0xb2b8('0x2d')]:_0x2dffe2['model'];if(!_0x539968[_0xb2b8('0x2c')]['hasOwnProperty'](_0xb2b8('0x2f'))){_0x1dc786['limit']=qs[_0xb2b8('0x19')](_0x539968['query'][_0xb2b8('0x19')]);_0x1dc786[_0xb2b8('0x18')]=qs[_0xb2b8('0x18')](_0x539968[_0xb2b8('0x2c')]['offset']);}_0x1dc786[_0xb2b8('0x30')]=qs[_0xb2b8('0x31')](_0x539968[_0xb2b8('0x2c')]['sort']);_0x1dc786['where']=qs[_0xb2b8('0x32')](_[_0xb2b8('0x33')](_0x539968['query'],_0x2dffe2[_0xb2b8('0x32')]),_0xd6e93e);if(_0x539968[_0xb2b8('0x2c')][_0xb2b8('0x34')]){_0x1dc786[_0xb2b8('0x35')]=_[_0xb2b8('0x36')](_0x1dc786[_0xb2b8('0x35')],{'$or':_[_0xb2b8('0x24')](_0xd6e93e,function(_0x3c0fcb){if(_0x3c0fcb[_0xb2b8('0x28')]!==_0xb2b8('0x37')){var _0x4a65ba={};_0x4a65ba[_0x3c0fcb[_0xb2b8('0x22')]]={'$like':'%'+_0x539968[_0xb2b8('0x2c')][_0xb2b8('0x34')]+'%'};return _0x4a65ba;}})});}_0x1dc786=_[_0xb2b8('0x36')]({},_0x1dc786,_0x539968['options']);var _0x500e50={'where':_0x1dc786['where']};return db[_0xb2b8('0x25')][_0xb2b8('0x38')](_0x500e50)[_0xb2b8('0x20')](function(_0x174e7f){_0x18c2bc[_0xb2b8('0x38')]=_0x174e7f;if(_0x539968[_0xb2b8('0x2c')][_0xb2b8('0x39')]){_0x1dc786[_0xb2b8('0x3a')]=[{'all':!![]}];}return db[_0xb2b8('0x25')][_0xb2b8('0x3b')](_0x1dc786);})[_0xb2b8('0x20')](function(_0x45686e){_0x18c2bc['rows']=_0x45686e;return _0x18c2bc;})[_0xb2b8('0x20')](respondWithFilteredResult(_0x265e54,_0x1dc786))[_0xb2b8('0x3c')](handleError(_0x265e54,null));};exports[_0xb2b8('0x3d')]=function(_0x5368fa,_0x55936d){var _0x56e5be={'raw':!![],'where':{'id':_0x5368fa[_0xb2b8('0x3e')]['id']}},_0x521bdc={};_0x521bdc['model']=_[_0xb2b8('0x2b')](db[_0xb2b8('0x25')][_0xb2b8('0x26')]);_0x521bdc['query']=_[_0xb2b8('0x2b')](_0x5368fa[_0xb2b8('0x2c')]);_0x521bdc['filters']=_['intersection'](_0x521bdc['model'],_0x521bdc['query']);_0x56e5be[_0xb2b8('0x2d')]=_[_0xb2b8('0x3f')](_0x521bdc[_0xb2b8('0x2a')],qs[_0xb2b8('0x40')](_0x5368fa[_0xb2b8('0x2c')][_0xb2b8('0x40')]));_0x56e5be[_0xb2b8('0x2d')]=_0x56e5be['attributes'][_0xb2b8('0x2e')]?_0x56e5be[_0xb2b8('0x2d')]:_0x521bdc[_0xb2b8('0x2a')];if(_0x5368fa[_0xb2b8('0x2c')][_0xb2b8('0x39')]){_0x56e5be[_0xb2b8('0x3a')]=[{'all':!![]}];}_0x56e5be=_[_0xb2b8('0x36')]({},_0x56e5be,_0x5368fa['options']);return db[_0xb2b8('0x25')][_0xb2b8('0x41')](_0x56e5be)[_0xb2b8('0x20')](handleEntityNotFound(_0x55936d,null))[_0xb2b8('0x20')](respondWithResult(_0x55936d,null))['catch'](handleError(_0x55936d,null));};exports[_0xb2b8('0x42')]=function(_0x4cc2a6,_0x18dd23){return db['MailSubstatus']['create'](_0x4cc2a6[_0xb2b8('0x43')],{})[_0xb2b8('0x20')](respondWithResult(_0x18dd23,0xc9))[_0xb2b8('0x3c')](handleError(_0x18dd23,null));};exports[_0xb2b8('0x1f')]=function(_0x2121c1,_0x5ef464){if(_0x2121c1[_0xb2b8('0x43')]['id']){delete _0x2121c1[_0xb2b8('0x43')]['id'];}return db['MailSubstatus'][_0xb2b8('0x41')]({'where':{'id':_0x2121c1[_0xb2b8('0x3e')]['id']}})['then'](handleEntityNotFound(_0x5ef464,null))[_0xb2b8('0x20')](saveUpdates(_0x2121c1['body'],null))[_0xb2b8('0x20')](respondWithResult(_0x5ef464,null))[_0xb2b8('0x3c')](handleError(_0x5ef464,null));};exports[_0xb2b8('0x44')]=function(_0x979a46,_0xcd3b77){return db[_0xb2b8('0x25')]['find']({'where':{'id':_0x979a46[_0xb2b8('0x3e')]['id']}})[_0xb2b8('0x20')](handleEntityNotFound(_0xcd3b77,null))[_0xb2b8('0x20')](removeEntity(_0xcd3b77,null))[_0xb2b8('0x3c')](handleError(_0xcd3b77,null));};exports['describe']=function(_0x253357,_0x1ea0f7){return db['MailSubstatus'][_0xb2b8('0x45')]()[_0xb2b8('0x20')](respondWithResult(_0x1ea0f7,null))[_0xb2b8('0x3c')](handleError(_0x1ea0f7,null));};