Built motion from commit (unavailable).|2.5.4
[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 _0x8667=['../../config/utils','../../config/logger','../../config/environment','jayson/promise','http','info','request\x20sent','debug','MailServerIn,\x20%s,\x20%s,\x20%s','stringify','error','code','MailServerIn,\x20%s,\x20%s','message','result','catch','GetMailServerIn','MailServerIn','options','raw','where','attributes','limit','include','map','model','randomstring','ioredis','../../mysqldb'];(function(_0x42057a,_0x4c59bb){var _0x334b7e=function(_0x4b046c){while(--_0x4b046c){_0x42057a['push'](_0x42057a['shift']());}};_0x334b7e(++_0x4c59bb);}(_0x8667,0x1cd));var _0x7866=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x8667[_0x3dd15e];return _0x231fd0;};'use strict';var _=require('lodash');var util=require('util');var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x7866('0x0'));var fs=require('fs');var Redis=require(_0x7866('0x1'));var db=require(_0x7866('0x2'))['db'];var utils=require(_0x7866('0x3'));var logger=require(_0x7866('0x4'))('rpc');var config=require(_0x7866('0x5'));var jayson=require(_0x7866('0x6'));var client=jayson['client'][_0x7866('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x703faa,_0x52960d,_0x3d5985){return new BPromise(function(_0x1fb084,_0x3f6cb1){return client['request'](_0x703faa,_0x3d5985)['then'](function(_0xf1dff7){logger[_0x7866('0x8')]('MailServerIn,\x20%s,\x20%s',_0x52960d,_0x7866('0x9'));logger[_0x7866('0xa')](_0x7866('0xb'),_0x52960d,_0x7866('0x9'),JSON[_0x7866('0xc')](_0xf1dff7));if(_0xf1dff7[_0x7866('0xd')]){if(_0xf1dff7[_0x7866('0xd')][_0x7866('0xe')]===0x1f4){logger[_0x7866('0xd')](_0x7866('0xf'),_0x52960d,_0xf1dff7[_0x7866('0xd')]['message']);return _0x3f6cb1(_0xf1dff7[_0x7866('0xd')][_0x7866('0x10')]);}logger[_0x7866('0xd')]('MailServerIn,\x20%s,\x20%s',_0x52960d,_0xf1dff7[_0x7866('0xd')][_0x7866('0x10')]);return _0x1fb084(_0xf1dff7[_0x7866('0xd')][_0x7866('0x10')]);}else{logger[_0x7866('0x8')](_0x7866('0xf'),_0x52960d,_0x7866('0x9'));_0x1fb084(_0xf1dff7[_0x7866('0x11')]['message']);}})[_0x7866('0x12')](function(_0x1677c5){logger['error'](_0x7866('0xf'),_0x52960d,_0x1677c5);_0x3f6cb1(_0x1677c5);});});}exports[_0x7866('0x13')]=function(_0x598710){var _0x892e11=this;return new Promise(function(_0x159fc3,_0x183f60){return db[_0x7866('0x14')]['findAll']({'raw':_0x598710[_0x7866('0x15')]?_0x598710[_0x7866('0x15')][_0x7866('0x16')]===undefined?!![]:![]:!![],'where':_0x598710['options']?_0x598710['options'][_0x7866('0x17')]||null:null,'attributes':_0x598710[_0x7866('0x15')]?_0x598710[_0x7866('0x15')][_0x7866('0x18')]||null:null,'limit':_0x598710[_0x7866('0x15')]?_0x598710[_0x7866('0x15')][_0x7866('0x19')]||null:null,'include':_0x598710[_0x7866('0x15')]?_0x598710[_0x7866('0x15')][_0x7866('0x1a')]?_[_0x7866('0x1b')](_0x598710['options'][_0x7866('0x1a')],function(_0x522477){return{'model':db[_0x522477['model']],'as':_0x522477['as'],'attributes':_0x522477[_0x7866('0x18')],'include':_0x522477[_0x7866('0x1a')]?_['map'](_0x522477[_0x7866('0x1a')],function(_0x523ff0){return{'model':db[_0x523ff0[_0x7866('0x1c')]],'as':_0x523ff0['as'],'attributes':_0x523ff0[_0x7866('0x18')],'include':_0x523ff0[_0x7866('0x1a')]?_[_0x7866('0x1b')](_0x523ff0[_0x7866('0x1a')],function(_0x423a94){return{'model':db[_0x423a94[_0x7866('0x1c')]],'as':_0x423a94['as'],'attributes':_0x423a94[_0x7866('0x18')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x21482d){logger[_0x7866('0x8')](_0x7866('0x13'),_0x598710);logger[_0x7866('0xa')](_0x7866('0x13'),_0x598710,JSON[_0x7866('0xc')](_0x21482d));_0x159fc3(_0x21482d);})[_0x7866('0x12')](function(_0x461e94){logger['error'](_0x7866('0x13'),_0x461e94[_0x7866('0x10')],_0x598710);_0x183f60(_0x892e11[_0x7866('0xd')](0x1f4,_0x461e94[_0x7866('0x10')]));});});};