Built motion from commit (unavailable).|2.5.8
[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 _0xa4aa=['SmsQueue,\x20%s,\x20%s','debug','SmsQueue,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','findAll','options','raw','where','attributes','map','model','include','GetSmsQueue','catch','ShowSmsQueue','SmsQueue','find','lodash','util','moment','bluebird','ioredis','../../mysqldb','rpc','../../config/environment','jayson/promise','client','http','defaults','redis','localhost','socket.io-emitter','./smsQueue.socket','register','request','then','info'];(function(_0x481bdf,_0x231538){var _0x281a12=function(_0x264b18){while(--_0x264b18){_0x481bdf['push'](_0x481bdf['shift']());}};_0x281a12(++_0x231538);}(_0xa4aa,0x1e4));var _0xaa4a=function(_0x24058e,_0x440f67){_0x24058e=_0x24058e-0x0;var _0x2c72a9=_0xa4aa[_0x24058e];return _0x2c72a9;};'use strict';var _=require(_0xaa4a('0x0'));var util=require(_0xaa4a('0x1'));var moment=require(_0xaa4a('0x2'));var BPromise=require(_0xaa4a('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xaa4a('0x4'));var db=require(_0xaa4a('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xaa4a('0x6'));var config=require(_0xaa4a('0x7'));var jayson=require(_0xaa4a('0x8'));var client=jayson[_0xaa4a('0x9')][_0xaa4a('0xa')]({'port':0x232a});config['redis']=_[_0xaa4a('0xb')](config[_0xaa4a('0xc')],{'host':_0xaa4a('0xd'),'port':0x18eb});var socket=require(_0xaa4a('0xe'))(new Redis(config[_0xaa4a('0xc')]));require(_0xaa4a('0xf'))[_0xaa4a('0x10')](socket);function respondWithRpcPromise(_0x4d04dd,_0x54be08,_0x56dde3){return new BPromise(function(_0x317afd,_0xfe9b8a){return client[_0xaa4a('0x11')](_0x4d04dd,_0x56dde3)[_0xaa4a('0x12')](function(_0x18900c){logger[_0xaa4a('0x13')](_0xaa4a('0x14'),_0x54be08,'request\x20sent');logger[_0xaa4a('0x15')](_0xaa4a('0x16'),_0x54be08,_0xaa4a('0x17'),JSON[_0xaa4a('0x18')](_0x18900c));if(_0x18900c[_0xaa4a('0x19')]){if(_0x18900c['error'][_0xaa4a('0x1a')]===0x1f4){logger[_0xaa4a('0x19')]('SmsQueue,\x20%s,\x20%s',_0x54be08,_0x18900c[_0xaa4a('0x19')][_0xaa4a('0x1b')]);return _0xfe9b8a(_0x18900c['error'][_0xaa4a('0x1b')]);}logger[_0xaa4a('0x19')](_0xaa4a('0x14'),_0x54be08,_0x18900c['error'][_0xaa4a('0x1b')]);return _0x317afd(_0x18900c['error'][_0xaa4a('0x1b')]);}else{logger[_0xaa4a('0x13')](_0xaa4a('0x14'),_0x54be08,_0xaa4a('0x17'));_0x317afd(_0x18900c[_0xaa4a('0x1c')][_0xaa4a('0x1b')]);}})['catch'](function(_0x2d22a9){logger[_0xaa4a('0x19')](_0xaa4a('0x14'),_0x54be08,_0x2d22a9);_0xfe9b8a(_0x2d22a9);});});}exports['GetSmsQueue']=function(_0x1f1f99){var _0x5633cf=this;return new Promise(function(_0x1fa805,_0x4d7eaa){return db['SmsQueue'][_0xaa4a('0x1d')]({'raw':_0x1f1f99[_0xaa4a('0x1e')]?_0x1f1f99[_0xaa4a('0x1e')][_0xaa4a('0x1f')]===undefined?!![]:![]:!![],'where':_0x1f1f99[_0xaa4a('0x1e')]?_0x1f1f99['options'][_0xaa4a('0x20')]||null:null,'attributes':_0x1f1f99[_0xaa4a('0x1e')]?_0x1f1f99['options'][_0xaa4a('0x21')]||null:null,'limit':_0x1f1f99[_0xaa4a('0x1e')]?_0x1f1f99[_0xaa4a('0x1e')]['limit']||null:null,'include':_0x1f1f99[_0xaa4a('0x1e')]?_0x1f1f99[_0xaa4a('0x1e')]['include']?_[_0xaa4a('0x22')](_0x1f1f99['options']['include'],function(_0x26925a){return{'model':db[_0x26925a[_0xaa4a('0x23')]],'as':_0x26925a['as'],'attributes':_0x26925a[_0xaa4a('0x21')],'include':_0x26925a[_0xaa4a('0x24')]?_['map'](_0x26925a[_0xaa4a('0x24')],function(_0x4e43cc){return{'model':db[_0x4e43cc[_0xaa4a('0x23')]],'as':_0x4e43cc['as'],'attributes':_0x4e43cc['attributes'],'include':_0x4e43cc[_0xaa4a('0x24')]?_[_0xaa4a('0x22')](_0x4e43cc['include'],function(_0x9ddfd2){return{'model':db[_0x9ddfd2[_0xaa4a('0x23')]],'as':_0x9ddfd2['as'],'attributes':_0x9ddfd2[_0xaa4a('0x21')]};}):[]};}):[]};}):[]:[]})[_0xaa4a('0x12')](function(_0x4ce4c1){logger[_0xaa4a('0x13')](_0xaa4a('0x25'),_0x1f1f99);logger[_0xaa4a('0x15')](_0xaa4a('0x25'),_0x1f1f99,JSON[_0xaa4a('0x18')](_0x4ce4c1));_0x1fa805(_0x4ce4c1);})[_0xaa4a('0x26')](function(_0x314a87){logger[_0xaa4a('0x19')](_0xaa4a('0x25'),_0x314a87[_0xaa4a('0x1b')],_0x1f1f99);_0x4d7eaa(_0x5633cf['error'](0x1f4,_0x314a87[_0xaa4a('0x1b')]));});});};exports[_0xaa4a('0x27')]=function(_0x155d5e){var _0x5154c5=this;return new Promise(function(_0x4721ce,_0x416ec9){return db[_0xaa4a('0x28')][_0xaa4a('0x29')]({'raw':_0x155d5e[_0xaa4a('0x1e')]?_0x155d5e[_0xaa4a('0x1e')][_0xaa4a('0x1f')]===undefined?!![]:![]:!![],'where':_0x155d5e['options']?_0x155d5e[_0xaa4a('0x1e')][_0xaa4a('0x20')]||null:null,'attributes':_0x155d5e[_0xaa4a('0x1e')]?_0x155d5e[_0xaa4a('0x1e')][_0xaa4a('0x21')]||null:null,'include':_0x155d5e['options']?_0x155d5e[_0xaa4a('0x1e')]['include']?_[_0xaa4a('0x22')](_0x155d5e['options'][_0xaa4a('0x24')],function(_0x38cf90){return{'model':db[_0x38cf90[_0xaa4a('0x23')]],'as':_0x38cf90['as'],'attributes':_0x38cf90[_0xaa4a('0x21')],'include':_0x38cf90[_0xaa4a('0x24')]?_[_0xaa4a('0x22')](_0x38cf90['include'],function(_0x8c2b5d){return{'model':db[_0x8c2b5d[_0xaa4a('0x23')]],'as':_0x8c2b5d['as'],'attributes':_0x8c2b5d[_0xaa4a('0x21')],'include':_0x8c2b5d['include']?_[_0xaa4a('0x22')](_0x8c2b5d[_0xaa4a('0x24')],function(_0x3a1abe){return{'model':db[_0x3a1abe['model']],'as':_0x3a1abe['as'],'attributes':_0x3a1abe[_0xaa4a('0x21')]};}):[]};}):[]};}):[]:[]})[_0xaa4a('0x12')](function(_0x31ef09){logger['info']('ShowSmsQueue',_0x155d5e);logger[_0xaa4a('0x15')]('ShowSmsQueue',_0x155d5e,JSON[_0xaa4a('0x18')](_0x31ef09));_0x4721ce(_0x31ef09);})[_0xaa4a('0x26')](function(_0x651ece){logger[_0xaa4a('0x19')](_0xaa4a('0x27'),_0x651ece[_0xaa4a('0x1b')],_0x155d5e);_0x416ec9(_0x5154c5[_0xaa4a('0x19')](0x1f4,_0x651ece[_0xaa4a('0x1b')]));});});};