63d9983ebff1b89b2163c30ec1433bf183f84e58
[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 _0xc038=['catch','ShowSmsAccount','options','attributes','include','map','model','info','moment','randomstring','ioredis','../../config/utils','rpc','../../config/environment','jayson/promise','http','redis','defaults','localhost','socket.io-emitter','./smsAccount.socket','register','request','then','request\x20sent','debug','stringify','error','code','SmsAccount,\x20%s,\x20%s','message'];(function(_0x357abb,_0x5d189c){var _0x2160d7=function(_0x2463bf){while(--_0x2463bf){_0x357abb['push'](_0x357abb['shift']());}};_0x2160d7(++_0x5d189c);}(_0xc038,0x65));var _0x8c03=function(_0x1e251a,_0x10ab3d){_0x1e251a=_0x1e251a-0x0;var _0xd45050=_0xc038[_0x1e251a];return _0xd45050;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x8c03('0x0'));var BPromise=require('bluebird');var rs=require(_0x8c03('0x1'));var fs=require('fs');var Redis=require(_0x8c03('0x2'));var db=require('../../mysqldb')['db'];var utils=require(_0x8c03('0x3'));var logger=require('../../config/logger')(_0x8c03('0x4'));var config=require(_0x8c03('0x5'));var jayson=require(_0x8c03('0x6'));var client=jayson['client'][_0x8c03('0x7')]({'port':0x232a});config[_0x8c03('0x8')]=_[_0x8c03('0x9')](config[_0x8c03('0x8')],{'host':_0x8c03('0xa'),'port':0x18eb});var socket=require(_0x8c03('0xb'))(new Redis(config['redis']));require(_0x8c03('0xc'))[_0x8c03('0xd')](socket);function respondWithRpcPromise(_0x2eabd3,_0x4bd26b,_0x1713ab){return new BPromise(function(_0x53999b,_0x39c365){return client[_0x8c03('0xe')](_0x2eabd3,_0x1713ab)[_0x8c03('0xf')](function(_0x505cc8){logger['info']('SmsAccount,\x20%s,\x20%s',_0x4bd26b,_0x8c03('0x10'));logger[_0x8c03('0x11')]('SmsAccount,\x20%s,\x20%s,\x20%s',_0x4bd26b,_0x8c03('0x10'),JSON[_0x8c03('0x12')](_0x505cc8));if(_0x505cc8[_0x8c03('0x13')]){if(_0x505cc8[_0x8c03('0x13')][_0x8c03('0x14')]===0x1f4){logger[_0x8c03('0x13')](_0x8c03('0x15'),_0x4bd26b,_0x505cc8['error'][_0x8c03('0x16')]);return _0x39c365(_0x505cc8[_0x8c03('0x13')][_0x8c03('0x16')]);}logger[_0x8c03('0x13')](_0x8c03('0x15'),_0x4bd26b,_0x505cc8[_0x8c03('0x13')][_0x8c03('0x16')]);return _0x53999b(_0x505cc8[_0x8c03('0x13')]['message']);}else{logger['info']('SmsAccount,\x20%s,\x20%s',_0x4bd26b,'request\x20sent');_0x53999b(_0x505cc8['result'][_0x8c03('0x16')]);}})[_0x8c03('0x17')](function(_0x54ecac){logger[_0x8c03('0x13')](_0x8c03('0x15'),_0x4bd26b,_0x54ecac);_0x39c365(_0x54ecac);});});}exports[_0x8c03('0x18')]=function(_0x1939ef){var _0x1e1bd7=this;return new Promise(function(_0x327b59,_0x40f659){return db['SmsAccount']['find']({'raw':_0x1939ef[_0x8c03('0x19')]?_0x1939ef['options']['raw']===undefined?!![]:![]:!![],'where':_0x1939ef[_0x8c03('0x19')]?_0x1939ef[_0x8c03('0x19')]['where']||null:null,'attributes':_0x1939ef['options']?_0x1939ef[_0x8c03('0x19')][_0x8c03('0x1a')]||null:null,'include':_0x1939ef[_0x8c03('0x19')]?_0x1939ef[_0x8c03('0x19')][_0x8c03('0x1b')]?_[_0x8c03('0x1c')](_0x1939ef[_0x8c03('0x19')][_0x8c03('0x1b')],function(_0x4c82ee){return{'model':db[_0x4c82ee[_0x8c03('0x1d')]],'as':_0x4c82ee['as'],'attributes':_0x4c82ee[_0x8c03('0x1a')],'include':_0x4c82ee[_0x8c03('0x1b')]?_['map'](_0x4c82ee[_0x8c03('0x1b')],function(_0x19dcdb){return{'model':db[_0x19dcdb[_0x8c03('0x1d')]],'as':_0x19dcdb['as'],'attributes':_0x19dcdb[_0x8c03('0x1a')],'include':_0x19dcdb[_0x8c03('0x1b')]?_[_0x8c03('0x1c')](_0x19dcdb[_0x8c03('0x1b')],function(_0x563045){return{'model':db[_0x563045[_0x8c03('0x1d')]],'as':_0x563045['as'],'attributes':_0x563045[_0x8c03('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x8c03('0xf')](function(_0x554b3f){logger[_0x8c03('0x1e')](_0x8c03('0x18'),_0x1939ef);logger[_0x8c03('0x11')](_0x8c03('0x18'),_0x1939ef,JSON[_0x8c03('0x12')](_0x554b3f));_0x327b59(_0x554b3f);})['catch'](function(_0x7668b4){logger['error']('ShowSmsAccount',_0x7668b4['message'],_0x1939ef);_0x40f659(_0x1e1bd7['error'](0x1f4,_0x7668b4[_0x8c03('0x16')]));});});};