Built motion from commit (unavailable).|2.5.19
[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 _0x9d23=['socket.io-emitter','./smsQueue.socket','register','info','SmsQueue,\x20%s,\x20%s','request\x20sent','debug','SmsQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetSmsQueue','SmsQueue','findAll','options','raw','where','attributes','include','model','map','then','ShowSmsQueue','util','moment','bluebird','randomstring','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','redis','defaults','localhost'];(function(_0x1876b2,_0x5d0225){var _0x9fb1e0=function(_0x29b099){while(--_0x29b099){_0x1876b2['push'](_0x1876b2['shift']());}};_0x9fb1e0(++_0x5d0225);}(_0x9d23,0x68));var _0x39d2=function(_0x243de6,_0x5b3347){_0x243de6=_0x243de6-0x0;var _0x1ddf09=_0x9d23[_0x243de6];return _0x1ddf09;};'use strict';var _=require('lodash');var util=require(_0x39d2('0x0'));var moment=require(_0x39d2('0x1'));var BPromise=require(_0x39d2('0x2'));var rs=require(_0x39d2('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x39d2('0x4'));var logger=require(_0x39d2('0x5'))(_0x39d2('0x6'));var config=require(_0x39d2('0x7'));var jayson=require(_0x39d2('0x8'));var client=jayson['client'][_0x39d2('0x9')]({'port':0x232a});config[_0x39d2('0xa')]=_[_0x39d2('0xb')](config[_0x39d2('0xa')],{'host':_0x39d2('0xc'),'port':0x18eb});var socket=require(_0x39d2('0xd'))(new Redis(config[_0x39d2('0xa')]));require(_0x39d2('0xe'))[_0x39d2('0xf')](socket);function respondWithRpcPromise(_0x298be0,_0x5eb169,_0x11a914){return new BPromise(function(_0x18fbb6,_0x500951){return client['request'](_0x298be0,_0x11a914)['then'](function(_0x3ccee7){logger[_0x39d2('0x10')](_0x39d2('0x11'),_0x5eb169,_0x39d2('0x12'));logger[_0x39d2('0x13')](_0x39d2('0x14'),_0x5eb169,'request\x20sent',JSON[_0x39d2('0x15')](_0x3ccee7));if(_0x3ccee7[_0x39d2('0x16')]){if(_0x3ccee7[_0x39d2('0x16')][_0x39d2('0x17')]===0x1f4){logger[_0x39d2('0x16')](_0x39d2('0x11'),_0x5eb169,_0x3ccee7[_0x39d2('0x16')]['message']);return _0x500951(_0x3ccee7[_0x39d2('0x16')][_0x39d2('0x18')]);}logger[_0x39d2('0x16')]('SmsQueue,\x20%s,\x20%s',_0x5eb169,_0x3ccee7[_0x39d2('0x16')]['message']);return _0x18fbb6(_0x3ccee7[_0x39d2('0x16')]['message']);}else{logger[_0x39d2('0x10')](_0x39d2('0x11'),_0x5eb169,_0x39d2('0x12'));_0x18fbb6(_0x3ccee7[_0x39d2('0x19')]['message']);}})[_0x39d2('0x1a')](function(_0x11ef84){logger['error'](_0x39d2('0x11'),_0x5eb169,_0x11ef84);_0x500951(_0x11ef84);});});}exports[_0x39d2('0x1b')]=function(_0x2fc59b){var _0x5ff543=this;return new Promise(function(_0x21dbb7,_0x21b2e1){return db[_0x39d2('0x1c')][_0x39d2('0x1d')]({'raw':_0x2fc59b['options']?_0x2fc59b[_0x39d2('0x1e')][_0x39d2('0x1f')]===undefined?!![]:![]:!![],'where':_0x2fc59b[_0x39d2('0x1e')]?_0x2fc59b['options'][_0x39d2('0x20')]||null:null,'attributes':_0x2fc59b[_0x39d2('0x1e')]?_0x2fc59b[_0x39d2('0x1e')][_0x39d2('0x21')]||null:null,'limit':_0x2fc59b[_0x39d2('0x1e')]?_0x2fc59b['options']['limit']||null:null,'include':_0x2fc59b[_0x39d2('0x1e')]?_0x2fc59b[_0x39d2('0x1e')][_0x39d2('0x22')]?_['map'](_0x2fc59b['options'][_0x39d2('0x22')],function(_0x8c9d57){return{'model':db[_0x8c9d57['model']],'as':_0x8c9d57['as'],'attributes':_0x8c9d57[_0x39d2('0x21')],'include':_0x8c9d57[_0x39d2('0x22')]?_['map'](_0x8c9d57['include'],function(_0x543583){return{'model':db[_0x543583[_0x39d2('0x23')]],'as':_0x543583['as'],'attributes':_0x543583[_0x39d2('0x21')],'include':_0x543583['include']?_[_0x39d2('0x24')](_0x543583[_0x39d2('0x22')],function(_0x397c2a){return{'model':db[_0x397c2a['model']],'as':_0x397c2a['as'],'attributes':_0x397c2a[_0x39d2('0x21')]};}):[]};}):[]};}):[]:[]})[_0x39d2('0x25')](function(_0x1e99d6){logger[_0x39d2('0x10')](_0x39d2('0x1b'),_0x2fc59b);logger['debug']('GetSmsQueue',_0x2fc59b,JSON[_0x39d2('0x15')](_0x1e99d6));_0x21dbb7(_0x1e99d6);})['catch'](function(_0x20449f){logger['error']('GetSmsQueue',_0x20449f[_0x39d2('0x18')],_0x2fc59b);_0x21b2e1(_0x5ff543[_0x39d2('0x16')](0x1f4,_0x20449f['message']));});});};exports['ShowSmsQueue']=function(_0x1e2021){var _0x513749=this;return new Promise(function(_0x4aa1d6,_0x42b884){return db[_0x39d2('0x1c')]['find']({'raw':_0x1e2021[_0x39d2('0x1e')]?_0x1e2021[_0x39d2('0x1e')][_0x39d2('0x1f')]===undefined?!![]:![]:!![],'where':_0x1e2021['options']?_0x1e2021[_0x39d2('0x1e')][_0x39d2('0x20')]||null:null,'attributes':_0x1e2021[_0x39d2('0x1e')]?_0x1e2021[_0x39d2('0x1e')]['attributes']||null:null,'include':_0x1e2021[_0x39d2('0x1e')]?_0x1e2021[_0x39d2('0x1e')][_0x39d2('0x22')]?_[_0x39d2('0x24')](_0x1e2021[_0x39d2('0x1e')]['include'],function(_0x3984a0){return{'model':db[_0x3984a0[_0x39d2('0x23')]],'as':_0x3984a0['as'],'attributes':_0x3984a0[_0x39d2('0x21')],'include':_0x3984a0['include']?_[_0x39d2('0x24')](_0x3984a0[_0x39d2('0x22')],function(_0x3c8b72){return{'model':db[_0x3c8b72['model']],'as':_0x3c8b72['as'],'attributes':_0x3c8b72[_0x39d2('0x21')],'include':_0x3c8b72[_0x39d2('0x22')]?_[_0x39d2('0x24')](_0x3c8b72[_0x39d2('0x22')],function(_0x29d3aa){return{'model':db[_0x29d3aa[_0x39d2('0x23')]],'as':_0x29d3aa['as'],'attributes':_0x29d3aa[_0x39d2('0x21')]};}):[]};}):[]};}):[]:[]})[_0x39d2('0x25')](function(_0x51ac07){logger[_0x39d2('0x10')](_0x39d2('0x26'),_0x1e2021);logger[_0x39d2('0x13')]('ShowSmsQueue',_0x1e2021,JSON[_0x39d2('0x15')](_0x51ac07));_0x4aa1d6(_0x51ac07);})[_0x39d2('0x1a')](function(_0x3db1a3){logger[_0x39d2('0x16')]('ShowSmsQueue',_0x3db1a3[_0x39d2('0x18')],_0x1e2021);_0x42b884(_0x513749[_0x39d2('0x16')](0x1f4,_0x3db1a3[_0x39d2('0x18')]));});});};