Built motion from commit (unavailable).|2.5.0
[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 _0x6a22=['socket.io-emitter','./smsQueue.socket','register','request','SmsQueue,\x20%s,\x20%s','SmsQueue,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','info','result','catch','SmsQueue','options','raw','where','map','include','attributes','model','then','GetSmsQueue','stringify','ShowSmsQueue','debug','lodash','util','moment','bluebird','randomstring','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','defaults','redis','localhost'];(function(_0x3b53b0,_0x23dc58){var _0x4eddc6=function(_0x46254f){while(--_0x46254f){_0x3b53b0['push'](_0x3b53b0['shift']());}};_0x4eddc6(++_0x23dc58);}(_0x6a22,0x15a));var _0x26a2=function(_0x430ea6,_0x58db3b){_0x430ea6=_0x430ea6-0x0;var _0x8c837=_0x6a22[_0x430ea6];return _0x8c837;};'use strict';var _=require(_0x26a2('0x0'));var util=require(_0x26a2('0x1'));var moment=require(_0x26a2('0x2'));var BPromise=require(_0x26a2('0x3'));var rs=require(_0x26a2('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x26a2('0x5'));var logger=require(_0x26a2('0x6'))(_0x26a2('0x7'));var config=require(_0x26a2('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x26a2('0x9')][_0x26a2('0xa')]({'port':0x232a});config['redis']=_[_0x26a2('0xb')](config[_0x26a2('0xc')],{'host':_0x26a2('0xd'),'port':0x18eb});var socket=require(_0x26a2('0xe'))(new Redis(config['redis']));require(_0x26a2('0xf'))[_0x26a2('0x10')](socket);function respondWithRpcPromise(_0x134ab6,_0x56a76f,_0xbe253d){return new BPromise(function(_0x2f44ef,_0x5a07a7){return client[_0x26a2('0x11')](_0x134ab6,_0xbe253d)['then'](function(_0x148ed8){logger['info'](_0x26a2('0x12'),_0x56a76f,'request\x20sent');logger['debug'](_0x26a2('0x13'),_0x56a76f,_0x26a2('0x14'),JSON['stringify'](_0x148ed8));if(_0x148ed8[_0x26a2('0x15')]){if(_0x148ed8['error'][_0x26a2('0x16')]===0x1f4){logger[_0x26a2('0x15')]('SmsQueue,\x20%s,\x20%s',_0x56a76f,_0x148ed8[_0x26a2('0x15')]['message']);return _0x5a07a7(_0x148ed8[_0x26a2('0x15')][_0x26a2('0x17')]);}logger[_0x26a2('0x15')](_0x26a2('0x12'),_0x56a76f,_0x148ed8[_0x26a2('0x15')][_0x26a2('0x17')]);return _0x2f44ef(_0x148ed8['error'][_0x26a2('0x17')]);}else{logger[_0x26a2('0x18')](_0x26a2('0x12'),_0x56a76f,_0x26a2('0x14'));_0x2f44ef(_0x148ed8[_0x26a2('0x19')]['message']);}})[_0x26a2('0x1a')](function(_0x421d37){logger[_0x26a2('0x15')]('SmsQueue,\x20%s,\x20%s',_0x56a76f,_0x421d37);_0x5a07a7(_0x421d37);});});}exports['GetSmsQueue']=function(_0x30a893){var _0x154a9e=this;return new Promise(function(_0x4691ef,_0x330d83){return db[_0x26a2('0x1b')]['findAll']({'raw':_0x30a893[_0x26a2('0x1c')]?_0x30a893[_0x26a2('0x1c')][_0x26a2('0x1d')]===undefined?!![]:![]:!![],'where':_0x30a893[_0x26a2('0x1c')]?_0x30a893['options'][_0x26a2('0x1e')]||null:null,'attributes':_0x30a893[_0x26a2('0x1c')]?_0x30a893[_0x26a2('0x1c')]['attributes']||null:null,'limit':_0x30a893[_0x26a2('0x1c')]?_0x30a893['options']['limit']||null:null,'include':_0x30a893[_0x26a2('0x1c')]?_0x30a893[_0x26a2('0x1c')]['include']?_[_0x26a2('0x1f')](_0x30a893['options'][_0x26a2('0x20')],function(_0xf8e5bc){return{'model':db[_0xf8e5bc['model']],'as':_0xf8e5bc['as'],'attributes':_0xf8e5bc[_0x26a2('0x21')],'include':_0xf8e5bc['include']?_[_0x26a2('0x1f')](_0xf8e5bc[_0x26a2('0x20')],function(_0x1870ca){return{'model':db[_0x1870ca[_0x26a2('0x22')]],'as':_0x1870ca['as'],'attributes':_0x1870ca[_0x26a2('0x21')],'include':_0x1870ca[_0x26a2('0x20')]?_[_0x26a2('0x1f')](_0x1870ca[_0x26a2('0x20')],function(_0x12ebf7){return{'model':db[_0x12ebf7[_0x26a2('0x22')]],'as':_0x12ebf7['as'],'attributes':_0x12ebf7[_0x26a2('0x21')]};}):[]};}):[]};}):[]:[]})[_0x26a2('0x23')](function(_0x535c1d){logger['info'](_0x26a2('0x24'),_0x30a893);logger['debug'](_0x26a2('0x24'),_0x30a893,JSON[_0x26a2('0x25')](_0x535c1d));_0x4691ef(_0x535c1d);})['catch'](function(_0x5c6947){logger['error'](_0x26a2('0x24'),_0x5c6947['message'],_0x30a893);_0x330d83(_0x154a9e['error'](0x1f4,_0x5c6947[_0x26a2('0x17')]));});});};exports[_0x26a2('0x26')]=function(_0x549c42){var _0x2df72b=this;return new Promise(function(_0x2fc6cf,_0x24e934){return db['SmsQueue']['find']({'raw':_0x549c42[_0x26a2('0x1c')]?_0x549c42[_0x26a2('0x1c')]['raw']===undefined?!![]:![]:!![],'where':_0x549c42[_0x26a2('0x1c')]?_0x549c42[_0x26a2('0x1c')][_0x26a2('0x1e')]||null:null,'attributes':_0x549c42['options']?_0x549c42[_0x26a2('0x1c')]['attributes']||null:null,'include':_0x549c42[_0x26a2('0x1c')]?_0x549c42['options'][_0x26a2('0x20')]?_[_0x26a2('0x1f')](_0x549c42[_0x26a2('0x1c')][_0x26a2('0x20')],function(_0x5a576a){return{'model':db[_0x5a576a[_0x26a2('0x22')]],'as':_0x5a576a['as'],'attributes':_0x5a576a[_0x26a2('0x21')],'include':_0x5a576a[_0x26a2('0x20')]?_[_0x26a2('0x1f')](_0x5a576a['include'],function(_0x33e134){return{'model':db[_0x33e134[_0x26a2('0x22')]],'as':_0x33e134['as'],'attributes':_0x33e134['attributes'],'include':_0x33e134[_0x26a2('0x20')]?_[_0x26a2('0x1f')](_0x33e134[_0x26a2('0x20')],function(_0x8eb99e){return{'model':db[_0x8eb99e[_0x26a2('0x22')]],'as':_0x8eb99e['as'],'attributes':_0x8eb99e[_0x26a2('0x21')]};}):[]};}):[]};}):[]:[]})[_0x26a2('0x23')](function(_0x30f648){logger['info']('ShowSmsQueue',_0x549c42);logger[_0x26a2('0x27')](_0x26a2('0x26'),_0x549c42,JSON[_0x26a2('0x25')](_0x30f648));_0x2fc6cf(_0x30f648);})[_0x26a2('0x1a')](function(_0x2d2d43){logger[_0x26a2('0x15')](_0x26a2('0x26'),_0x2d2d43['message'],_0x549c42);_0x24e934(_0x2df72b[_0x26a2('0x15')](0x1f4,_0x2d2d43[_0x26a2('0x17')]));});});};