00173a62296a7a764779358169194cf85ca2e7eb
[motion2.git] / server / api / smsAccount / smsAccount.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 _0x6b39=['http','redis','defaults','localhost','socket.io-emitter','./smsAccount.socket','register','request','then','info','SmsAccount,\x20%s,\x20%s','request\x20sent','SmsAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','ShowSmsAccount','SmsAccount','find','raw','options','where','include','map','model','attributes','debug','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','client'];(function(_0xad5879,_0x332433){var _0x16c7e1=function(_0x277488){while(--_0x277488){_0xad5879['push'](_0xad5879['shift']());}};_0x16c7e1(++_0x332433);}(_0x6b39,0x156));var _0x96b3=function(_0xca5e7d,_0xd2bf69){_0xca5e7d=_0xca5e7d-0x0;var _0x4fa0cf=_0x6b39[_0xca5e7d];return _0x4fa0cf;};'use strict';var _=require(_0x96b3('0x0'));var util=require(_0x96b3('0x1'));var moment=require(_0x96b3('0x2'));var BPromise=require(_0x96b3('0x3'));var rs=require(_0x96b3('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x96b3('0x5'))['db'];var utils=require(_0x96b3('0x6'));var logger=require(_0x96b3('0x7'))('rpc');var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x96b3('0x8')][_0x96b3('0x9')]({'port':0x232a});config[_0x96b3('0xa')]=_[_0x96b3('0xb')](config[_0x96b3('0xa')],{'host':_0x96b3('0xc'),'port':0x18eb});var socket=require(_0x96b3('0xd'))(new Redis(config[_0x96b3('0xa')]));require(_0x96b3('0xe'))[_0x96b3('0xf')](socket);function respondWithRpcPromise(_0xec26b0,_0x10b3e7,_0x15d052){return new BPromise(function(_0x50af13,_0x2b8b34){return client[_0x96b3('0x10')](_0xec26b0,_0x15d052)[_0x96b3('0x11')](function(_0x1efd89){logger[_0x96b3('0x12')](_0x96b3('0x13'),_0x10b3e7,_0x96b3('0x14'));logger['debug'](_0x96b3('0x15'),_0x10b3e7,_0x96b3('0x14'),JSON[_0x96b3('0x16')](_0x1efd89));if(_0x1efd89[_0x96b3('0x17')]){if(_0x1efd89[_0x96b3('0x17')][_0x96b3('0x18')]===0x1f4){logger[_0x96b3('0x17')](_0x96b3('0x13'),_0x10b3e7,_0x1efd89[_0x96b3('0x17')][_0x96b3('0x19')]);return _0x2b8b34(_0x1efd89[_0x96b3('0x17')][_0x96b3('0x19')]);}logger['error'](_0x96b3('0x13'),_0x10b3e7,_0x1efd89[_0x96b3('0x17')][_0x96b3('0x19')]);return _0x50af13(_0x1efd89[_0x96b3('0x17')][_0x96b3('0x19')]);}else{logger[_0x96b3('0x12')]('SmsAccount,\x20%s,\x20%s',_0x10b3e7,_0x96b3('0x14'));_0x50af13(_0x1efd89[_0x96b3('0x1a')][_0x96b3('0x19')]);}})[_0x96b3('0x1b')](function(_0x1ab220){logger['error'](_0x96b3('0x13'),_0x10b3e7,_0x1ab220);_0x2b8b34(_0x1ab220);});});}exports[_0x96b3('0x1c')]=function(_0x14684f){var _0x2d9fb0=this;return new Promise(function(_0x3e521f,_0x406c90){return db[_0x96b3('0x1d')][_0x96b3('0x1e')]({'raw':_0x14684f['options']?_0x14684f['options'][_0x96b3('0x1f')]===undefined?!![]:![]:!![],'where':_0x14684f['options']?_0x14684f[_0x96b3('0x20')][_0x96b3('0x21')]||null:null,'attributes':_0x14684f[_0x96b3('0x20')]?_0x14684f[_0x96b3('0x20')]['attributes']||null:null,'include':_0x14684f[_0x96b3('0x20')]?_0x14684f[_0x96b3('0x20')][_0x96b3('0x22')]?_[_0x96b3('0x23')](_0x14684f['options']['include'],function(_0x18ffc7){return{'model':db[_0x18ffc7[_0x96b3('0x24')]],'as':_0x18ffc7['as'],'attributes':_0x18ffc7[_0x96b3('0x25')],'include':_0x18ffc7[_0x96b3('0x22')]?_[_0x96b3('0x23')](_0x18ffc7[_0x96b3('0x22')],function(_0x2db20a){return{'model':db[_0x2db20a['model']],'as':_0x2db20a['as'],'attributes':_0x2db20a['attributes'],'include':_0x2db20a['include']?_[_0x96b3('0x23')](_0x2db20a['include'],function(_0x7c8139){return{'model':db[_0x7c8139[_0x96b3('0x24')]],'as':_0x7c8139['as'],'attributes':_0x7c8139['attributes']};}):[]};}):[]};}):[]:[]})[_0x96b3('0x11')](function(_0x1a2b3d){logger[_0x96b3('0x12')](_0x96b3('0x1c'),_0x14684f);logger[_0x96b3('0x26')]('ShowSmsAccount',_0x14684f,JSON[_0x96b3('0x16')](_0x1a2b3d));_0x3e521f(_0x1a2b3d);})[_0x96b3('0x1b')](function(_0x4e3389){logger['error'](_0x96b3('0x1c'),_0x4e3389[_0x96b3('0x19')],_0x14684f);_0x406c90(_0x2d9fb0[_0x96b3('0x17')](0x1f4,_0x4e3389[_0x96b3('0x19')]));});});};