9d245b287940a127eda48ced02a4a5143fd5361d
[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 _0xdb4b=['debug','SmsAccount,\x20%s,\x20%s,\x20%s','error','code','message','result','SmsAccount','find','options','raw','where','attributes','include','model','map','info','stringify','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','defaults','redis','localhost','socket.io-emitter','register','request','then','SmsAccount,\x20%s,\x20%s','request\x20sent'];(function(_0xafcf00,_0x4429a3){var _0x513af4=function(_0x59554d){while(--_0x59554d){_0xafcf00['push'](_0xafcf00['shift']());}};_0x513af4(++_0x4429a3);}(_0xdb4b,0x83));var _0xbdb4=function(_0x146fc2,_0x4beccc){_0x146fc2=_0x146fc2-0x0;var _0x3600ee=_0xdb4b[_0x146fc2];return _0x3600ee;};'use strict';var _=require(_0xbdb4('0x0'));var util=require(_0xbdb4('0x1'));var moment=require(_0xbdb4('0x2'));var BPromise=require(_0xbdb4('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xbdb4('0x4'));var db=require(_0xbdb4('0x5'))['db'];var utils=require(_0xbdb4('0x6'));var logger=require(_0xbdb4('0x7'))(_0xbdb4('0x8'));var config=require(_0xbdb4('0x9'));var jayson=require(_0xbdb4('0xa'));var client=jayson[_0xbdb4('0xb')]['http']({'port':0x232a});config['redis']=_[_0xbdb4('0xc')](config[_0xbdb4('0xd')],{'host':_0xbdb4('0xe'),'port':0x18eb});var socket=require(_0xbdb4('0xf'))(new Redis(config[_0xbdb4('0xd')]));require('./smsAccount.socket')[_0xbdb4('0x10')](socket);function respondWithRpcPromise(_0x5d171b,_0x5bc059,_0x5b6e4c){return new BPromise(function(_0x4f4082,_0x2a5115){return client[_0xbdb4('0x11')](_0x5d171b,_0x5b6e4c)[_0xbdb4('0x12')](function(_0x400025){logger['info'](_0xbdb4('0x13'),_0x5bc059,_0xbdb4('0x14'));logger[_0xbdb4('0x15')](_0xbdb4('0x16'),_0x5bc059,_0xbdb4('0x14'),JSON['stringify'](_0x400025));if(_0x400025[_0xbdb4('0x17')]){if(_0x400025[_0xbdb4('0x17')][_0xbdb4('0x18')]===0x1f4){logger['error'](_0xbdb4('0x13'),_0x5bc059,_0x400025[_0xbdb4('0x17')]['message']);return _0x2a5115(_0x400025[_0xbdb4('0x17')]['message']);}logger['error'](_0xbdb4('0x13'),_0x5bc059,_0x400025[_0xbdb4('0x17')]['message']);return _0x4f4082(_0x400025[_0xbdb4('0x17')][_0xbdb4('0x19')]);}else{logger['info'](_0xbdb4('0x13'),_0x5bc059,_0xbdb4('0x14'));_0x4f4082(_0x400025[_0xbdb4('0x1a')][_0xbdb4('0x19')]);}})['catch'](function(_0x30998e){logger[_0xbdb4('0x17')](_0xbdb4('0x13'),_0x5bc059,_0x30998e);_0x2a5115(_0x30998e);});});}exports['ShowSmsAccount']=function(_0x47139d){var _0x36ddc2=this;return new Promise(function(_0x35afa2,_0x3ee1e2){return db[_0xbdb4('0x1b')][_0xbdb4('0x1c')]({'raw':_0x47139d[_0xbdb4('0x1d')]?_0x47139d[_0xbdb4('0x1d')][_0xbdb4('0x1e')]===undefined?!![]:![]:!![],'where':_0x47139d[_0xbdb4('0x1d')]?_0x47139d[_0xbdb4('0x1d')][_0xbdb4('0x1f')]||null:null,'attributes':_0x47139d[_0xbdb4('0x1d')]?_0x47139d[_0xbdb4('0x1d')][_0xbdb4('0x20')]||null:null,'include':_0x47139d['options']?_0x47139d[_0xbdb4('0x1d')][_0xbdb4('0x21')]?_['map'](_0x47139d[_0xbdb4('0x1d')][_0xbdb4('0x21')],function(_0x5868e3){return{'model':db[_0x5868e3[_0xbdb4('0x22')]],'as':_0x5868e3['as'],'attributes':_0x5868e3['attributes'],'include':_0x5868e3['include']?_[_0xbdb4('0x23')](_0x5868e3[_0xbdb4('0x21')],function(_0x4d3c87){return{'model':db[_0x4d3c87[_0xbdb4('0x22')]],'as':_0x4d3c87['as'],'attributes':_0x4d3c87[_0xbdb4('0x20')],'include':_0x4d3c87[_0xbdb4('0x21')]?_[_0xbdb4('0x23')](_0x4d3c87[_0xbdb4('0x21')],function(_0xabe2d){return{'model':db[_0xabe2d[_0xbdb4('0x22')]],'as':_0xabe2d['as'],'attributes':_0xabe2d[_0xbdb4('0x20')]};}):[]};}):[]};}):[]:[]})[_0xbdb4('0x12')](function(_0x56e2b9){logger[_0xbdb4('0x24')]('ShowSmsAccount',_0x47139d);logger[_0xbdb4('0x15')]('ShowSmsAccount',_0x47139d,JSON[_0xbdb4('0x25')](_0x56e2b9));_0x35afa2(_0x56e2b9);})['catch'](function(_0x1abd6b){logger[_0xbdb4('0x17')]('ShowSmsAccount',_0x1abd6b[_0xbdb4('0x19')],_0x47139d);_0x3ee1e2(_0x36ddc2[_0xbdb4('0x17')](0x1f4,_0x1abd6b['message']));});});};