Built motion from commit (unavailable).|2.5.6
[motion2.git] / server / api / faxApplication / faxApplication.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 _0x51f2=['create','body','update','params','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','lodash','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','limit','set','Content-Range','reject','save','then','error','name','send','index','map','FaxApplication','rawAttributes','fieldName','query','keys','filters','intersection','attributes','model','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','type','VIRTUAL','count','include','findAll','rows','catch','show','fields','includeAll','options','find'];(function(_0x134183,_0x42b55a){var _0x124479=function(_0x57fbd1){while(--_0x57fbd1){_0x134183['push'](_0x134183['shift']());}};_0x124479(++_0x42b55a);}(_0x51f2,0xeb));var _0x251f=function(_0x3a0bab,_0x1ec264){_0x3a0bab=_0x3a0bab-0x0;var _0x92fed4=_0x51f2[_0x3a0bab];return _0x92fed4;};'use strict';var pdf=require(_0x251f('0x0'));var emlformat=require(_0x251f('0x1'));var rimraf=require(_0x251f('0x2'));var zipdir=require(_0x251f('0x3'));var jsonpatch=require(_0x251f('0x4'));var rp=require(_0x251f('0x5'));var moment=require(_0x251f('0x6'));var BPromise=require(_0x251f('0x7'));var Mustache=require(_0x251f('0x8'));var util=require('util');var path=require(_0x251f('0x9'));var sox=require(_0x251f('0xa'));var csv=require(_0x251f('0xb'));var ejs=require(_0x251f('0xc'));var fs=require('fs');var _=require(_0x251f('0xd'));var squel=require('squel');var crypto=require(_0x251f('0xe'));var jsforce=require(_0x251f('0xf'));var deskjs=require(_0x251f('0x10'));var toCsv=require(_0x251f('0xb'));var querystring=require('querystring');var Papa=require(_0x251f('0x11'));var Redis=require(_0x251f('0x12'));var authService=require(_0x251f('0x13'));var qs=require(_0x251f('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x251f('0x15'));var logger=require(_0x251f('0x16'))(_0x251f('0x17'));var utils=require(_0x251f('0x18'));var config=require('../../config/environment');var licenseUtil=require(_0x251f('0x19'));var db=require(_0x251f('0x1a'))['db'];function respondWithStatusCode(_0x262da7,_0x1d923a){_0x1d923a=_0x1d923a||0xcc;return function(_0x13802a){if(_0x13802a){return _0x262da7[_0x251f('0x1b')](_0x1d923a);}return _0x262da7[_0x251f('0x1c')](_0x1d923a)[_0x251f('0x1d')]();};}function respondWithResult(_0x3806b1,_0x1de162){_0x1de162=_0x1de162||0xc8;return function(_0x1837d1){if(_0x1837d1){return _0x3806b1['status'](_0x1de162)[_0x251f('0x1e')](_0x1837d1);}};}function respondWithFilteredResult(_0x9d39e3,_0x4e1492){return function(_0x1f6c55){if(_0x1f6c55){var _0x4303e2=_0x1f6c55['count'],_0x2f16d4=_0x4e1492['offset'],_0x190ff3=_0x4e1492[_0x251f('0x1f')]+_0x4e1492[_0x251f('0x20')],_0x9f7fb2;if(_0x190ff3>=_0x4303e2){_0x190ff3=_0x4303e2;_0x9f7fb2=0xc8;}else{_0x9f7fb2=0xce;}_0x9d39e3[_0x251f('0x1c')](_0x9f7fb2);return _0x9d39e3[_0x251f('0x21')](_0x251f('0x22'),_0x2f16d4+'-'+_0x190ff3+'/'+_0x4303e2)['json'](_0x1f6c55);}return null;};}function patchUpdates(_0x21040e){return function(_0x2198a7){try{jsonpatch['apply'](_0x2198a7,_0x21040e,!![]);}catch(_0x509b50){return BPromise[_0x251f('0x23')](_0x509b50);}return _0x2198a7[_0x251f('0x24')]();};}function saveUpdates(_0x63fa24,_0x11df74){return function(_0x35c190){if(_0x35c190){return _0x35c190['update'](_0x63fa24)[_0x251f('0x25')](function(_0x492612){return _0x492612;});}return null;};}function removeEntity(_0x5ac4ba,_0x25d2e8){return function(_0xdd907d){if(_0xdd907d){return _0xdd907d['destroy']()['then'](function(){_0x5ac4ba[_0x251f('0x1c')](0xcc)['end']();});}};}function handleEntityNotFound(_0x5549b0,_0x2da7ad){return function(_0x356d9f){if(!_0x356d9f){_0x5549b0[_0x251f('0x1b')](0x194);}return _0x356d9f;};}function handleError(_0x4efea8,_0x28c6a4){_0x28c6a4=_0x28c6a4||0x1f4;return function(_0x1f770c){logger[_0x251f('0x26')](_0x1f770c['stack']);if(_0x1f770c[_0x251f('0x27')]){delete _0x1f770c[_0x251f('0x27')];}_0x4efea8[_0x251f('0x1c')](_0x28c6a4)[_0x251f('0x28')](_0x1f770c);};}exports[_0x251f('0x29')]=function(_0x2842ed,_0x42a442){var _0xcbd067={},_0x34235c={},_0x5aa987={'count':0x0,'rows':[]};var _0x2d2054=_[_0x251f('0x2a')](db[_0x251f('0x2b')][_0x251f('0x2c')],function(_0x24032){return{'name':_0x24032[_0x251f('0x2d')],'type':_0x24032['type']['key']};});_0x34235c['model']=_[_0x251f('0x2a')](_0x2d2054,_0x251f('0x27'));_0x34235c[_0x251f('0x2e')]=_[_0x251f('0x2f')](_0x2842ed['query']);_0x34235c[_0x251f('0x30')]=_[_0x251f('0x31')](_0x34235c['model'],_0x34235c[_0x251f('0x2e')]);_0xcbd067[_0x251f('0x32')]=_['intersection'](_0x34235c[_0x251f('0x33')],qs['fields'](_0x2842ed[_0x251f('0x2e')]['fields']));_0xcbd067[_0x251f('0x32')]=_0xcbd067[_0x251f('0x32')][_0x251f('0x34')]?_0xcbd067[_0x251f('0x32')]:_0x34235c[_0x251f('0x33')];if(!_0x2842ed[_0x251f('0x2e')][_0x251f('0x35')](_0x251f('0x36'))){_0xcbd067[_0x251f('0x20')]=qs['limit'](_0x2842ed[_0x251f('0x2e')][_0x251f('0x20')]);_0xcbd067[_0x251f('0x1f')]=qs[_0x251f('0x1f')](_0x2842ed['query'][_0x251f('0x1f')]);}_0xcbd067[_0x251f('0x37')]=qs[_0x251f('0x38')](_0x2842ed[_0x251f('0x2e')][_0x251f('0x38')]);_0xcbd067[_0x251f('0x39')]=qs['filters'](_[_0x251f('0x3a')](_0x2842ed[_0x251f('0x2e')],_0x34235c[_0x251f('0x30')]),_0x2d2054);if(_0x2842ed['query'][_0x251f('0x3b')]){_0xcbd067['where']=_[_0x251f('0x3c')](_0xcbd067[_0x251f('0x39')],{'$or':_['map'](_0x2d2054,function(_0x3c3716){if(_0x3c3716[_0x251f('0x3d')]!==_0x251f('0x3e')){var _0x224efa={};_0x224efa[_0x3c3716['name']]={'$like':'%'+_0x2842ed[_0x251f('0x2e')][_0x251f('0x3b')]+'%'};return _0x224efa;}})});}_0xcbd067=_['merge']({},_0xcbd067,_0x2842ed['options']);var _0x55236a={'where':_0xcbd067['where']};return db[_0x251f('0x2b')][_0x251f('0x3f')](_0x55236a)[_0x251f('0x25')](function(_0x288dd5){_0x5aa987[_0x251f('0x3f')]=_0x288dd5;if(_0x2842ed[_0x251f('0x2e')]['includeAll']){_0xcbd067[_0x251f('0x40')]=[{'all':!![]}];}return db['FaxApplication'][_0x251f('0x41')](_0xcbd067);})['then'](function(_0xcecd69){_0x5aa987[_0x251f('0x42')]=_0xcecd69;return _0x5aa987;})[_0x251f('0x25')](respondWithFilteredResult(_0x42a442,_0xcbd067))[_0x251f('0x43')](handleError(_0x42a442,null));};exports[_0x251f('0x44')]=function(_0x505775,_0x35b25e){var _0x205e0a={'raw':!![],'where':{'id':_0x505775['params']['id']}},_0x46a813={};_0x46a813['model']=_[_0x251f('0x2f')](db[_0x251f('0x2b')]['rawAttributes']);_0x46a813[_0x251f('0x2e')]=_['keys'](_0x505775[_0x251f('0x2e')]);_0x46a813['filters']=_[_0x251f('0x31')](_0x46a813[_0x251f('0x33')],_0x46a813[_0x251f('0x2e')]);_0x205e0a[_0x251f('0x32')]=_['intersection'](_0x46a813['model'],qs[_0x251f('0x45')](_0x505775[_0x251f('0x2e')]['fields']));_0x205e0a[_0x251f('0x32')]=_0x205e0a[_0x251f('0x32')]['length']?_0x205e0a[_0x251f('0x32')]:_0x46a813[_0x251f('0x33')];if(_0x505775[_0x251f('0x2e')][_0x251f('0x46')]){_0x205e0a[_0x251f('0x40')]=[{'all':!![]}];}_0x205e0a=_[_0x251f('0x3c')]({},_0x205e0a,_0x505775[_0x251f('0x47')]);return db[_0x251f('0x2b')][_0x251f('0x48')](_0x205e0a)[_0x251f('0x25')](handleEntityNotFound(_0x35b25e,null))['then'](respondWithResult(_0x35b25e,null))[_0x251f('0x43')](handleError(_0x35b25e,null));};exports[_0x251f('0x49')]=function(_0x15ef4e,_0x178496){return db[_0x251f('0x2b')][_0x251f('0x49')](_0x15ef4e[_0x251f('0x4a')],{})[_0x251f('0x25')](respondWithResult(_0x178496,0xc9))['catch'](handleError(_0x178496,null));};exports[_0x251f('0x4b')]=function(_0x1572c1,_0x39475b){if(_0x1572c1[_0x251f('0x4a')]['id']){delete _0x1572c1[_0x251f('0x4a')]['id'];}return db[_0x251f('0x2b')]['find']({'where':{'id':_0x1572c1[_0x251f('0x4c')]['id']}})[_0x251f('0x25')](handleEntityNotFound(_0x39475b,null))[_0x251f('0x25')](saveUpdates(_0x1572c1[_0x251f('0x4a')],null))[_0x251f('0x25')](respondWithResult(_0x39475b,null))[_0x251f('0x43')](handleError(_0x39475b,null));};exports['destroy']=function(_0x2ca5b0,_0x2a9706){return db[_0x251f('0x2b')][_0x251f('0x48')]({'where':{'id':_0x2ca5b0['params']['id']}})[_0x251f('0x25')](handleEntityNotFound(_0x2a9706,null))[_0x251f('0x25')](removeEntity(_0x2a9706,null))[_0x251f('0x43')](handleError(_0x2a9706,null));};