Built motion from commit 351e7f9c.|2.6.31
[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 _0xaf19=['stringify','util','moment','randomstring','../../config/utils','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','register','then','info','SmsAccount,\x20%s,\x20%s','debug','SmsAccount,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','result','catch','SmsAccount','options','raw','attributes','include','map','model','ShowSmsAccount'];(function(_0x4cb748,_0x37c98d){var _0x263ccf=function(_0x2fa86c){while(--_0x2fa86c){_0x4cb748['push'](_0x4cb748['shift']());}};_0x263ccf(++_0x37c98d);}(_0xaf19,0x1cf));var _0x9af1=function(_0x38b0be,_0x1743eb){_0x38b0be=_0x38b0be-0x0;var _0x2cdb0e=_0xaf19[_0x38b0be];return _0x2cdb0e;};'use strict';var _=require('lodash');var util=require(_0x9af1('0x0'));var moment=require(_0x9af1('0x1'));var BPromise=require('bluebird');var rs=require(_0x9af1('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x9af1('0x3'));var logger=require('../../config/logger')('rpc');var config=require(_0x9af1('0x4'));var jayson=require(_0x9af1('0x5'));var client=jayson[_0x9af1('0x6')][_0x9af1('0x7')]({'port':0x232a});config[_0x9af1('0x8')]=_[_0x9af1('0x9')](config[_0x9af1('0x8')],{'host':_0x9af1('0xa'),'port':0x18eb});var socket=require(_0x9af1('0xb'))(new Redis(config[_0x9af1('0x8')]));require('./smsAccount.socket')[_0x9af1('0xc')](socket);function respondWithRpcPromise(_0x3f94c2,_0x2fdd1a,_0x3963ab){return new BPromise(function(_0xcdc266,_0x1b4132){return client['request'](_0x3f94c2,_0x3963ab)[_0x9af1('0xd')](function(_0x2c83b6){logger[_0x9af1('0xe')](_0x9af1('0xf'),_0x2fdd1a,'request\x20sent');logger[_0x9af1('0x10')](_0x9af1('0x11'),_0x2fdd1a,_0x9af1('0x12'),JSON['stringify'](_0x2c83b6));if(_0x2c83b6[_0x9af1('0x13')]){if(_0x2c83b6['error'][_0x9af1('0x14')]===0x1f4){logger['error'](_0x9af1('0xf'),_0x2fdd1a,_0x2c83b6[_0x9af1('0x13')][_0x9af1('0x15')]);return _0x1b4132(_0x2c83b6[_0x9af1('0x13')][_0x9af1('0x15')]);}logger[_0x9af1('0x13')](_0x9af1('0xf'),_0x2fdd1a,_0x2c83b6[_0x9af1('0x13')][_0x9af1('0x15')]);return _0xcdc266(_0x2c83b6[_0x9af1('0x13')][_0x9af1('0x15')]);}else{logger[_0x9af1('0xe')](_0x9af1('0xf'),_0x2fdd1a,_0x9af1('0x12'));_0xcdc266(_0x2c83b6[_0x9af1('0x16')][_0x9af1('0x15')]);}})[_0x9af1('0x17')](function(_0x19e0cd){logger[_0x9af1('0x13')](_0x9af1('0xf'),_0x2fdd1a,_0x19e0cd);_0x1b4132(_0x19e0cd);});});}exports['ShowSmsAccount']=function(_0x49e736){var _0x2022f4=this;return new Promise(function(_0x28f016,_0x3da095){return db[_0x9af1('0x18')]['find']({'raw':_0x49e736[_0x9af1('0x19')]?_0x49e736[_0x9af1('0x19')][_0x9af1('0x1a')]===undefined?!![]:![]:!![],'where':_0x49e736[_0x9af1('0x19')]?_0x49e736[_0x9af1('0x19')]['where']||null:null,'attributes':_0x49e736[_0x9af1('0x19')]?_0x49e736[_0x9af1('0x19')][_0x9af1('0x1b')]||null:null,'include':_0x49e736[_0x9af1('0x19')]?_0x49e736['options'][_0x9af1('0x1c')]?_[_0x9af1('0x1d')](_0x49e736['options'][_0x9af1('0x1c')],function(_0x521f56){return{'model':db[_0x521f56[_0x9af1('0x1e')]],'as':_0x521f56['as'],'attributes':_0x521f56[_0x9af1('0x1b')],'include':_0x521f56['include']?_[_0x9af1('0x1d')](_0x521f56[_0x9af1('0x1c')],function(_0x529302){return{'model':db[_0x529302[_0x9af1('0x1e')]],'as':_0x529302['as'],'attributes':_0x529302[_0x9af1('0x1b')],'include':_0x529302[_0x9af1('0x1c')]?_[_0x9af1('0x1d')](_0x529302[_0x9af1('0x1c')],function(_0x1ffb77){return{'model':db[_0x1ffb77[_0x9af1('0x1e')]],'as':_0x1ffb77['as'],'attributes':_0x1ffb77[_0x9af1('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x9af1('0xd')](function(_0x13bcd9){logger[_0x9af1('0xe')](_0x9af1('0x1f'),_0x49e736);logger[_0x9af1('0x10')](_0x9af1('0x1f'),_0x49e736,JSON[_0x9af1('0x20')](_0x13bcd9));_0x28f016(_0x13bcd9);})[_0x9af1('0x17')](function(_0x5121f0){logger['error'](_0x9af1('0x1f'),_0x5121f0[_0x9af1('0x15')],_0x49e736);_0x3da095(_0x2022f4['error'](0x1f4,_0x5121f0['message']));});});};