Built motion from commit (unavailable).|2.5.4
[motion2.git] / server / api / mailApplication / mailApplication.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 _0xbf0e=['send','params','keys','MailApplication','rawAttributes','query','filters','intersection','attributes','model','fields','length','include','options','find','catch','update','body','html-pdf','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','to-csv','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','sendStatus','status','end','json','offset','limit','set','Content-Range','apply','reject','save','then','destroy','error','stack','name'];(function(_0x4ed2c1,_0x8c9475){var _0x397295=function(_0x120012){while(--_0x120012){_0x4ed2c1['push'](_0x4ed2c1['shift']());}};_0x397295(++_0x8c9475);}(_0xbf0e,0x16e));var _0xebf0=function(_0x9331c2,_0x18050b){_0x9331c2=_0x9331c2-0x0;var _0x24ca58=_0xbf0e[_0x9331c2];return _0x24ca58;};'use strict';var pdf=require(_0xebf0('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xebf0('0x1'));var zipdir=require(_0xebf0('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xebf0('0x3'));var moment=require(_0xebf0('0x4'));var BPromise=require(_0xebf0('0x5'));var Mustache=require(_0xebf0('0x6'));var util=require(_0xebf0('0x7'));var path=require(_0xebf0('0x8'));var sox=require('sox');var csv=require(_0xebf0('0x9'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require(_0xebf0('0xa'));var crypto=require(_0xebf0('0xb'));var jsforce=require(_0xebf0('0xc'));var deskjs=require(_0xebf0('0xd'));var toCsv=require('to-csv');var querystring=require(_0xebf0('0xe'));var Papa=require(_0xebf0('0xf'));var Redis=require(_0xebf0('0x10'));var authService=require('../../components/auth/service');var qs=require(_0xebf0('0x11'));var as=require(_0xebf0('0x12'));var hardwareService=require(_0xebf0('0x13'));var logger=require(_0xebf0('0x14'))(_0xebf0('0x15'));var utils=require(_0xebf0('0x16'));var config=require('../../config/environment');var db=require(_0xebf0('0x17'))['db'];function respondWithStatusCode(_0x584535,_0x183073){_0x183073=_0x183073||0xcc;return function(_0x5d4d92){if(_0x5d4d92){return _0x584535[_0xebf0('0x18')](_0x183073);}return _0x584535[_0xebf0('0x19')](_0x183073)[_0xebf0('0x1a')]();};}function respondWithResult(_0x791427,_0x26c10b){_0x26c10b=_0x26c10b||0xc8;return function(_0x1323d5){if(_0x1323d5){return _0x791427['status'](_0x26c10b)[_0xebf0('0x1b')](_0x1323d5);}};}function respondWithFilteredResult(_0x180ce2,_0xb2be3a){return function(_0x45b785){if(_0x45b785){var _0x19d772=_0x45b785['count'],_0x36387e=_0xb2be3a[_0xebf0('0x1c')],_0x2a4ee7=_0xb2be3a['offset']+_0xb2be3a[_0xebf0('0x1d')],_0x22a605;if(_0x2a4ee7>=_0x19d772){_0x2a4ee7=_0x19d772;_0x22a605=0xc8;}else{_0x22a605=0xce;}_0x180ce2[_0xebf0('0x19')](_0x22a605);return _0x180ce2[_0xebf0('0x1e')](_0xebf0('0x1f'),_0x36387e+'-'+_0x2a4ee7+'/'+_0x19d772)[_0xebf0('0x1b')](_0x45b785);}return null;};}function patchUpdates(_0x5dec11){return function(_0x49246b){try{jsonpatch[_0xebf0('0x20')](_0x49246b,_0x5dec11,!![]);}catch(_0x759ac5){return BPromise[_0xebf0('0x21')](_0x759ac5);}return _0x49246b[_0xebf0('0x22')]();};}function saveUpdates(_0x2e80e6,_0x3d3eba){return function(_0x239373){if(_0x239373){return _0x239373['update'](_0x2e80e6)[_0xebf0('0x23')](function(_0x5bd171){return _0x5bd171;});}return null;};}function removeEntity(_0x301898,_0x5da27f){return function(_0x317e9c){if(_0x317e9c){return _0x317e9c[_0xebf0('0x24')]()[_0xebf0('0x23')](function(){_0x301898['status'](0xcc)[_0xebf0('0x1a')]();});}};}function handleEntityNotFound(_0x4bafca,_0x35aeeb){return function(_0xf59924){if(!_0xf59924){_0x4bafca[_0xebf0('0x18')](0x194);}return _0xf59924;};}function handleError(_0x2e8e8d,_0x49425f){_0x49425f=_0x49425f||0x1f4;return function(_0x309149){logger[_0xebf0('0x25')](_0x309149[_0xebf0('0x26')]);if(_0x309149[_0xebf0('0x27')]){delete _0x309149[_0xebf0('0x27')];}_0x2e8e8d['status'](_0x49425f)[_0xebf0('0x28')](_0x309149);};}exports['show']=function(_0x40b575,_0x3feb18){var _0x411f41={'raw':!![],'where':{'id':_0x40b575[_0xebf0('0x29')]['id']}},_0x408462={};_0x408462['model']=_[_0xebf0('0x2a')](db[_0xebf0('0x2b')][_0xebf0('0x2c')]);_0x408462[_0xebf0('0x2d')]=_['keys'](_0x40b575[_0xebf0('0x2d')]);_0x408462[_0xebf0('0x2e')]=_[_0xebf0('0x2f')](_0x408462['model'],_0x408462[_0xebf0('0x2d')]);_0x411f41[_0xebf0('0x30')]=_[_0xebf0('0x2f')](_0x408462[_0xebf0('0x31')],qs[_0xebf0('0x32')](_0x40b575[_0xebf0('0x2d')]['fields']));_0x411f41[_0xebf0('0x30')]=_0x411f41[_0xebf0('0x30')][_0xebf0('0x33')]?_0x411f41['attributes']:_0x408462[_0xebf0('0x31')];if(_0x40b575['query']['includeAll']){_0x411f41[_0xebf0('0x34')]=[{'all':!![]}];}_0x411f41=_['merge']({},_0x411f41,_0x40b575[_0xebf0('0x35')]);return db['MailApplication'][_0xebf0('0x36')](_0x411f41)[_0xebf0('0x23')](handleEntityNotFound(_0x3feb18,null))[_0xebf0('0x23')](respondWithResult(_0x3feb18,null))[_0xebf0('0x37')](handleError(_0x3feb18,null));};exports[_0xebf0('0x38')]=function(_0x356436,_0x129192){if(_0x356436[_0xebf0('0x39')]['id']){delete _0x356436[_0xebf0('0x39')]['id'];}return db[_0xebf0('0x2b')]['find']({'where':{'id':_0x356436[_0xebf0('0x29')]['id']}})[_0xebf0('0x23')](handleEntityNotFound(_0x129192,null))['then'](saveUpdates(_0x356436[_0xebf0('0x39')],null))[_0xebf0('0x23')](respondWithResult(_0x129192,null))['catch'](handleError(_0x129192,null));};exports[_0xebf0('0x24')]=function(_0x5dc08f,_0x2b1e5b){return db[_0xebf0('0x2b')][_0xebf0('0x36')]({'where':{'id':_0x5dc08f[_0xebf0('0x29')]['id']}})[_0xebf0('0x23')](handleEntityNotFound(_0x2b1e5b,null))[_0xebf0('0x23')](removeEntity(_0x2b1e5b,null))[_0xebf0('0x37')](handleError(_0x2b1e5b,null));};