1b4ad7287df7d083be6af4fdbf22805b1cad00b7
[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 _0x2f57=['catch','util','bluebird','randomstring','ioredis','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./smsAccount.socket','register','then','info','SmsAccount,\x20%s,\x20%s','request\x20sent','debug','SmsAccount,\x20%s,\x20%s,\x20%s','error','message','result','ShowSmsAccount','SmsAccount','find','options','raw','where','attributes','include','map','model','stringify'];(function(_0x2adb6a,_0x6b50f3){var _0x575613=function(_0x3e9ebc){while(--_0x3e9ebc){_0x2adb6a['push'](_0x2adb6a['shift']());}};_0x575613(++_0x6b50f3);}(_0x2f57,0x104));var _0x72f5=function(_0xbb126a,_0x2223ac){_0xbb126a=_0xbb126a-0x0;var _0x9bbdf4=_0x2f57[_0xbb126a];return _0x9bbdf4;};'use strict';var _=require('lodash');var util=require(_0x72f5('0x0'));var moment=require('moment');var BPromise=require(_0x72f5('0x1'));var rs=require(_0x72f5('0x2'));var fs=require('fs');var Redis=require(_0x72f5('0x3'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x72f5('0x4'))(_0x72f5('0x5'));var config=require(_0x72f5('0x6'));var jayson=require(_0x72f5('0x7'));var client=jayson[_0x72f5('0x8')][_0x72f5('0x9')]({'port':0x232a});config[_0x72f5('0xa')]=_[_0x72f5('0xb')](config[_0x72f5('0xa')],{'host':_0x72f5('0xc'),'port':0x18eb});var socket=require(_0x72f5('0xd'))(new Redis(config[_0x72f5('0xa')]));require(_0x72f5('0xe'))[_0x72f5('0xf')](socket);function respondWithRpcPromise(_0x55ce47,_0x42f496,_0x4af632){return new BPromise(function(_0x2d2c52,_0x5c411){return client['request'](_0x55ce47,_0x4af632)[_0x72f5('0x10')](function(_0x2a26b4){logger[_0x72f5('0x11')](_0x72f5('0x12'),_0x42f496,_0x72f5('0x13'));logger[_0x72f5('0x14')](_0x72f5('0x15'),_0x42f496,'request\x20sent',JSON['stringify'](_0x2a26b4));if(_0x2a26b4[_0x72f5('0x16')]){if(_0x2a26b4[_0x72f5('0x16')]['code']===0x1f4){logger[_0x72f5('0x16')](_0x72f5('0x12'),_0x42f496,_0x2a26b4[_0x72f5('0x16')][_0x72f5('0x17')]);return _0x5c411(_0x2a26b4[_0x72f5('0x16')][_0x72f5('0x17')]);}logger['error'](_0x72f5('0x12'),_0x42f496,_0x2a26b4[_0x72f5('0x16')][_0x72f5('0x17')]);return _0x2d2c52(_0x2a26b4['error'][_0x72f5('0x17')]);}else{logger[_0x72f5('0x11')](_0x72f5('0x12'),_0x42f496,'request\x20sent');_0x2d2c52(_0x2a26b4[_0x72f5('0x18')][_0x72f5('0x17')]);}})['catch'](function(_0x374725){logger['error'](_0x72f5('0x12'),_0x42f496,_0x374725);_0x5c411(_0x374725);});});}exports[_0x72f5('0x19')]=function(_0x70aa25){var _0x44c204=this;return new Promise(function(_0x101da8,_0x3b65a3){return db[_0x72f5('0x1a')][_0x72f5('0x1b')]({'raw':_0x70aa25[_0x72f5('0x1c')]?_0x70aa25[_0x72f5('0x1c')][_0x72f5('0x1d')]===undefined?!![]:![]:!![],'where':_0x70aa25[_0x72f5('0x1c')]?_0x70aa25[_0x72f5('0x1c')][_0x72f5('0x1e')]||null:null,'attributes':_0x70aa25[_0x72f5('0x1c')]?_0x70aa25[_0x72f5('0x1c')][_0x72f5('0x1f')]||null:null,'include':_0x70aa25[_0x72f5('0x1c')]?_0x70aa25[_0x72f5('0x1c')][_0x72f5('0x20')]?_[_0x72f5('0x21')](_0x70aa25[_0x72f5('0x1c')][_0x72f5('0x20')],function(_0x45c8de){return{'model':db[_0x45c8de[_0x72f5('0x22')]],'as':_0x45c8de['as'],'attributes':_0x45c8de[_0x72f5('0x1f')],'include':_0x45c8de[_0x72f5('0x20')]?_[_0x72f5('0x21')](_0x45c8de[_0x72f5('0x20')],function(_0x138f0c){return{'model':db[_0x138f0c[_0x72f5('0x22')]],'as':_0x138f0c['as'],'attributes':_0x138f0c[_0x72f5('0x1f')],'include':_0x138f0c['include']?_[_0x72f5('0x21')](_0x138f0c[_0x72f5('0x20')],function(_0x3176bf){return{'model':db[_0x3176bf['model']],'as':_0x3176bf['as'],'attributes':_0x3176bf['attributes']};}):[]};}):[]};}):[]:[]})[_0x72f5('0x10')](function(_0x3bd05d){logger['info'](_0x72f5('0x19'),_0x70aa25);logger['debug'](_0x72f5('0x19'),_0x70aa25,JSON[_0x72f5('0x23')](_0x3bd05d));_0x101da8(_0x3bd05d);})[_0x72f5('0x24')](function(_0x1b614e){logger[_0x72f5('0x16')](_0x72f5('0x19'),_0x1b614e['message'],_0x70aa25);_0x3b65a3(_0x44c204[_0x72f5('0x16')](0x1f4,_0x1b614e['message']));});});};