Built motion from commit (unavailable).|2.5.3
[motion2.git] / server / api / mailServerIn / mailServerIn.rpc.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 _0x6dc3=['MailServerIn','options','where','attributes','limit','include','map','model','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','jayson/promise','client','MailServerIn,\x20%s,\x20%s','debug','MailServerIn,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','info','result','catch','GetMailServerIn'];(function(_0x5b6165,_0x21fb6a){var _0x40053c=function(_0x492be2){while(--_0x492be2){_0x5b6165['push'](_0x5b6165['shift']());}};_0x40053c(++_0x21fb6a);}(_0x6dc3,0x1d9));var _0x36dc=function(_0x28cc23,_0x17fb4e){_0x28cc23=_0x28cc23-0x0;var _0x3897e4=_0x6dc3[_0x28cc23];return _0x3897e4;};'use strict';var _=require(_0x36dc('0x0'));var util=require(_0x36dc('0x1'));var moment=require(_0x36dc('0x2'));var BPromise=require(_0x36dc('0x3'));var rs=require(_0x36dc('0x4'));var fs=require('fs');var Redis=require(_0x36dc('0x5'));var db=require(_0x36dc('0x6'))['db'];var utils=require(_0x36dc('0x7'));var logger=require('../../config/logger')(_0x36dc('0x8'));var config=require('../../config/environment');var jayson=require(_0x36dc('0x9'));var client=jayson[_0x36dc('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x4c0f96,_0xd79a8d,_0x29c1b7){return new BPromise(function(_0x41a67b,_0x493c21){return client['request'](_0x4c0f96,_0x29c1b7)['then'](function(_0x25b66a){logger['info'](_0x36dc('0xb'),_0xd79a8d,'request\x20sent');logger[_0x36dc('0xc')](_0x36dc('0xd'),_0xd79a8d,_0x36dc('0xe'),JSON[_0x36dc('0xf')](_0x25b66a));if(_0x25b66a[_0x36dc('0x10')]){if(_0x25b66a['error'][_0x36dc('0x11')]===0x1f4){logger[_0x36dc('0x10')](_0x36dc('0xb'),_0xd79a8d,_0x25b66a[_0x36dc('0x10')][_0x36dc('0x12')]);return _0x493c21(_0x25b66a[_0x36dc('0x10')][_0x36dc('0x12')]);}logger[_0x36dc('0x10')](_0x36dc('0xb'),_0xd79a8d,_0x25b66a[_0x36dc('0x10')][_0x36dc('0x12')]);return _0x41a67b(_0x25b66a['error'][_0x36dc('0x12')]);}else{logger[_0x36dc('0x13')](_0x36dc('0xb'),_0xd79a8d,'request\x20sent');_0x41a67b(_0x25b66a[_0x36dc('0x14')][_0x36dc('0x12')]);}})[_0x36dc('0x15')](function(_0x4764ae){logger[_0x36dc('0x10')]('MailServerIn,\x20%s,\x20%s',_0xd79a8d,_0x4764ae);_0x493c21(_0x4764ae);});});}exports[_0x36dc('0x16')]=function(_0x32da21){var _0x498f44=this;return new Promise(function(_0x3a5140,_0x3fb5a7){return db[_0x36dc('0x17')]['findAll']({'raw':_0x32da21[_0x36dc('0x18')]?_0x32da21[_0x36dc('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0x32da21['options']?_0x32da21[_0x36dc('0x18')][_0x36dc('0x19')]||null:null,'attributes':_0x32da21[_0x36dc('0x18')]?_0x32da21['options'][_0x36dc('0x1a')]||null:null,'limit':_0x32da21[_0x36dc('0x18')]?_0x32da21[_0x36dc('0x18')][_0x36dc('0x1b')]||null:null,'include':_0x32da21[_0x36dc('0x18')]?_0x32da21['options'][_0x36dc('0x1c')]?_[_0x36dc('0x1d')](_0x32da21[_0x36dc('0x18')][_0x36dc('0x1c')],function(_0x1de4bf){return{'model':db[_0x1de4bf[_0x36dc('0x1e')]],'as':_0x1de4bf['as'],'attributes':_0x1de4bf['attributes'],'include':_0x1de4bf['include']?_[_0x36dc('0x1d')](_0x1de4bf[_0x36dc('0x1c')],function(_0x1f8831){return{'model':db[_0x1f8831[_0x36dc('0x1e')]],'as':_0x1f8831['as'],'attributes':_0x1f8831[_0x36dc('0x1a')],'include':_0x1f8831[_0x36dc('0x1c')]?_[_0x36dc('0x1d')](_0x1f8831['include'],function(_0x1d94ec){return{'model':db[_0x1d94ec[_0x36dc('0x1e')]],'as':_0x1d94ec['as'],'attributes':_0x1d94ec[_0x36dc('0x1a')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x414501){logger['info'](_0x36dc('0x16'),_0x32da21);logger[_0x36dc('0xc')](_0x36dc('0x16'),_0x32da21,JSON[_0x36dc('0xf')](_0x414501));_0x3a5140(_0x414501);})['catch'](function(_0x3a2bbe){logger[_0x36dc('0x10')](_0x36dc('0x16'),_0x3a2bbe[_0x36dc('0x12')],_0x32da21);_0x3fb5a7(_0x498f44['error'](0x1f4,_0x3a2bbe[_0x36dc('0x12')]));});});};