Built motion from commit 9c91e9f5.|2.6.29
[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 _0x2f33=['bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','request','then','info','SmsAccount,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','catch','SmsAccount','options','raw','where','attributes','include','map','model','ShowSmsAccount','lodash'];(function(_0x2aaa68,_0x5baa84){var _0x523f8f=function(_0xe67a25){while(--_0xe67a25){_0x2aaa68['push'](_0x2aaa68['shift']());}};_0x523f8f(++_0x5baa84);}(_0x2f33,0xa4));var _0x32f3=function(_0x3af851,_0x396f25){_0x3af851=_0x3af851-0x0;var _0x3aeed6=_0x2f33[_0x3af851];return _0x3aeed6;};'use strict';var _=require(_0x32f3('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x32f3('0x1'));var rs=require(_0x32f3('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x32f3('0x3'))['db'];var utils=require(_0x32f3('0x4'));var logger=require(_0x32f3('0x5'))('rpc');var config=require(_0x32f3('0x6'));var jayson=require(_0x32f3('0x7'));var client=jayson[_0x32f3('0x8')][_0x32f3('0x9')]({'port':0x232a});config[_0x32f3('0xa')]=_[_0x32f3('0xb')](config[_0x32f3('0xa')],{'host':_0x32f3('0xc'),'port':0x18eb});var socket=require(_0x32f3('0xd'))(new Redis(config[_0x32f3('0xa')]));require('./smsAccount.socket')['register'](socket);function respondWithRpcPromise(_0x3df58f,_0x2eb32c,_0x49287f){return new BPromise(function(_0x4d19fb,_0x427b25){return client[_0x32f3('0xe')](_0x3df58f,_0x49287f)[_0x32f3('0xf')](function(_0x3ed4e6){logger[_0x32f3('0x10')](_0x32f3('0x11'),_0x2eb32c,_0x32f3('0x12'));logger['debug']('SmsAccount,\x20%s,\x20%s,\x20%s',_0x2eb32c,_0x32f3('0x12'),JSON[_0x32f3('0x13')](_0x3ed4e6));if(_0x3ed4e6[_0x32f3('0x14')]){if(_0x3ed4e6[_0x32f3('0x14')][_0x32f3('0x15')]===0x1f4){logger[_0x32f3('0x14')](_0x32f3('0x11'),_0x2eb32c,_0x3ed4e6[_0x32f3('0x14')][_0x32f3('0x16')]);return _0x427b25(_0x3ed4e6[_0x32f3('0x14')][_0x32f3('0x16')]);}logger[_0x32f3('0x14')](_0x32f3('0x11'),_0x2eb32c,_0x3ed4e6[_0x32f3('0x14')]['message']);return _0x4d19fb(_0x3ed4e6[_0x32f3('0x14')][_0x32f3('0x16')]);}else{logger[_0x32f3('0x10')](_0x32f3('0x11'),_0x2eb32c,_0x32f3('0x12'));_0x4d19fb(_0x3ed4e6['result'][_0x32f3('0x16')]);}})[_0x32f3('0x17')](function(_0x4ce0b3){logger[_0x32f3('0x14')](_0x32f3('0x11'),_0x2eb32c,_0x4ce0b3);_0x427b25(_0x4ce0b3);});});}exports['ShowSmsAccount']=function(_0x473971){var _0x2afc02=this;return new Promise(function(_0x1f3ae5,_0xa809ae){return db[_0x32f3('0x18')]['find']({'raw':_0x473971[_0x32f3('0x19')]?_0x473971['options'][_0x32f3('0x1a')]===undefined?!![]:![]:!![],'where':_0x473971[_0x32f3('0x19')]?_0x473971[_0x32f3('0x19')][_0x32f3('0x1b')]||null:null,'attributes':_0x473971[_0x32f3('0x19')]?_0x473971['options'][_0x32f3('0x1c')]||null:null,'include':_0x473971[_0x32f3('0x19')]?_0x473971[_0x32f3('0x19')][_0x32f3('0x1d')]?_[_0x32f3('0x1e')](_0x473971[_0x32f3('0x19')][_0x32f3('0x1d')],function(_0xc4378e){return{'model':db[_0xc4378e[_0x32f3('0x1f')]],'as':_0xc4378e['as'],'attributes':_0xc4378e['attributes'],'include':_0xc4378e[_0x32f3('0x1d')]?_[_0x32f3('0x1e')](_0xc4378e['include'],function(_0x3aadde){return{'model':db[_0x3aadde[_0x32f3('0x1f')]],'as':_0x3aadde['as'],'attributes':_0x3aadde['attributes'],'include':_0x3aadde['include']?_[_0x32f3('0x1e')](_0x3aadde[_0x32f3('0x1d')],function(_0x53ef7e){return{'model':db[_0x53ef7e[_0x32f3('0x1f')]],'as':_0x53ef7e['as'],'attributes':_0x53ef7e['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x4a8238){logger[_0x32f3('0x10')](_0x32f3('0x20'),_0x473971);logger['debug']('ShowSmsAccount',_0x473971,JSON[_0x32f3('0x13')](_0x4a8238));_0x1f3ae5(_0x4a8238);})[_0x32f3('0x17')](function(_0x3627a8){logger[_0x32f3('0x14')]('ShowSmsAccount',_0x3627a8[_0x32f3('0x16')],_0x473971);_0xa809ae(_0x2afc02[_0x32f3('0x14')](0x1f4,_0x3627a8[_0x32f3('0x16')]));});});};