7fb132a24788e047ffba96711250fed1326bf8e0
[motion2.git] / server / api / smsQueue / smsQueue.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 _0xb769=['http','defaults','redis','localhost','socket.io-emitter','./smsQueue.socket','register','request','then','info','SmsQueue,\x20%s,\x20%s','debug','SmsQueue,\x20%s,\x20%s,\x20%s','code','error','message','request\x20sent','catch','GetSmsQueue','SmsQueue','findAll','options','where','limit','map','include','attributes','model','ShowSmsQueue','find','stringify','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client'];(function(_0x4fc421,_0x94e88){var _0x8c6d63=function(_0x5b8b42){while(--_0x5b8b42){_0x4fc421['push'](_0x4fc421['shift']());}};_0x8c6d63(++_0x94e88);}(_0xb769,0x115));var _0x9b76=function(_0x3741d8,_0x4f0e08){_0x3741d8=_0x3741d8-0x0;var _0x3e824e=_0xb769[_0x3741d8];return _0x3e824e;};'use strict';var _=require('lodash');var util=require(_0x9b76('0x0'));var moment=require(_0x9b76('0x1'));var BPromise=require('bluebird');var rs=require(_0x9b76('0x2'));var fs=require('fs');var Redis=require(_0x9b76('0x3'));var db=require(_0x9b76('0x4'))['db'];var utils=require(_0x9b76('0x5'));var logger=require(_0x9b76('0x6'))(_0x9b76('0x7'));var config=require('../../config/environment');var jayson=require(_0x9b76('0x8'));var client=jayson[_0x9b76('0x9')][_0x9b76('0xa')]({'port':0x232a});config['redis']=_[_0x9b76('0xb')](config[_0x9b76('0xc')],{'host':_0x9b76('0xd'),'port':0x18eb});var socket=require(_0x9b76('0xe'))(new Redis(config[_0x9b76('0xc')]));require(_0x9b76('0xf'))[_0x9b76('0x10')](socket);function respondWithRpcPromise(_0x57996c,_0x32e7d3,_0x3af47b){return new BPromise(function(_0x3b9573,_0x5b49a2){return client[_0x9b76('0x11')](_0x57996c,_0x3af47b)[_0x9b76('0x12')](function(_0x1df64a){logger[_0x9b76('0x13')](_0x9b76('0x14'),_0x32e7d3,'request\x20sent');logger[_0x9b76('0x15')](_0x9b76('0x16'),_0x32e7d3,'request\x20sent',JSON['stringify'](_0x1df64a));if(_0x1df64a['error']){if(_0x1df64a['error'][_0x9b76('0x17')]===0x1f4){logger[_0x9b76('0x18')](_0x9b76('0x14'),_0x32e7d3,_0x1df64a[_0x9b76('0x18')][_0x9b76('0x19')]);return _0x5b49a2(_0x1df64a[_0x9b76('0x18')][_0x9b76('0x19')]);}logger[_0x9b76('0x18')](_0x9b76('0x14'),_0x32e7d3,_0x1df64a[_0x9b76('0x18')][_0x9b76('0x19')]);return _0x3b9573(_0x1df64a[_0x9b76('0x18')][_0x9b76('0x19')]);}else{logger[_0x9b76('0x13')](_0x9b76('0x14'),_0x32e7d3,_0x9b76('0x1a'));_0x3b9573(_0x1df64a['result'][_0x9b76('0x19')]);}})[_0x9b76('0x1b')](function(_0x1b857b){logger['error'](_0x9b76('0x14'),_0x32e7d3,_0x1b857b);_0x5b49a2(_0x1b857b);});});}exports[_0x9b76('0x1c')]=function(_0x596058){var _0x3d6a32=this;return new Promise(function(_0x1bc3e0,_0x1d96d9){return db[_0x9b76('0x1d')][_0x9b76('0x1e')]({'raw':_0x596058[_0x9b76('0x1f')]?_0x596058['options']['raw']===undefined?!![]:![]:!![],'where':_0x596058[_0x9b76('0x1f')]?_0x596058[_0x9b76('0x1f')][_0x9b76('0x20')]||null:null,'attributes':_0x596058[_0x9b76('0x1f')]?_0x596058['options']['attributes']||null:null,'limit':_0x596058[_0x9b76('0x1f')]?_0x596058['options'][_0x9b76('0x21')]||null:null,'include':_0x596058[_0x9b76('0x1f')]?_0x596058[_0x9b76('0x1f')]['include']?_[_0x9b76('0x22')](_0x596058['options'][_0x9b76('0x23')],function(_0x321536){return{'model':db[_0x321536['model']],'as':_0x321536['as'],'attributes':_0x321536[_0x9b76('0x24')],'include':_0x321536[_0x9b76('0x23')]?_['map'](_0x321536[_0x9b76('0x23')],function(_0x423266){return{'model':db[_0x423266[_0x9b76('0x25')]],'as':_0x423266['as'],'attributes':_0x423266['attributes'],'include':_0x423266[_0x9b76('0x23')]?_['map'](_0x423266['include'],function(_0x1d4083){return{'model':db[_0x1d4083[_0x9b76('0x25')]],'as':_0x1d4083['as'],'attributes':_0x1d4083[_0x9b76('0x24')]};}):[]};}):[]};}):[]:[]})[_0x9b76('0x12')](function(_0x492ea3){logger[_0x9b76('0x13')]('GetSmsQueue',_0x596058);logger[_0x9b76('0x15')](_0x9b76('0x1c'),_0x596058,JSON['stringify'](_0x492ea3));_0x1bc3e0(_0x492ea3);})[_0x9b76('0x1b')](function(_0x15484b){logger[_0x9b76('0x18')](_0x9b76('0x1c'),_0x15484b[_0x9b76('0x19')],_0x596058);_0x1d96d9(_0x3d6a32[_0x9b76('0x18')](0x1f4,_0x15484b[_0x9b76('0x19')]));});});};exports[_0x9b76('0x26')]=function(_0x279251){var _0x2c67e7=this;return new Promise(function(_0x2d4912,_0x3acb01){return db[_0x9b76('0x1d')][_0x9b76('0x27')]({'raw':_0x279251[_0x9b76('0x1f')]?_0x279251[_0x9b76('0x1f')]['raw']===undefined?!![]:![]:!![],'where':_0x279251['options']?_0x279251['options'][_0x9b76('0x20')]||null:null,'attributes':_0x279251[_0x9b76('0x1f')]?_0x279251['options']['attributes']||null:null,'include':_0x279251[_0x9b76('0x1f')]?_0x279251['options'][_0x9b76('0x23')]?_[_0x9b76('0x22')](_0x279251['options'][_0x9b76('0x23')],function(_0x25d621){return{'model':db[_0x25d621[_0x9b76('0x25')]],'as':_0x25d621['as'],'attributes':_0x25d621[_0x9b76('0x24')],'include':_0x25d621[_0x9b76('0x23')]?_[_0x9b76('0x22')](_0x25d621['include'],function(_0x3e7395){return{'model':db[_0x3e7395[_0x9b76('0x25')]],'as':_0x3e7395['as'],'attributes':_0x3e7395['attributes'],'include':_0x3e7395[_0x9b76('0x23')]?_[_0x9b76('0x22')](_0x3e7395[_0x9b76('0x23')],function(_0x1df06c){return{'model':db[_0x1df06c[_0x9b76('0x25')]],'as':_0x1df06c['as'],'attributes':_0x1df06c[_0x9b76('0x24')]};}):[]};}):[]};}):[]:[]})[_0x9b76('0x12')](function(_0x822b07){logger[_0x9b76('0x13')](_0x9b76('0x26'),_0x279251);logger[_0x9b76('0x15')](_0x9b76('0x26'),_0x279251,JSON[_0x9b76('0x28')](_0x822b07));_0x2d4912(_0x822b07);})[_0x9b76('0x1b')](function(_0x35093b){logger[_0x9b76('0x18')]('ShowSmsQueue',_0x35093b['message'],_0x279251);_0x3acb01(_0x2c67e7[_0x9b76('0x18')](0x1f4,_0x35093b[_0x9b76('0x19')]));});});};