3c1d399ec6929b79795c84232c2ca9359e3b4530
[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 _0x3fe4=['defaults','redis','localhost','socket.io-emitter','./smsAccount.socket','register','then','info','request\x20sent','debug','SmsAccount,\x20%s,\x20%s,\x20%s','stringify','error','SmsAccount,\x20%s,\x20%s','message','catch','SmsAccount','options','raw','where','include','model','attributes','ShowSmsAccount','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client'];(function(_0x36ad95,_0x28136f){var _0x26cb0c=function(_0xc287ce){while(--_0xc287ce){_0x36ad95['push'](_0x36ad95['shift']());}};_0x26cb0c(++_0x28136f);}(_0x3fe4,0x176));var _0x43fe=function(_0x5dc877,_0x54c9e7){_0x5dc877=_0x5dc877-0x0;var _0x36263b=_0x3fe4[_0x5dc877];return _0x36263b;};'use strict';var _=require(_0x43fe('0x0'));var util=require(_0x43fe('0x1'));var moment=require(_0x43fe('0x2'));var BPromise=require(_0x43fe('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x43fe('0x4'));var db=require(_0x43fe('0x5'))['db'];var utils=require(_0x43fe('0x6'));var logger=require(_0x43fe('0x7'))(_0x43fe('0x8'));var config=require(_0x43fe('0x9'));var jayson=require('jayson/promise');var client=jayson[_0x43fe('0xa')]['http']({'port':0x232a});config['redis']=_[_0x43fe('0xb')](config[_0x43fe('0xc')],{'host':_0x43fe('0xd'),'port':0x18eb});var socket=require(_0x43fe('0xe'))(new Redis(config[_0x43fe('0xc')]));require(_0x43fe('0xf'))[_0x43fe('0x10')](socket);function respondWithRpcPromise(_0x292a8b,_0x446cbb,_0x11eaae){return new BPromise(function(_0xf149d8,_0x2d2a4c){return client['request'](_0x292a8b,_0x11eaae)[_0x43fe('0x11')](function(_0x5104ef){logger[_0x43fe('0x12')]('SmsAccount,\x20%s,\x20%s',_0x446cbb,_0x43fe('0x13'));logger[_0x43fe('0x14')](_0x43fe('0x15'),_0x446cbb,_0x43fe('0x13'),JSON[_0x43fe('0x16')](_0x5104ef));if(_0x5104ef[_0x43fe('0x17')]){if(_0x5104ef['error']['code']===0x1f4){logger[_0x43fe('0x17')](_0x43fe('0x18'),_0x446cbb,_0x5104ef[_0x43fe('0x17')][_0x43fe('0x19')]);return _0x2d2a4c(_0x5104ef[_0x43fe('0x17')][_0x43fe('0x19')]);}logger[_0x43fe('0x17')](_0x43fe('0x18'),_0x446cbb,_0x5104ef[_0x43fe('0x17')][_0x43fe('0x19')]);return _0xf149d8(_0x5104ef['error'][_0x43fe('0x19')]);}else{logger[_0x43fe('0x12')](_0x43fe('0x18'),_0x446cbb,_0x43fe('0x13'));_0xf149d8(_0x5104ef['result']['message']);}})[_0x43fe('0x1a')](function(_0x26940a){logger[_0x43fe('0x17')](_0x43fe('0x18'),_0x446cbb,_0x26940a);_0x2d2a4c(_0x26940a);});});}exports['ShowSmsAccount']=function(_0x4739c1){var _0x119b91=this;return new Promise(function(_0x4cc967,_0xb676ff){return db[_0x43fe('0x1b')]['find']({'raw':_0x4739c1['options']?_0x4739c1[_0x43fe('0x1c')][_0x43fe('0x1d')]===undefined?!![]:![]:!![],'where':_0x4739c1[_0x43fe('0x1c')]?_0x4739c1[_0x43fe('0x1c')][_0x43fe('0x1e')]||null:null,'attributes':_0x4739c1[_0x43fe('0x1c')]?_0x4739c1[_0x43fe('0x1c')]['attributes']||null:null,'include':_0x4739c1[_0x43fe('0x1c')]?_0x4739c1[_0x43fe('0x1c')][_0x43fe('0x1f')]?_['map'](_0x4739c1[_0x43fe('0x1c')][_0x43fe('0x1f')],function(_0x320911){return{'model':db[_0x320911['model']],'as':_0x320911['as'],'attributes':_0x320911['attributes'],'include':_0x320911[_0x43fe('0x1f')]?_['map'](_0x320911[_0x43fe('0x1f')],function(_0x5502ab){return{'model':db[_0x5502ab[_0x43fe('0x20')]],'as':_0x5502ab['as'],'attributes':_0x5502ab[_0x43fe('0x21')],'include':_0x5502ab[_0x43fe('0x1f')]?_['map'](_0x5502ab[_0x43fe('0x1f')],function(_0xf91288){return{'model':db[_0xf91288[_0x43fe('0x20')]],'as':_0xf91288['as'],'attributes':_0xf91288[_0x43fe('0x21')]};}):[]};}):[]};}):[]:[]})[_0x43fe('0x11')](function(_0x386037){logger[_0x43fe('0x12')](_0x43fe('0x22'),_0x4739c1);logger[_0x43fe('0x14')]('ShowSmsAccount',_0x4739c1,JSON[_0x43fe('0x16')](_0x386037));_0x4cc967(_0x386037);})[_0x43fe('0x1a')](function(_0x5d590b){logger[_0x43fe('0x17')](_0x43fe('0x22'),_0x5d590b['message'],_0x4739c1);_0xb676ff(_0x119b91[_0x43fe('0x17')](0x1f4,_0x5d590b[_0x43fe('0x19')]));});});};