Built motion from commit (unavailable).|2.5.4
[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 _0xf70c=['request\x20sent','result','catch','GetSmsQueue','findAll','options','raw','attributes','limit','map','model','include','ShowSmsQueue','SmsQueue','where','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','redis','localhost','socket.io-emitter','./smsQueue.socket','register','request','info','debug','SmsQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','SmsQueue,\x20%s,\x20%s','message'];(function(_0x331a4d,_0x408462){var _0x44944a=function(_0x37941b){while(--_0x37941b){_0x331a4d['push'](_0x331a4d['shift']());}};_0x44944a(++_0x408462);}(_0xf70c,0x1dd));var _0xcf70=function(_0x358370,_0x5ef179){_0x358370=_0x358370-0x0;var _0x210896=_0xf70c[_0x358370];return _0x210896;};'use strict';var _=require(_0xcf70('0x0'));var util=require(_0xcf70('0x1'));var moment=require(_0xcf70('0x2'));var BPromise=require(_0xcf70('0x3'));var rs=require(_0xcf70('0x4'));var fs=require('fs');var Redis=require(_0xcf70('0x5'));var db=require(_0xcf70('0x6'))['db'];var utils=require(_0xcf70('0x7'));var logger=require(_0xcf70('0x8'))(_0xcf70('0x9'));var config=require(_0xcf70('0xa'));var jayson=require('jayson/promise');var client=jayson[_0xcf70('0xb')][_0xcf70('0xc')]({'port':0x232a});config[_0xcf70('0xd')]=_['defaults'](config[_0xcf70('0xd')],{'host':_0xcf70('0xe'),'port':0x18eb});var socket=require(_0xcf70('0xf'))(new Redis(config['redis']));require(_0xcf70('0x10'))[_0xcf70('0x11')](socket);function respondWithRpcPromise(_0xcc9426,_0x23743d,_0x14e7c5){return new BPromise(function(_0x5e1e17,_0x4f07a9){return client[_0xcf70('0x12')](_0xcc9426,_0x14e7c5)['then'](function(_0x1c765b){logger[_0xcf70('0x13')]('SmsQueue,\x20%s,\x20%s',_0x23743d,'request\x20sent');logger[_0xcf70('0x14')](_0xcf70('0x15'),_0x23743d,'request\x20sent',JSON[_0xcf70('0x16')](_0x1c765b));if(_0x1c765b[_0xcf70('0x17')]){if(_0x1c765b[_0xcf70('0x17')][_0xcf70('0x18')]===0x1f4){logger[_0xcf70('0x17')](_0xcf70('0x19'),_0x23743d,_0x1c765b[_0xcf70('0x17')]['message']);return _0x4f07a9(_0x1c765b[_0xcf70('0x17')][_0xcf70('0x1a')]);}logger[_0xcf70('0x17')](_0xcf70('0x19'),_0x23743d,_0x1c765b[_0xcf70('0x17')][_0xcf70('0x1a')]);return _0x5e1e17(_0x1c765b[_0xcf70('0x17')][_0xcf70('0x1a')]);}else{logger[_0xcf70('0x13')](_0xcf70('0x19'),_0x23743d,_0xcf70('0x1b'));_0x5e1e17(_0x1c765b[_0xcf70('0x1c')][_0xcf70('0x1a')]);}})[_0xcf70('0x1d')](function(_0x355a3d){logger[_0xcf70('0x17')](_0xcf70('0x19'),_0x23743d,_0x355a3d);_0x4f07a9(_0x355a3d);});});}exports[_0xcf70('0x1e')]=function(_0x385c59){var _0x3a48c5=this;return new Promise(function(_0x29a800,_0x7c6cb9){return db['SmsQueue'][_0xcf70('0x1f')]({'raw':_0x385c59[_0xcf70('0x20')]?_0x385c59['options'][_0xcf70('0x21')]===undefined?!![]:![]:!![],'where':_0x385c59[_0xcf70('0x20')]?_0x385c59[_0xcf70('0x20')]['where']||null:null,'attributes':_0x385c59[_0xcf70('0x20')]?_0x385c59[_0xcf70('0x20')][_0xcf70('0x22')]||null:null,'limit':_0x385c59[_0xcf70('0x20')]?_0x385c59[_0xcf70('0x20')][_0xcf70('0x23')]||null:null,'include':_0x385c59[_0xcf70('0x20')]?_0x385c59['options']['include']?_[_0xcf70('0x24')](_0x385c59[_0xcf70('0x20')]['include'],function(_0x51e537){return{'model':db[_0x51e537[_0xcf70('0x25')]],'as':_0x51e537['as'],'attributes':_0x51e537[_0xcf70('0x22')],'include':_0x51e537[_0xcf70('0x26')]?_['map'](_0x51e537[_0xcf70('0x26')],function(_0xc8a5c8){return{'model':db[_0xc8a5c8['model']],'as':_0xc8a5c8['as'],'attributes':_0xc8a5c8['attributes'],'include':_0xc8a5c8[_0xcf70('0x26')]?_[_0xcf70('0x24')](_0xc8a5c8[_0xcf70('0x26')],function(_0x4ae736){return{'model':db[_0x4ae736['model']],'as':_0x4ae736['as'],'attributes':_0x4ae736[_0xcf70('0x22')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x3c1b9c){logger[_0xcf70('0x13')](_0xcf70('0x1e'),_0x385c59);logger['debug']('GetSmsQueue',_0x385c59,JSON[_0xcf70('0x16')](_0x3c1b9c));_0x29a800(_0x3c1b9c);})[_0xcf70('0x1d')](function(_0x4d9f34){logger['error'](_0xcf70('0x1e'),_0x4d9f34[_0xcf70('0x1a')],_0x385c59);_0x7c6cb9(_0x3a48c5[_0xcf70('0x17')](0x1f4,_0x4d9f34[_0xcf70('0x1a')]));});});};exports[_0xcf70('0x27')]=function(_0x3d81f7){var _0x35655a=this;return new Promise(function(_0x5e4fc1,_0x8e1ba4){return db[_0xcf70('0x28')]['find']({'raw':_0x3d81f7[_0xcf70('0x20')]?_0x3d81f7[_0xcf70('0x20')][_0xcf70('0x21')]===undefined?!![]:![]:!![],'where':_0x3d81f7[_0xcf70('0x20')]?_0x3d81f7['options'][_0xcf70('0x29')]||null:null,'attributes':_0x3d81f7[_0xcf70('0x20')]?_0x3d81f7[_0xcf70('0x20')]['attributes']||null:null,'include':_0x3d81f7['options']?_0x3d81f7['options'][_0xcf70('0x26')]?_['map'](_0x3d81f7['options'][_0xcf70('0x26')],function(_0x294813){return{'model':db[_0x294813['model']],'as':_0x294813['as'],'attributes':_0x294813['attributes'],'include':_0x294813[_0xcf70('0x26')]?_['map'](_0x294813[_0xcf70('0x26')],function(_0x3eb5dd){return{'model':db[_0x3eb5dd['model']],'as':_0x3eb5dd['as'],'attributes':_0x3eb5dd[_0xcf70('0x22')],'include':_0x3eb5dd[_0xcf70('0x26')]?_['map'](_0x3eb5dd[_0xcf70('0x26')],function(_0x3d3887){return{'model':db[_0x3d3887[_0xcf70('0x25')]],'as':_0x3d3887['as'],'attributes':_0x3d3887['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x488e95){logger[_0xcf70('0x13')](_0xcf70('0x27'),_0x3d81f7);logger[_0xcf70('0x14')](_0xcf70('0x27'),_0x3d81f7,JSON[_0xcf70('0x16')](_0x488e95));_0x5e4fc1(_0x488e95);})[_0xcf70('0x1d')](function(_0x3a6563){logger[_0xcf70('0x17')](_0xcf70('0x27'),_0x3a6563[_0xcf70('0x1a')],_0x3d81f7);_0x8e1ba4(_0x35655a[_0xcf70('0x17')](0x1f4,_0x3a6563[_0xcf70('0x1a')]));});});};