c287e45d8efca313a370a7a028a7455310afe6c4
[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 _0x7ffc=['raw','where','attributes','include','map','model','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','http','redis','localhost','socket.io-emitter','./smsAccount.socket','register','then','SmsAccount,\x20%s,\x20%s','request\x20sent','debug','SmsAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','ShowSmsAccount','options'];(function(_0x48981c,_0x296fd6){var _0x16b52e=function(_0xf1c992){while(--_0xf1c992){_0x48981c['push'](_0x48981c['shift']());}};_0x16b52e(++_0x296fd6);}(_0x7ffc,0xd2));var _0xc7ff=function(_0x822a3f,_0x32fd83){_0x822a3f=_0x822a3f-0x0;var _0x1053e7=_0x7ffc[_0x822a3f];return _0x1053e7;};'use strict';var _=require(_0xc7ff('0x0'));var util=require(_0xc7ff('0x1'));var moment=require(_0xc7ff('0x2'));var BPromise=require(_0xc7ff('0x3'));var rs=require(_0xc7ff('0x4'));var fs=require('fs');var Redis=require(_0xc7ff('0x5'));var db=require(_0xc7ff('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0xc7ff('0x7'))('rpc');var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson['client'][_0xc7ff('0x8')]({'port':0x232a});config[_0xc7ff('0x9')]=_['defaults'](config['redis'],{'host':_0xc7ff('0xa'),'port':0x18eb});var socket=require(_0xc7ff('0xb'))(new Redis(config[_0xc7ff('0x9')]));require(_0xc7ff('0xc'))[_0xc7ff('0xd')](socket);function respondWithRpcPromise(_0x406b8e,_0x1bc9b2,_0x4aa6e0){return new BPromise(function(_0x28d385,_0x22e9be){return client['request'](_0x406b8e,_0x4aa6e0)[_0xc7ff('0xe')](function(_0x4d2c58){logger['info'](_0xc7ff('0xf'),_0x1bc9b2,_0xc7ff('0x10'));logger[_0xc7ff('0x11')](_0xc7ff('0x12'),_0x1bc9b2,'request\x20sent',JSON[_0xc7ff('0x13')](_0x4d2c58));if(_0x4d2c58['error']){if(_0x4d2c58[_0xc7ff('0x14')][_0xc7ff('0x15')]===0x1f4){logger[_0xc7ff('0x14')](_0xc7ff('0xf'),_0x1bc9b2,_0x4d2c58[_0xc7ff('0x14')][_0xc7ff('0x16')]);return _0x22e9be(_0x4d2c58[_0xc7ff('0x14')][_0xc7ff('0x16')]);}logger[_0xc7ff('0x14')]('SmsAccount,\x20%s,\x20%s',_0x1bc9b2,_0x4d2c58['error']['message']);return _0x28d385(_0x4d2c58[_0xc7ff('0x14')][_0xc7ff('0x16')]);}else{logger[_0xc7ff('0x17')](_0xc7ff('0xf'),_0x1bc9b2,_0xc7ff('0x10'));_0x28d385(_0x4d2c58[_0xc7ff('0x18')][_0xc7ff('0x16')]);}})[_0xc7ff('0x19')](function(_0x32a219){logger[_0xc7ff('0x14')]('SmsAccount,\x20%s,\x20%s',_0x1bc9b2,_0x32a219);_0x22e9be(_0x32a219);});});}exports[_0xc7ff('0x1a')]=function(_0x171821){var _0x781632=this;return new Promise(function(_0x32de85,_0x362705){return db['SmsAccount']['find']({'raw':_0x171821[_0xc7ff('0x1b')]?_0x171821['options'][_0xc7ff('0x1c')]===undefined?!![]:![]:!![],'where':_0x171821[_0xc7ff('0x1b')]?_0x171821[_0xc7ff('0x1b')][_0xc7ff('0x1d')]||null:null,'attributes':_0x171821[_0xc7ff('0x1b')]?_0x171821[_0xc7ff('0x1b')][_0xc7ff('0x1e')]||null:null,'include':_0x171821[_0xc7ff('0x1b')]?_0x171821[_0xc7ff('0x1b')][_0xc7ff('0x1f')]?_[_0xc7ff('0x20')](_0x171821['options'][_0xc7ff('0x1f')],function(_0x4b2812){return{'model':db[_0x4b2812[_0xc7ff('0x21')]],'as':_0x4b2812['as'],'attributes':_0x4b2812['attributes'],'include':_0x4b2812['include']?_[_0xc7ff('0x20')](_0x4b2812[_0xc7ff('0x1f')],function(_0x2b4268){return{'model':db[_0x2b4268[_0xc7ff('0x21')]],'as':_0x2b4268['as'],'attributes':_0x2b4268[_0xc7ff('0x1e')],'include':_0x2b4268[_0xc7ff('0x1f')]?_[_0xc7ff('0x20')](_0x2b4268[_0xc7ff('0x1f')],function(_0x3d5bfc){return{'model':db[_0x3d5bfc[_0xc7ff('0x21')]],'as':_0x3d5bfc['as'],'attributes':_0x3d5bfc['attributes']};}):[]};}):[]};}):[]:[]})[_0xc7ff('0xe')](function(_0xd95e44){logger[_0xc7ff('0x17')](_0xc7ff('0x1a'),_0x171821);logger['debug'](_0xc7ff('0x1a'),_0x171821,JSON['stringify'](_0xd95e44));_0x32de85(_0xd95e44);})['catch'](function(_0xd272f8){logger[_0xc7ff('0x14')](_0xc7ff('0x1a'),_0xd272f8['message'],_0x171821);_0x362705(_0x781632[_0xc7ff('0x14')](0x1f4,_0xd272f8[_0xc7ff('0x16')]));});});};