5c1abfe34f116bd4d6404f4a2b130a39eef1082e
[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 _0xdf5e=['bluebird','randomstring','../../mysqldb','rpc','../../config/environment','jayson/promise','client','http','request','then','info','MailServerIn,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','GetMailServerIn','MailServerIn','options','raw','attributes','limit','include','map','model','debug','moment'];(function(_0x2713b3,_0x15dafa){var _0x3df272=function(_0x459d38){while(--_0x459d38){_0x2713b3['push'](_0x2713b3['shift']());}};_0x3df272(++_0x15dafa);}(_0xdf5e,0x12b));var _0xedf5=function(_0x35ef6b,_0x202c42){_0x35ef6b=_0x35ef6b-0x0;var _0x3ad145=_0xdf5e[_0x35ef6b];return _0x3ad145;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0xedf5('0x0'));var BPromise=require(_0xedf5('0x1'));var rs=require(_0xedf5('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xedf5('0x3'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xedf5('0x4'));var config=require(_0xedf5('0x5'));var jayson=require(_0xedf5('0x6'));var client=jayson[_0xedf5('0x7')][_0xedf5('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x45f4cd,_0x1540c9,_0x562912){return new BPromise(function(_0x35ab81,_0x4ff797){return client[_0xedf5('0x9')](_0x45f4cd,_0x562912)[_0xedf5('0xa')](function(_0x500c09){logger[_0xedf5('0xb')](_0xedf5('0xc'),_0x1540c9,_0xedf5('0xd'));logger['debug']('MailServerIn,\x20%s,\x20%s,\x20%s',_0x1540c9,_0xedf5('0xd'),JSON[_0xedf5('0xe')](_0x500c09));if(_0x500c09['error']){if(_0x500c09[_0xedf5('0xf')][_0xedf5('0x10')]===0x1f4){logger[_0xedf5('0xf')]('MailServerIn,\x20%s,\x20%s',_0x1540c9,_0x500c09[_0xedf5('0xf')][_0xedf5('0x11')]);return _0x4ff797(_0x500c09[_0xedf5('0xf')][_0xedf5('0x11')]);}logger['error'](_0xedf5('0xc'),_0x1540c9,_0x500c09[_0xedf5('0xf')]['message']);return _0x35ab81(_0x500c09[_0xedf5('0xf')][_0xedf5('0x11')]);}else{logger[_0xedf5('0xb')](_0xedf5('0xc'),_0x1540c9,_0xedf5('0xd'));_0x35ab81(_0x500c09[_0xedf5('0x12')][_0xedf5('0x11')]);}})[_0xedf5('0x13')](function(_0x359eab){logger[_0xedf5('0xf')](_0xedf5('0xc'),_0x1540c9,_0x359eab);_0x4ff797(_0x359eab);});});}exports[_0xedf5('0x14')]=function(_0x8f4c77){var _0x246ec5=this;return new Promise(function(_0x53d39c,_0x41f0c0){return db[_0xedf5('0x15')]['findAll']({'raw':_0x8f4c77[_0xedf5('0x16')]?_0x8f4c77['options'][_0xedf5('0x17')]===undefined?!![]:![]:!![],'where':_0x8f4c77[_0xedf5('0x16')]?_0x8f4c77[_0xedf5('0x16')]['where']||null:null,'attributes':_0x8f4c77[_0xedf5('0x16')]?_0x8f4c77[_0xedf5('0x16')][_0xedf5('0x18')]||null:null,'limit':_0x8f4c77[_0xedf5('0x16')]?_0x8f4c77[_0xedf5('0x16')][_0xedf5('0x19')]||null:null,'include':_0x8f4c77[_0xedf5('0x16')]?_0x8f4c77['options'][_0xedf5('0x1a')]?_[_0xedf5('0x1b')](_0x8f4c77['options'][_0xedf5('0x1a')],function(_0x56c42c){return{'model':db[_0x56c42c[_0xedf5('0x1c')]],'as':_0x56c42c['as'],'attributes':_0x56c42c[_0xedf5('0x18')],'include':_0x56c42c[_0xedf5('0x1a')]?_[_0xedf5('0x1b')](_0x56c42c[_0xedf5('0x1a')],function(_0x3ca302){return{'model':db[_0x3ca302['model']],'as':_0x3ca302['as'],'attributes':_0x3ca302['attributes'],'include':_0x3ca302[_0xedf5('0x1a')]?_[_0xedf5('0x1b')](_0x3ca302['include'],function(_0x44aea2){return{'model':db[_0x44aea2[_0xedf5('0x1c')]],'as':_0x44aea2['as'],'attributes':_0x44aea2[_0xedf5('0x18')]};}):[]};}):[]};}):[]:[]})[_0xedf5('0xa')](function(_0x2d906e){logger['info']('GetMailServerIn',_0x8f4c77);logger[_0xedf5('0x1d')](_0xedf5('0x14'),_0x8f4c77,JSON[_0xedf5('0xe')](_0x2d906e));_0x53d39c(_0x2d906e);})[_0xedf5('0x13')](function(_0x6cd29d){logger[_0xedf5('0xf')]('GetMailServerIn',_0x6cd29d[_0xedf5('0x11')],_0x8f4c77);_0x41f0c0(_0x246ec5[_0xedf5('0xf')](0x1f4,_0x6cd29d[_0xedf5('0x11')]));});});};