Built motion from commit bbec7235.|2.6.20
[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 _0x2608=['http','then','info','MailServerIn,\x20%s,\x20%s','request\x20sent','debug','MailServerIn,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetMailServerIn','findAll','options','raw','attributes','limit','include','map','model','lodash','moment','bluebird','randomstring','../../mysqldb','../../config/logger','rpc','jayson/promise','client'];(function(_0x32996b,_0x4c0449){var _0x2e39f2=function(_0x4016fb){while(--_0x4016fb){_0x32996b['push'](_0x32996b['shift']());}};_0x2e39f2(++_0x4c0449);}(_0x2608,0x1c8));var _0x8260=function(_0x49f4c5,_0x42da90){_0x49f4c5=_0x49f4c5-0x0;var _0x3843c7=_0x2608[_0x49f4c5];return _0x3843c7;};'use strict';var _=require(_0x8260('0x0'));var util=require('util');var moment=require(_0x8260('0x1'));var BPromise=require(_0x8260('0x2'));var rs=require(_0x8260('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x8260('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x8260('0x5'))(_0x8260('0x6'));var config=require('../../config/environment');var jayson=require(_0x8260('0x7'));var client=jayson[_0x8260('0x8')][_0x8260('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x2541e7,_0x3504cd,_0x45954d){return new BPromise(function(_0x491e4b,_0x52dbb6){return client['request'](_0x2541e7,_0x45954d)[_0x8260('0xa')](function(_0x54e5b9){logger[_0x8260('0xb')](_0x8260('0xc'),_0x3504cd,_0x8260('0xd'));logger[_0x8260('0xe')](_0x8260('0xf'),_0x3504cd,_0x8260('0xd'),JSON[_0x8260('0x10')](_0x54e5b9));if(_0x54e5b9[_0x8260('0x11')]){if(_0x54e5b9[_0x8260('0x11')][_0x8260('0x12')]===0x1f4){logger[_0x8260('0x11')]('MailServerIn,\x20%s,\x20%s',_0x3504cd,_0x54e5b9['error'][_0x8260('0x13')]);return _0x52dbb6(_0x54e5b9[_0x8260('0x11')][_0x8260('0x13')]);}logger[_0x8260('0x11')](_0x8260('0xc'),_0x3504cd,_0x54e5b9[_0x8260('0x11')][_0x8260('0x13')]);return _0x491e4b(_0x54e5b9['error']['message']);}else{logger[_0x8260('0xb')]('MailServerIn,\x20%s,\x20%s',_0x3504cd,'request\x20sent');_0x491e4b(_0x54e5b9[_0x8260('0x14')][_0x8260('0x13')]);}})[_0x8260('0x15')](function(_0x21b4e5){logger[_0x8260('0x11')](_0x8260('0xc'),_0x3504cd,_0x21b4e5);_0x52dbb6(_0x21b4e5);});});}exports[_0x8260('0x16')]=function(_0x86245){var _0x501d72=this;return new Promise(function(_0x5b1d0b,_0x50ec48){return db['MailServerIn'][_0x8260('0x17')]({'raw':_0x86245[_0x8260('0x18')]?_0x86245['options'][_0x8260('0x19')]===undefined?!![]:![]:!![],'where':_0x86245[_0x8260('0x18')]?_0x86245[_0x8260('0x18')]['where']||null:null,'attributes':_0x86245[_0x8260('0x18')]?_0x86245[_0x8260('0x18')][_0x8260('0x1a')]||null:null,'limit':_0x86245[_0x8260('0x18')]?_0x86245[_0x8260('0x18')][_0x8260('0x1b')]||null:null,'include':_0x86245[_0x8260('0x18')]?_0x86245[_0x8260('0x18')][_0x8260('0x1c')]?_[_0x8260('0x1d')](_0x86245[_0x8260('0x18')]['include'],function(_0x496152){return{'model':db[_0x496152[_0x8260('0x1e')]],'as':_0x496152['as'],'attributes':_0x496152['attributes'],'include':_0x496152[_0x8260('0x1c')]?_[_0x8260('0x1d')](_0x496152[_0x8260('0x1c')],function(_0x1f055e){return{'model':db[_0x1f055e[_0x8260('0x1e')]],'as':_0x1f055e['as'],'attributes':_0x1f055e[_0x8260('0x1a')],'include':_0x1f055e[_0x8260('0x1c')]?_['map'](_0x1f055e[_0x8260('0x1c')],function(_0x32f40e){return{'model':db[_0x32f40e[_0x8260('0x1e')]],'as':_0x32f40e['as'],'attributes':_0x32f40e[_0x8260('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x8260('0xa')](function(_0x5c5872){logger['info']('GetMailServerIn',_0x86245);logger[_0x8260('0xe')]('GetMailServerIn',_0x86245,JSON[_0x8260('0x10')](_0x5c5872));_0x5b1d0b(_0x5c5872);})[_0x8260('0x15')](function(_0x3c3694){logger['error'](_0x8260('0x16'),_0x3c3694[_0x8260('0x13')],_0x86245);_0x50ec48(_0x501d72[_0x8260('0x11')](0x1f4,_0x3c3694[_0x8260('0x13')]));});});};