Built motion from commit 67e5df37.|2.0.60
[motion2.git] / server / api / mailSubstatus / mailSubstatus.controller.js
1 var _0x1cff=["\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","\x70\x61\x70\x61\x70\x61\x72\x73\x65","\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","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x6A\x73\x6F\x6E","\x63\x6F\x75\x6E\x74","\x6F\x66\x66\x73\x65\x74","\x6C\x69\x6D\x69\x74","\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","\x74\x68\x65\x6E","\x75\x70\x64\x61\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x73\x74\x61\x63\x6B","\x65\x72\x72\x6F\x72","\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\x75\x62\x73\x74\x61\x74\x75\x73","\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","\x64\x65\x73\x63\x72\x69\x62\x65"];_0x1cff[0];var jsonpatch=require(_0x1cff[1]);var rp=require(_0x1cff[2]);var moment=require(_0x1cff[3]);var BPromise=require(_0x1cff[4]);var Mustache=require(_0x1cff[5]);var util=require(_0x1cff[6]);var path=require(_0x1cff[7]);var sox=require(_0x1cff[8]);var csv=require(_0x1cff[9]);var ejs=require(_0x1cff[10]);var fs=require(_0x1cff[11]);var _=require(_0x1cff[12]);var squel=require(_0x1cff[13]);var crypto=require(_0x1cff[14]);var jsforce=require(_0x1cff[15]);var deskjs=require(_0x1cff[16]);var toCsv=require(_0x1cff[9]);var querystring=require(_0x1cff[17]);var Papa=require(_0x1cff[18]);var qs=require(_0x1cff[19]);var logger=require(_0x1cff[21])(_0x1cff[20]);var utils=require(_0x1cff[22]);var config=require(_0x1cff[23]);var db=require(_0x1cff[25])[_0x1cff[24]];function respondWithStatusCode(_0xdcc5x1a,_0xdcc5x1b){_0xdcc5x1b= _0xdcc5x1b|| 204;return function(_0xdcc5x1c){if(_0xdcc5x1c){return _0xdcc5x1a[_0x1cff[26]](_0xdcc5x1b)};return _0xdcc5x1a[_0x1cff[28]](_0xdcc5x1b)[_0x1cff[27]]()}}function respondWithResult(_0xdcc5x1a,_0xdcc5x1b){_0xdcc5x1b= _0xdcc5x1b|| 200;return function(_0xdcc5x1c){if(_0xdcc5x1c){return _0xdcc5x1a[_0x1cff[28]](_0xdcc5x1b)[_0x1cff[29]](_0xdcc5x1c)}}}function respondWithFilteredResult(_0xdcc5x1a,_0xdcc5x1f){return function(_0xdcc5x1c){if(_0xdcc5x1c){var _0xdcc5x20=_0xdcc5x1c[_0x1cff[30]],_0xdcc5x21=_0xdcc5x1f[_0x1cff[31]],_0xdcc5x22=_0xdcc5x1f[_0x1cff[31]]+ _0xdcc5x1f[_0x1cff[32]],_0xdcc5x1b;if(_0xdcc5x22>= _0xdcc5x20){_0xdcc5x22= _0xdcc5x20;_0xdcc5x1b= 200}else {_0xdcc5x1b= 206};_0xdcc5x1a[_0x1cff[28]](_0xdcc5x1b);return _0xdcc5x1a[_0x1cff[36]](_0x1cff[33],_0xdcc5x21+ _0x1cff[34]+ _0xdcc5x22+ _0x1cff[35]+ _0xdcc5x20)[_0x1cff[29]](_0xdcc5x1c)};return null}}function patchUpdates(_0xdcc5x24){return function(_0xdcc5x1c){try{jsonpatch[_0x1cff[37]](_0xdcc5x1c,_0xdcc5x24,true)}catch(err){return BPromise[_0x1cff[38]](err)};return _0xdcc5x1c[_0x1cff[39]]()}}function saveUpdates(_0xdcc5x26,_0xdcc5x1b){return function(_0xdcc5x1c){if(_0xdcc5x1c){return _0xdcc5x1c[_0x1cff[41]](_0xdcc5x26)[_0x1cff[40]](function(_0xdcc5x27){return _0xdcc5x27})};return null}}function removeEntity(_0xdcc5x1a,_0xdcc5x1b){return function(_0xdcc5x1c){if(_0xdcc5x1c){return _0xdcc5x1c[_0x1cff[42]]()[_0x1cff[40]](function(){_0xdcc5x1a[_0x1cff[28]](204)[_0x1cff[27]]()})}}}function handleEntityNotFound(_0xdcc5x1a,_0xdcc5x1b){return function(_0xdcc5x1c){if(!_0xdcc5x1c){_0xdcc5x1a[_0x1cff[26]](404)};return _0xdcc5x1c}}function handleError(_0xdcc5x1a,_0xdcc5x1b){_0xdcc5x1b= _0xdcc5x1b|| 500;return function(_0xdcc5x2b){logger[_0x1cff[44]](_0xdcc5x2b[_0x1cff[43]]);if(_0xdcc5x2b[_0x1cff[45]]){delete _0xdcc5x2b[_0x1cff[45]]};_0xdcc5x1a[_0x1cff[28]](_0xdcc5x1b)[_0x1cff[46]](_0xdcc5x2b)}}exports[_0x1cff[47]]= function(_0xdcc5x2c,_0xdcc5x1a){var _0xdcc5x1f={},_0xdcc5x2d={},_0xdcc5x2e={count:0,rows:[]};_0xdcc5x2d[_0x1cff[48]]= _[_0x1cff[51]](db[_0x1cff[50]][_0x1cff[49]]);var _0xdcc5x2f={dateStart:_0xdcc5x2c[_0x1cff[53]][_0x1cff[52]],dateEnd:_0xdcc5x2c[_0x1cff[53]][_0x1cff[54]]};delete _0xdcc5x2c[_0x1cff[53]][_0x1cff[52]];delete _0xdcc5x2c[_0x1cff[53]][_0x1cff[54]];_0xdcc5x2d[_0x1cff[53]]= _[_0x1cff[51]](_0xdcc5x2c[_0x1cff[53]]);_0xdcc5x2d[_0x1cff[55]]= _[_0x1cff[56]](_0xdcc5x2d[_0x1cff[48]],_0xdcc5x2d[_0x1cff[53]]);_0xdcc5x1f[_0x1cff[57]]= _[_0x1cff[56]](_0xdcc5x2d[_0x1cff[48]],qs[_0x1cff[58]](_0xdcc5x2c[_0x1cff[53]][_0x1cff[58]]));_0xdcc5x1f[_0x1cff[57]]= (_0xdcc5x1f[_0x1cff[57]][_0x1cff[59]])?_0xdcc5x1f[_0x1cff[57]]:_0xdcc5x2d[_0x1cff[48]];if(!_0xdcc5x2c[_0x1cff[53]][_0x1cff[61]](_0x1cff[60])){_0xdcc5x1f[_0x1cff[32]]= qs[_0x1cff[32]](_0xdcc5x2c[_0x1cff[53]][_0x1cff[32]]);_0xdcc5x1f[_0x1cff[31]]= qs[_0x1cff[31]](_0xdcc5x2c[_0x1cff[53]][_0x1cff[31]])};_0xdcc5x1f[_0x1cff[62]]= qs[_0x1cff[63]](_0xdcc5x2c[_0x1cff[53]][_0x1cff[63]]);_0xdcc5x1f[_0x1cff[64]]= qs[_0x1cff[55]](_[_0x1cff[65]](_0xdcc5x2c[_0x1cff[53]],_0xdcc5x2d[_0x1cff[55]]));if(_0xdcc5x2f[_0x1cff[52]]){if(_0xdcc5x2f[_0x1cff[54]]){_0xdcc5x2f[_0x1cff[54]]= moment(_0xdcc5x2f[_0x1cff[54]])[_0x1cff[67]](1,_0x1cff[66])}else {_0xdcc5x2f[_0x1cff[54]]= moment(_0xdcc5x2f[_0x1cff[52]])[_0x1cff[67]](1,_0x1cff[66])};_[_0x1cff[68]](_0xdcc5x1f[_0x1cff[64]],{createdAt:{$gte:_0xdcc5x2f[_0x1cff[52]],$lte:_0xdcc5x2f[_0x1cff[54]]}})};if(_0xdcc5x2c[_0x1cff[53]][_0x1cff[69]]){_0xdcc5x1f[_0x1cff[64]]= _[_0x1cff[68]](_0xdcc5x1f[_0x1cff[64]],{$or:_[_0x1cff[71]](_0xdcc5x1f[_0x1cff[57]],function(_0xdcc5x30){var _0xdcc5x2e={};_0xdcc5x2e[_0xdcc5x30]= {$like:_0x1cff[70]+ _0xdcc5x2c[_0x1cff[53]][_0x1cff[69]]+ _0x1cff[70]};return _0xdcc5x2e})})};_0xdcc5x1f= _[_0x1cff[68]]({},_0xdcc5x1f,_0xdcc5x2c[_0x1cff[72]]);var _0xdcc5x31={where:_0xdcc5x1f[_0x1cff[64]]};return db[_0x1cff[50]][_0x1cff[30]](_0xdcc5x31)[_0x1cff[40]](function(_0xdcc5x20){_0xdcc5x2e[_0x1cff[30]]= _0xdcc5x20;if(_0xdcc5x2c[_0x1cff[53]][_0x1cff[75]]){_0xdcc5x1f[_0x1cff[76]]= [{all:true}]};return db[_0x1cff[50]][_0x1cff[77]](_0xdcc5x1f)})[_0x1cff[40]](function(_0xdcc5x32){_0xdcc5x2e[_0x1cff[74]]= _0xdcc5x32;return _0xdcc5x2e})[_0x1cff[40]](respondWithFilteredResult(_0xdcc5x1a,_0xdcc5x1f))[_0x1cff[73]](handleError(_0xdcc5x1a,null))};exports[_0x1cff[78]]= function(_0xdcc5x2c,_0xdcc5x1a){var _0xdcc5x1f={raw:true,where:{id:_0xdcc5x2c[_0x1cff[80]][_0x1cff[79]]}},_0xdcc5x2d={};_0xdcc5x2d[_0x1cff[48]]= _[_0x1cff[51]](db[_0x1cff[50]][_0x1cff[49]]);_0xdcc5x2d[_0x1cff[53]]= _[_0x1cff[51]](_0xdcc5x2c[_0x1cff[53]]);_0xdcc5x2d[_0x1cff[55]]= _[_0x1cff[56]](_0xdcc5x2d[_0x1cff[48]],_0xdcc5x2d[_0x1cff[53]]);_0xdcc5x1f[_0x1cff[57]]= _[_0x1cff[56]](_0xdcc5x2d[_0x1cff[48]],qs[_0x1cff[58]](_0xdcc5x2c[_0x1cff[53]][_0x1cff[58]]));_0xdcc5x1f[_0x1cff[57]]= (_0xdcc5x1f[_0x1cff[57]][_0x1cff[59]])?_0xdcc5x1f[_0x1cff[57]]:_0xdcc5x2d[_0x1cff[48]];if(_0xdcc5x2c[_0x1cff[53]][_0x1cff[75]]){_0xdcc5x1f[_0x1cff[76]]= [{all:true}]};_0xdcc5x1f= _[_0x1cff[68]]({},_0xdcc5x1f,_0xdcc5x2c[_0x1cff[72]]);return db[_0x1cff[50]][_0x1cff[81]](_0xdcc5x1f)[_0x1cff[40]](handleEntityNotFound(_0xdcc5x1a,null))[_0x1cff[40]](respondWithResult(_0xdcc5x1a,null))[_0x1cff[73]](handleError(_0xdcc5x1a,null))};exports[_0x1cff[82]]= function(_0xdcc5x2c,_0xdcc5x1a){return db[_0x1cff[50]][_0x1cff[82]](_0xdcc5x2c[_0x1cff[83]],{})[_0x1cff[40]](respondWithResult(_0xdcc5x1a,201))[_0x1cff[73]](handleError(_0xdcc5x1a,null))};exports[_0x1cff[41]]= function(_0xdcc5x2c,_0xdcc5x1a){if(_0xdcc5x2c[_0x1cff[83]][_0x1cff[79]]){delete _0xdcc5x2c[_0x1cff[83]][_0x1cff[79]]};return db[_0x1cff[50]][_0x1cff[81]]({where:{id:_0xdcc5x2c[_0x1cff[80]][_0x1cff[79]]}})[_0x1cff[40]](handleEntityNotFound(_0xdcc5x1a,null))[_0x1cff[40]](saveUpdates(_0xdcc5x2c[_0x1cff[83]],null))[_0x1cff[40]](respondWithResult(_0xdcc5x1a,null))[_0x1cff[73]](handleError(_0xdcc5x1a,null))};exports[_0x1cff[42]]= function(_0xdcc5x2c,_0xdcc5x1a){return db[_0x1cff[50]][_0x1cff[81]]({where:{id:_0xdcc5x2c[_0x1cff[80]][_0x1cff[79]]}})[_0x1cff[40]](handleEntityNotFound(_0xdcc5x1a,null))[_0x1cff[40]](removeEntity(_0xdcc5x1a,null))[_0x1cff[73]](handleError(_0xdcc5x1a,null))};exports[_0x1cff[84]]= function(_0xdcc5x2c,_0xdcc5x1a){return db[_0x1cff[50]][_0x1cff[84]]()[_0x1cff[40]](respondWithResult(_0xdcc5x1a,null))[_0x1cff[73]](handleError(_0xdcc5x1a,null))}