Built motion from commit 85f716e9.|2.6.8
[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 _0x59ba=['request','then','info','debug','SmsAccount,\x20%s,\x20%s,\x20%s','request\x20sent','error','SmsAccount,\x20%s,\x20%s','message','result','catch','SmsAccount','find','options','where','include','model','attributes','map','ShowSmsAccount','stringify','lodash','moment','bluebird','randomstring','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','defaults','redis','localhost','socket.io-emitter','register'];(function(_0x1cc8fe,_0x105328){var _0x230054=function(_0x1a1b56){while(--_0x1a1b56){_0x1cc8fe['push'](_0x1cc8fe['shift']());}};_0x230054(++_0x105328);}(_0x59ba,0xce));var _0xa59b=function(_0x36ec04,_0x327557){_0x36ec04=_0x36ec04-0x0;var _0x5f3193=_0x59ba[_0x36ec04];return _0x5f3193;};'use strict';var _=require(_0xa59b('0x0'));var util=require('util');var moment=require(_0xa59b('0x1'));var BPromise=require(_0xa59b('0x2'));var rs=require(_0xa59b('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xa59b('0x4'))['db'];var utils=require(_0xa59b('0x5'));var logger=require('../../config/logger')(_0xa59b('0x6'));var config=require(_0xa59b('0x7'));var jayson=require(_0xa59b('0x8'));var client=jayson[_0xa59b('0x9')][_0xa59b('0xa')]({'port':0x232a});config['redis']=_[_0xa59b('0xb')](config[_0xa59b('0xc')],{'host':_0xa59b('0xd'),'port':0x18eb});var socket=require(_0xa59b('0xe'))(new Redis(config[_0xa59b('0xc')]));require('./smsAccount.socket')[_0xa59b('0xf')](socket);function respondWithRpcPromise(_0x332075,_0x41cfbd,_0x194685){return new BPromise(function(_0x3cec92,_0x3a51d3){return client[_0xa59b('0x10')](_0x332075,_0x194685)[_0xa59b('0x11')](function(_0x14b0c3){logger[_0xa59b('0x12')]('SmsAccount,\x20%s,\x20%s',_0x41cfbd,'request\x20sent');logger[_0xa59b('0x13')](_0xa59b('0x14'),_0x41cfbd,_0xa59b('0x15'),JSON['stringify'](_0x14b0c3));if(_0x14b0c3[_0xa59b('0x16')]){if(_0x14b0c3[_0xa59b('0x16')]['code']===0x1f4){logger[_0xa59b('0x16')](_0xa59b('0x17'),_0x41cfbd,_0x14b0c3[_0xa59b('0x16')]['message']);return _0x3a51d3(_0x14b0c3[_0xa59b('0x16')]['message']);}logger[_0xa59b('0x16')](_0xa59b('0x17'),_0x41cfbd,_0x14b0c3[_0xa59b('0x16')][_0xa59b('0x18')]);return _0x3cec92(_0x14b0c3[_0xa59b('0x16')][_0xa59b('0x18')]);}else{logger['info']('SmsAccount,\x20%s,\x20%s',_0x41cfbd,_0xa59b('0x15'));_0x3cec92(_0x14b0c3[_0xa59b('0x19')][_0xa59b('0x18')]);}})[_0xa59b('0x1a')](function(_0x361e3b){logger[_0xa59b('0x16')](_0xa59b('0x17'),_0x41cfbd,_0x361e3b);_0x3a51d3(_0x361e3b);});});}exports['ShowSmsAccount']=function(_0x5b87cd){var _0x316d55=this;return new Promise(function(_0x37b6fb,_0x7be268){return db[_0xa59b('0x1b')][_0xa59b('0x1c')]({'raw':_0x5b87cd[_0xa59b('0x1d')]?_0x5b87cd[_0xa59b('0x1d')]['raw']===undefined?!![]:![]:!![],'where':_0x5b87cd['options']?_0x5b87cd['options'][_0xa59b('0x1e')]||null:null,'attributes':_0x5b87cd[_0xa59b('0x1d')]?_0x5b87cd[_0xa59b('0x1d')]['attributes']||null:null,'include':_0x5b87cd[_0xa59b('0x1d')]?_0x5b87cd[_0xa59b('0x1d')][_0xa59b('0x1f')]?_['map'](_0x5b87cd[_0xa59b('0x1d')]['include'],function(_0x2ab508){return{'model':db[_0x2ab508[_0xa59b('0x20')]],'as':_0x2ab508['as'],'attributes':_0x2ab508[_0xa59b('0x21')],'include':_0x2ab508[_0xa59b('0x1f')]?_[_0xa59b('0x22')](_0x2ab508[_0xa59b('0x1f')],function(_0x5110e1){return{'model':db[_0x5110e1['model']],'as':_0x5110e1['as'],'attributes':_0x5110e1[_0xa59b('0x21')],'include':_0x5110e1['include']?_[_0xa59b('0x22')](_0x5110e1['include'],function(_0x5516a3){return{'model':db[_0x5516a3['model']],'as':_0x5516a3['as'],'attributes':_0x5516a3[_0xa59b('0x21')]};}):[]};}):[]};}):[]:[]})[_0xa59b('0x11')](function(_0x541179){logger[_0xa59b('0x12')]('ShowSmsAccount',_0x5b87cd);logger[_0xa59b('0x13')](_0xa59b('0x23'),_0x5b87cd,JSON[_0xa59b('0x24')](_0x541179));_0x37b6fb(_0x541179);})[_0xa59b('0x1a')](function(_0x5bb06e){logger['error'](_0xa59b('0x23'),_0x5bb06e[_0xa59b('0x18')],_0x5b87cd);_0x7be268(_0x316d55[_0xa59b('0x16')](0x1f4,_0x5bb06e['message']));});});};