Built motion from commit ab065936.|2.0.51
[motion2.git] / server / api / mailServerOut / mailServerOut.controller.js
1 var _0x7a6e=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x66\x61\x73\x74\x2D\x6A\x73\x6F\x6E\x2D\x70\x61\x74\x63\x68","\x72\x65\x71\x75\x65\x73\x74\x2D\x70\x72\x6F\x6D\x69\x73\x65","\x6D\x6F\x6D\x65\x6E\x74","\x62\x6C\x75\x65\x62\x69\x72\x64","\x6D\x75\x73\x74\x61\x63\x68\x65","\x75\x74\x69\x6C","\x70\x61\x74\x68","\x73\x6F\x78","\x74\x6F\x2D\x63\x73\x76","\x65\x6A\x73","\x66\x73","\x6C\x6F\x64\x61\x73\x68","\x73\x71\x75\x65\x6C","\x63\x72\x79\x70\x74\x6F","\x6A\x73\x66\x6F\x72\x63\x65","\x64\x65\x73\x6B\x2E\x6A\x73","\x71\x75\x65\x72\x79\x73\x74\x72\x69\x6E\x67","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6D\x70\x6F\x6E\x65\x6E\x74\x73\x2F\x70\x61\x72\x73\x65\x72\x73\x2F\x71\x73","\x61\x70\x69","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x6C\x6F\x67\x67\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x75\x74\x69\x6C\x73","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x64\x62","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x79\x73\x71\x6C\x64\x62","\x4D\x61\x69\x6C\x53\x65\x72\x76\x65\x72\x4F\x75\x74\x2C\x20\x25\x73\x2C\x20\x25\x73\x2C\x20\x25\x73","\x6E\x6F\x20\x63\x6F\x6E\x74\x65\x6E\x74","\x69\x6E\x66\x6F","\x4D\x61\x69\x6C\x53\x65\x72\x76\x65\x72\x4F\x75\x74\x2C\x20\x25\x73\x2C\x20\x25\x73\x2C\x20\x25\x73\x2C\x20\x25\x73","\x64\x65\x62\x75\x67","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x65\x6E\x74\x69\x74\x79\x20\x66\x6F\x75\x6E\x64","\x73\x74\x72\x69\x6E\x67\x69\x66\x79","\x6A\x73\x6F\x6E","\x63\x6F\x75\x6E\x74","\x6F\x66\x66\x73\x65\x74","\x6C\x69\x6D\x69\x74","\x65\x6E\x74\x69\x74\x69\x65\x73\x20\x66\x6F\x75\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x52\x61\x6E\x67\x65","\x2D","\x2F","\x73\x65\x74","\x61\x70\x70\x6C\x79","\x72\x65\x6A\x65\x63\x74","\x73\x61\x76\x65","\x65\x6E\x74\x69\x74\x79\x20\x75\x70\x64\x61\x74\x65\x64","\x74\x68\x65\x6E","\x75\x70\x64\x61\x74\x65","\x65\x6E\x74\x69\x74\x79\x20\x72\x65\x6D\x6F\x76\x65\x64","\x64\x65\x73\x74\x72\x6F\x79","\x65\x6E\x74\x69\x74\x79\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64","\x65\x72\x72\x6F\x72","\x69\x6E\x73\x70\x65\x63\x74","\x6E\x61\x6D\x65","\x73\x65\x6E\x64","\x69\x6E\x64\x65\x78","\x6D\x6F\x64\x65\x6C","\x72\x61\x77\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x4D\x61\x69\x6C\x53\x65\x72\x76\x65\x72\x4F\x75\x74","\x6B\x65\x79\x73","\x64\x61\x74\x65\x53\x74\x61\x72\x74","\x71\x75\x65\x72\x79","\x64\x61\x74\x65\x45\x6E\x64","\x66\x69\x6C\x74\x65\x72\x73","\x69\x6E\x74\x65\x72\x73\x65\x63\x74\x69\x6F\x6E","\x61\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x66\x69\x65\x6C\x64\x73","\x6C\x65\x6E\x67\x74\x68","\x6E\x6F\x6C\x69\x6D\x69\x74","\x68\x61\x73\x4F\x77\x6E\x50\x72\x6F\x70\x65\x72\x74\x79","\x6F\x72\x64\x65\x72","\x73\x6F\x72\x74","\x77\x68\x65\x72\x65","\x70\x69\x63\x6B","\x64\x61\x79","\x61\x64\x64","\x6D\x65\x72\x67\x65","\x66\x69\x6C\x74\x65\x72","\x25","\x6D\x61\x70","\x6F\x70\x74\x69\x6F\x6E\x73","\x63\x61\x74\x63\x68","\x72\x6F\x77\x73","\x69\x6E\x63\x6C\x75\x64\x65\x41\x6C\x6C","\x69\x6E\x63\x6C\x75\x64\x65","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79"];_0x7a6e[0];var jsonpatch=require(_0x7a6e[1]);var rp=require(_0x7a6e[2]);var moment=require(_0x7a6e[3]);var BPromise=require(_0x7a6e[4]);var Mustache=require(_0x7a6e[5]);var util=require(_0x7a6e[6]);var path=require(_0x7a6e[7]);var sox=require(_0x7a6e[8]);var csv=require(_0x7a6e[9]);var ejs=require(_0x7a6e[10]);var fs=require(_0x7a6e[11]);var _=require(_0x7a6e[12]);var squel=require(_0x7a6e[13]);var crypto=require(_0x7a6e[14]);var jsforce=require(_0x7a6e[15]);var deskjs=require(_0x7a6e[16]);var toCsv=require(_0x7a6e[9]);var querystring=require(_0x7a6e[17]);var qs=require(_0x7a6e[18]);var logger=require(_0x7a6e[20])(_0x7a6e[19]);var utils=require(_0x7a6e[21]);var config=require(_0x7a6e[22]);var db=require(_0x7a6e[24])[_0x7a6e[23]];function respondWithStatusCode(_0x6f01x19,_0x6f01x1a,_0x6f01x1b){_0x6f01x1a= _0x6f01x1a|| 204;return function(_0x6f01x1c){if(_0x6f01x1c){logger[_0x7a6e[27]](_0x7a6e[25],_0x6f01x1b,_0x6f01x1a,_0x7a6e[26]);logger[_0x7a6e[29]](_0x7a6e[28],_0x6f01x1b,_0x6f01x1a,_0x7a6e[26]);return _0x6f01x19[_0x7a6e[30]](_0x6f01x1a)};return _0x6f01x19[_0x7a6e[32]](_0x6f01x1a)[_0x7a6e[31]]()}}function respondWithResult(_0x6f01x19,_0x6f01x1a,_0x6f01x1b){_0x6f01x1a= _0x6f01x1a|| 200;return function(_0x6f01x1c){if(_0x6f01x1c){logger[_0x7a6e[27]](_0x7a6e[25],_0x6f01x1b,_0x6f01x1a,_0x7a6e[33]);logger[_0x7a6e[29]](_0x7a6e[28],_0x6f01x1b,_0x6f01x1a,_0x7a6e[33],JSON[_0x7a6e[34]](_0x6f01x1c));return _0x6f01x19[_0x7a6e[32]](_0x6f01x1a)[_0x7a6e[35]](_0x6f01x1c)}}}function respondWithFilteredResult(_0x6f01x19,_0x6f01x1f,_0x6f01x1b){return function(_0x6f01x1c){if(_0x6f01x1c){var _0x6f01x20=_0x6f01x1c[_0x7a6e[36]],_0x6f01x21=_0x6f01x1f[_0x7a6e[37]],_0x6f01x22=_0x6f01x1f[_0x7a6e[37]]+ _0x6f01x1f[_0x7a6e[38]],_0x6f01x1a;if(_0x6f01x22>= _0x6f01x20){_0x6f01x22= _0x6f01x20;_0x6f01x1a= 200}else {_0x6f01x1a= 206};_0x6f01x19[_0x7a6e[32]](_0x6f01x1a);logger[_0x7a6e[27]](_0x7a6e[25],_0x6f01x1b,_0x6f01x1a,_0x7a6e[39]);logger[_0x7a6e[29]](_0x7a6e[28],_0x6f01x1b,_0x6f01x1a,_0x7a6e[33],JSON[_0x7a6e[34]](_0x6f01x1c));return _0x6f01x19[_0x7a6e[43]](_0x7a6e[40],_0x6f01x21+ _0x7a6e[41]+ _0x6f01x22+ _0x7a6e[42]+ _0x6f01x20)[_0x7a6e[35]](_0x6f01x1c)};return null}}function patchUpdates(_0x6f01x24){return function(_0x6f01x1c){try{jsonpatch[_0x7a6e[44]](_0x6f01x1c,_0x6f01x24,true)}catch(err){return BPromise[_0x7a6e[45]](err)};return _0x6f01x1c[_0x7a6e[46]]()}}function saveUpdates(_0x6f01x26,_0x6f01x1a,_0x6f01x1b){return function(_0x6f01x1c){if(_0x6f01x1c){return _0x6f01x1c[_0x7a6e[49]](_0x6f01x26)[_0x7a6e[48]](function(_0x6f01x27){logger[_0x7a6e[27]](_0x7a6e[25],_0x6f01x1b,_0x6f01x1a,_0x7a6e[47]);logger[_0x7a6e[29]](_0x7a6e[28],_0x6f01x1b,_0x6f01x1a,_0x7a6e[47],JSON[_0x7a6e[34]](_0x6f01x1c));return _0x6f01x27})};return null}}function removeEntity(_0x6f01x19,_0x6f01x1a,_0x6f01x1b){return function(_0x6f01x1c){if(_0x6f01x1c){return _0x6f01x1c[_0x7a6e[51]]()[_0x7a6e[48]](function(){logger[_0x7a6e[27]](_0x7a6e[25],_0x6f01x1b,_0x6f01x1a,_0x7a6e[50]);logger[_0x7a6e[29]](_0x7a6e[28],_0x6f01x1b,_0x6f01x1a,_0x7a6e[50],JSON[_0x7a6e[34]](_0x6f01x1c));_0x6f01x19[_0x7a6e[32]](204)[_0x7a6e[31]]()})}}}function handleEntityNotFound(_0x6f01x19,_0x6f01x1a,_0x6f01x1b){return function(_0x6f01x1c){if(!_0x6f01x1c){logger[_0x7a6e[53]](_0x7a6e[25],_0x6f01x1b,404,_0x7a6e[52]);_0x6f01x19[_0x7a6e[30]](404)};return _0x6f01x1c}}function handleError(_0x6f01x19,_0x6f01x1a,_0x6f01x1b){_0x6f01x1a= _0x6f01x1a|| 500;return function(_0x6f01x2b){logger[_0x7a6e[53]](_0x7a6e[25],_0x6f01x1b,_0x6f01x1a,util[_0x7a6e[54]](_0x6f01x2b,{showHidden:false,depth:null}));delete _0x6f01x2b[_0x7a6e[55]];_0x6f01x19[_0x7a6e[32]](_0x6f01x1a)[_0x7a6e[56]](_0x6f01x2b)}}exports[_0x7a6e[57]]= function(_0x6f01x2c,_0x6f01x19){var _0x6f01x1f={},_0x6f01x2d={},_0x6f01x2e={count:0,rows:[]};_0x6f01x2d[_0x7a6e[58]]= _[_0x7a6e[61]](db[_0x7a6e[60]][_0x7a6e[59]]);var _0x6f01x2f={dateStart:_0x6f01x2c[_0x7a6e[63]][_0x7a6e[62]],dateEnd:_0x6f01x2c[_0x7a6e[63]][_0x7a6e[64]]};delete _0x6f01x2c[_0x7a6e[63]][_0x7a6e[62]];delete _0x6f01x2c[_0x7a6e[63]][_0x7a6e[64]];_0x6f01x2d[_0x7a6e[63]]= _[_0x7a6e[61]](_0x6f01x2c[_0x7a6e[63]]);_0x6f01x2d[_0x7a6e[65]]= _[_0x7a6e[66]](_0x6f01x2d[_0x7a6e[58]],_0x6f01x2d[_0x7a6e[63]]);_0x6f01x1f[_0x7a6e[67]]= _[_0x7a6e[66]](_0x6f01x2d[_0x7a6e[58]],qs[_0x7a6e[68]](_0x6f01x2c[_0x7a6e[63]][_0x7a6e[68]]));_0x6f01x1f[_0x7a6e[67]]= (_0x6f01x1f[_0x7a6e[67]][_0x7a6e[69]])?_0x6f01x1f[_0x7a6e[67]]:_0x6f01x2d[_0x7a6e[58]];if(!_0x6f01x2c[_0x7a6e[63]][_0x7a6e[71]](_0x7a6e[70])){_0x6f01x1f[_0x7a6e[38]]= qs[_0x7a6e[38]](_0x6f01x2c[_0x7a6e[63]][_0x7a6e[38]]);_0x6f01x1f[_0x7a6e[37]]= qs[_0x7a6e[37]](_0x6f01x2c[_0x7a6e[63]][_0x7a6e[37]])};_0x6f01x1f[_0x7a6e[72]]= qs[_0x7a6e[73]](_0x6f01x2c[_0x7a6e[63]][_0x7a6e[73]]);_0x6f01x1f[_0x7a6e[74]]= qs[_0x7a6e[65]](_[_0x7a6e[75]](_0x6f01x2c[_0x7a6e[63]],_0x6f01x2d[_0x7a6e[65]]));if(_0x6f01x2f[_0x7a6e[62]]){if(_0x6f01x2f[_0x7a6e[64]]){_0x6f01x2f[_0x7a6e[64]]= moment(_0x6f01x2f[_0x7a6e[64]])[_0x7a6e[77]](1,_0x7a6e[76])}else {_0x6f01x2f[_0x7a6e[64]]= moment(_0x6f01x2f[_0x7a6e[62]])[_0x7a6e[77]](1,_0x7a6e[76])};_[_0x7a6e[78]](_0x6f01x1f[_0x7a6e[74]],{createdAt:{$gte:_0x6f01x2f[_0x7a6e[62]],$lte:_0x6f01x2f[_0x7a6e[64]]}})};if(_0x6f01x2c[_0x7a6e[63]][_0x7a6e[79]]){_0x6f01x1f[_0x7a6e[74]]= _[_0x7a6e[78]](_0x6f01x1f[_0x7a6e[74]],{$or:_[_0x7a6e[81]](_0x6f01x1f[_0x7a6e[67]],function(_0x6f01x30){var _0x6f01x2e={};_0x6f01x2e[_0x6f01x30]= {$like:_0x7a6e[80]+ _0x6f01x2c[_0x7a6e[63]][_0x7a6e[79]]+ _0x7a6e[80]};return _0x6f01x2e})})};_0x6f01x1f= _[_0x7a6e[78]]({},_0x6f01x1f,_0x6f01x2c[_0x7a6e[82]]);return db[_0x7a6e[60]][_0x7a6e[36]]({where:_0x6f01x1f[_0x7a6e[74]]})[_0x7a6e[48]](function(_0x6f01x20){_0x6f01x2e[_0x7a6e[36]]= _0x6f01x20;if(_0x6f01x2c[_0x7a6e[63]][_0x7a6e[85]]){_0x6f01x1f[_0x7a6e[86]]= [{all:true}]};return db[_0x7a6e[60]][_0x7a6e[87]](_0x6f01x1f)})[_0x7a6e[48]](function(_0x6f01x31){_0x6f01x2e[_0x7a6e[84]]= _0x6f01x31;return _0x6f01x2e})[_0x7a6e[48]](respondWithFilteredResult(_0x6f01x19,_0x6f01x1f,_0x7a6e[57]))[_0x7a6e[83]](handleError(_0x6f01x19,null,_0x7a6e[57]))};exports[_0x7a6e[88]]= function(_0x6f01x2c,_0x6f01x19){var _0x6f01x1f={raw:true,where:{id:_0x6f01x2c[_0x7a6e[90]][_0x7a6e[89]]}},_0x6f01x2d={};_0x6f01x2d[_0x7a6e[58]]= _[_0x7a6e[61]](db[_0x7a6e[60]][_0x7a6e[59]]);_0x6f01x2d[_0x7a6e[63]]= _[_0x7a6e[61]](_0x6f01x2c[_0x7a6e[63]]);_0x6f01x2d[_0x7a6e[65]]= _[_0x7a6e[66]](_0x6f01x2d[_0x7a6e[58]],_0x6f01x2d[_0x7a6e[63]]);_0x6f01x1f[_0x7a6e[67]]= _[_0x7a6e[66]](_0x6f01x2d[_0x7a6e[58]],qs[_0x7a6e[68]](_0x6f01x2c[_0x7a6e[63]][_0x7a6e[68]]));_0x6f01x1f[_0x7a6e[67]]= (_0x6f01x1f[_0x7a6e[67]][_0x7a6e[69]])?_0x6f01x1f[_0x7a6e[67]]:_0x6f01x2d[_0x7a6e[58]];if(_0x6f01x2c[_0x7a6e[63]][_0x7a6e[85]]){_0x6f01x1f[_0x7a6e[86]]= [{all:true}]};_0x6f01x1f= _[_0x7a6e[78]]({},_0x6f01x1f,_0x6f01x2c[_0x7a6e[82]]);return db[_0x7a6e[60]][_0x7a6e[91]](_0x6f01x1f)[_0x7a6e[48]](handleEntityNotFound(_0x6f01x19,null,_0x7a6e[88]))[_0x7a6e[48]](respondWithResult(_0x6f01x19,null,_0x7a6e[88]))[_0x7a6e[83]](handleError(_0x6f01x19,null,_0x7a6e[88]))};exports[_0x7a6e[92]]= function(_0x6f01x2c,_0x6f01x19){return db[_0x7a6e[60]][_0x7a6e[92]](_0x6f01x2c[_0x7a6e[93]],{})[_0x7a6e[48]](respondWithResult(_0x6f01x19,201,_0x7a6e[92]))[_0x7a6e[83]](handleError(_0x6f01x19,null,_0x7a6e[92]))};exports[_0x7a6e[49]]= function(_0x6f01x2c,_0x6f01x19){if(_0x6f01x2c[_0x7a6e[93]][_0x7a6e[89]]){delete _0x6f01x2c[_0x7a6e[93]][_0x7a6e[89]]};return db[_0x7a6e[60]][_0x7a6e[91]]({where:{id:_0x6f01x2c[_0x7a6e[90]][_0x7a6e[89]]}})[_0x7a6e[48]](handleEntityNotFound(_0x6f01x19,null,_0x7a6e[49]))[_0x7a6e[48]](saveUpdates(_0x6f01x2c[_0x7a6e[93]],null,_0x7a6e[49]))[_0x7a6e[48]](respondWithResult(_0x6f01x19,null,_0x7a6e[49]))[_0x7a6e[83]](handleError(_0x6f01x19,null,_0x7a6e[49]))};exports[_0x7a6e[51]]= function(_0x6f01x2c,_0x6f01x19){return db[_0x7a6e[60]][_0x7a6e[91]]({where:{id:_0x6f01x2c[_0x7a6e[90]][_0x7a6e[89]]}})[_0x7a6e[48]](handleEntityNotFound(_0x6f01x19,null,_0x7a6e[51]))[_0x7a6e[48]](removeEntity(_0x6f01x19,null,_0x7a6e[51]))[_0x7a6e[83]](handleError(_0x6f01x19,null,_0x7a6e[51]))}