Built motion from commit (unavailable).|2.3.0
[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 _0xe072=['include','model','ShowSmsAccount','lodash','moment','bluebird','../../mysqldb','../../config/utils','rpc','client','redis','defaults','socket.io-emitter','./smsAccount.socket','register','request','then','info','SmsAccount,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','result','catch','SmsAccount','find','options','attributes','map'];(function(_0x242d17,_0x30a922){var _0x501a6d=function(_0x4227e4){while(--_0x4227e4){_0x242d17['push'](_0x242d17['shift']());}};_0x501a6d(++_0x30a922);}(_0xe072,0xfb));var _0x2e07=function(_0xb47a00,_0x14784e){_0xb47a00=_0xb47a00-0x0;var _0x35bb27=_0xe072[_0xb47a00];return _0x35bb27;};'use strict';var _=require(_0x2e07('0x0'));var util=require('util');var moment=require(_0x2e07('0x1'));var BPromise=require(_0x2e07('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x2e07('0x3'))['db'];var utils=require(_0x2e07('0x4'));var logger=require('../../config/logger')(_0x2e07('0x5'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x2e07('0x6')]['http']({'port':0x232a});config[_0x2e07('0x7')]=_[_0x2e07('0x8')](config[_0x2e07('0x7')],{'host':'localhost','port':0x18eb});var socket=require(_0x2e07('0x9'))(new Redis(config[_0x2e07('0x7')]));require(_0x2e07('0xa'))[_0x2e07('0xb')](socket);function respondWithRpcPromise(_0x150f51,_0x1d30b4,_0x62a6b7){return new BPromise(function(_0x4a5a53,_0x3ae467){return client[_0x2e07('0xc')](_0x150f51,_0x62a6b7)[_0x2e07('0xd')](function(_0x4aeaef){logger[_0x2e07('0xe')](_0x2e07('0xf'),_0x1d30b4,_0x2e07('0x10'));logger[_0x2e07('0x11')]('SmsAccount,\x20%s,\x20%s,\x20%s',_0x1d30b4,'request\x20sent',JSON[_0x2e07('0x12')](_0x4aeaef));if(_0x4aeaef[_0x2e07('0x13')]){if(_0x4aeaef[_0x2e07('0x13')]['code']===0x1f4){logger[_0x2e07('0x13')](_0x2e07('0xf'),_0x1d30b4,_0x4aeaef['error']['message']);return _0x3ae467(_0x4aeaef[_0x2e07('0x13')][_0x2e07('0x14')]);}logger[_0x2e07('0x13')](_0x2e07('0xf'),_0x1d30b4,_0x4aeaef[_0x2e07('0x13')]['message']);return _0x4a5a53(_0x4aeaef[_0x2e07('0x13')]['message']);}else{logger[_0x2e07('0xe')](_0x2e07('0xf'),_0x1d30b4,'request\x20sent');_0x4a5a53(_0x4aeaef[_0x2e07('0x15')][_0x2e07('0x14')]);}})[_0x2e07('0x16')](function(_0x3105a9){logger['error'](_0x2e07('0xf'),_0x1d30b4,_0x3105a9);_0x3ae467(_0x3105a9);});});}exports['ShowSmsAccount']=function(_0x5c50e8){var _0xccfbd2=this;return new Promise(function(_0xb9f82f,_0x320d05){return db[_0x2e07('0x17')][_0x2e07('0x18')]({'raw':_0x5c50e8['options']?_0x5c50e8[_0x2e07('0x19')]['raw']===undefined?!![]:![]:!![],'where':_0x5c50e8[_0x2e07('0x19')]?_0x5c50e8[_0x2e07('0x19')]['where']||null:null,'attributes':_0x5c50e8['options']?_0x5c50e8[_0x2e07('0x19')][_0x2e07('0x1a')]||null:null,'include':_0x5c50e8[_0x2e07('0x19')]?_0x5c50e8['options']['include']?_[_0x2e07('0x1b')](_0x5c50e8[_0x2e07('0x19')][_0x2e07('0x1c')],function(_0x26c49c){return{'model':db[_0x26c49c['model']],'as':_0x26c49c['as'],'attributes':_0x26c49c['attributes'],'include':_0x26c49c[_0x2e07('0x1c')]?_[_0x2e07('0x1b')](_0x26c49c[_0x2e07('0x1c')],function(_0x244583){return{'model':db[_0x244583[_0x2e07('0x1d')]],'as':_0x244583['as'],'attributes':_0x244583[_0x2e07('0x1a')],'include':_0x244583[_0x2e07('0x1c')]?_[_0x2e07('0x1b')](_0x244583['include'],function(_0xe9ab8f){return{'model':db[_0xe9ab8f[_0x2e07('0x1d')]],'as':_0xe9ab8f['as'],'attributes':_0xe9ab8f[_0x2e07('0x1a')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x2b73d6){logger[_0x2e07('0xe')](_0x2e07('0x1e'),_0x5c50e8);logger[_0x2e07('0x11')](_0x2e07('0x1e'),_0x5c50e8,JSON['stringify'](_0x2b73d6));_0xb9f82f(_0x2b73d6);})[_0x2e07('0x16')](function(_0x4e95e7){logger[_0x2e07('0x13')](_0x2e07('0x1e'),_0x4e95e7[_0x2e07('0x14')],_0x5c50e8);_0x320d05(_0xccfbd2[_0x2e07('0x13')](0x1f4,_0x4e95e7[_0x2e07('0x14')]));});});};