Built motion from commit 47436d59.|2.6.7
[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 _0xeba7=['info','SmsAccount,\x20%s,\x20%s','request\x20sent','debug','SmsAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','ShowSmsAccount','SmsAccount','find','options','raw','where','attributes','include','map','model','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','http','defaults','redis','localhost','socket.io-emitter','./smsAccount.socket','register','then'];(function(_0x154704,_0x11999a){var _0x13f50d=function(_0x1974d0){while(--_0x1974d0){_0x154704['push'](_0x154704['shift']());}};_0x13f50d(++_0x11999a);}(_0xeba7,0x14d));var _0x7eba=function(_0x1fd646,_0x117207){_0x1fd646=_0x1fd646-0x0;var _0x5e1b00=_0xeba7[_0x1fd646];return _0x5e1b00;};'use strict';var _=require('lodash');var util=require(_0x7eba('0x0'));var moment=require(_0x7eba('0x1'));var BPromise=require('bluebird');var rs=require(_0x7eba('0x2'));var fs=require('fs');var Redis=require(_0x7eba('0x3'));var db=require(_0x7eba('0x4'))['db'];var utils=require(_0x7eba('0x5'));var logger=require(_0x7eba('0x6'))(_0x7eba('0x7'));var config=require('../../config/environment');var jayson=require(_0x7eba('0x8'));var client=jayson['client'][_0x7eba('0x9')]({'port':0x232a});config['redis']=_[_0x7eba('0xa')](config[_0x7eba('0xb')],{'host':_0x7eba('0xc'),'port':0x18eb});var socket=require(_0x7eba('0xd'))(new Redis(config[_0x7eba('0xb')]));require(_0x7eba('0xe'))[_0x7eba('0xf')](socket);function respondWithRpcPromise(_0x20c76d,_0x3a6c5f,_0x27f6f4){return new BPromise(function(_0x136f97,_0x430d89){return client['request'](_0x20c76d,_0x27f6f4)[_0x7eba('0x10')](function(_0x2a827a){logger[_0x7eba('0x11')](_0x7eba('0x12'),_0x3a6c5f,_0x7eba('0x13'));logger[_0x7eba('0x14')](_0x7eba('0x15'),_0x3a6c5f,_0x7eba('0x13'),JSON[_0x7eba('0x16')](_0x2a827a));if(_0x2a827a[_0x7eba('0x17')]){if(_0x2a827a[_0x7eba('0x17')]['code']===0x1f4){logger[_0x7eba('0x17')](_0x7eba('0x12'),_0x3a6c5f,_0x2a827a[_0x7eba('0x17')][_0x7eba('0x18')]);return _0x430d89(_0x2a827a[_0x7eba('0x17')][_0x7eba('0x18')]);}logger[_0x7eba('0x17')](_0x7eba('0x12'),_0x3a6c5f,_0x2a827a[_0x7eba('0x17')][_0x7eba('0x18')]);return _0x136f97(_0x2a827a['error'][_0x7eba('0x18')]);}else{logger[_0x7eba('0x11')](_0x7eba('0x12'),_0x3a6c5f,_0x7eba('0x13'));_0x136f97(_0x2a827a['result']['message']);}})['catch'](function(_0x287b8c){logger[_0x7eba('0x17')]('SmsAccount,\x20%s,\x20%s',_0x3a6c5f,_0x287b8c);_0x430d89(_0x287b8c);});});}exports[_0x7eba('0x19')]=function(_0x18f35a){var _0x488d39=this;return new Promise(function(_0x223609,_0x444a04){return db[_0x7eba('0x1a')][_0x7eba('0x1b')]({'raw':_0x18f35a[_0x7eba('0x1c')]?_0x18f35a[_0x7eba('0x1c')][_0x7eba('0x1d')]===undefined?!![]:![]:!![],'where':_0x18f35a[_0x7eba('0x1c')]?_0x18f35a[_0x7eba('0x1c')][_0x7eba('0x1e')]||null:null,'attributes':_0x18f35a['options']?_0x18f35a['options'][_0x7eba('0x1f')]||null:null,'include':_0x18f35a[_0x7eba('0x1c')]?_0x18f35a[_0x7eba('0x1c')][_0x7eba('0x20')]?_[_0x7eba('0x21')](_0x18f35a['options'][_0x7eba('0x20')],function(_0x2980ee){return{'model':db[_0x2980ee[_0x7eba('0x22')]],'as':_0x2980ee['as'],'attributes':_0x2980ee[_0x7eba('0x1f')],'include':_0x2980ee[_0x7eba('0x20')]?_[_0x7eba('0x21')](_0x2980ee['include'],function(_0x39ef07){return{'model':db[_0x39ef07[_0x7eba('0x22')]],'as':_0x39ef07['as'],'attributes':_0x39ef07[_0x7eba('0x1f')],'include':_0x39ef07[_0x7eba('0x20')]?_[_0x7eba('0x21')](_0x39ef07[_0x7eba('0x20')],function(_0x25afd6){return{'model':db[_0x25afd6[_0x7eba('0x22')]],'as':_0x25afd6['as'],'attributes':_0x25afd6['attributes']};}):[]};}):[]};}):[]:[]})[_0x7eba('0x10')](function(_0x3ba03c){logger[_0x7eba('0x11')](_0x7eba('0x19'),_0x18f35a);logger['debug'](_0x7eba('0x19'),_0x18f35a,JSON[_0x7eba('0x16')](_0x3ba03c));_0x223609(_0x3ba03c);})['catch'](function(_0x3a1a60){logger['error'](_0x7eba('0x19'),_0x3a1a60[_0x7eba('0x18')],_0x18f35a);_0x444a04(_0x488d39['error'](0x1f4,_0x3a1a60[_0x7eba('0x18')]));});});};