8560d319b92d93983ea7ba7a333d2ce6e2be047d
[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 _0xa80f=['info','request\x20sent','SmsQueue,\x20%s,\x20%s,\x20%s','error','code','message','SmsQueue,\x20%s,\x20%s','GetSmsQueue','SmsQueue','findAll','options','where','attributes','limit','include','map','model','debug','stringify','catch','ShowSmsQueue','find','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','http','redis','defaults','./smsQueue.socket','register','then'];(function(_0x427352,_0x1bce61){var _0x23e0e6=function(_0x2a42a9){while(--_0x2a42a9){_0x427352['push'](_0x427352['shift']());}};_0x23e0e6(++_0x1bce61);}(_0xa80f,0x1ea));var _0xfa80=function(_0x5993de,_0x1e902f){_0x5993de=_0x5993de-0x0;var _0x481faf=_0xa80f[_0x5993de];return _0x481faf;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0xfa80('0x0'));var BPromise=require(_0xfa80('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xfa80('0x2'));var db=require(_0xfa80('0x3'))['db'];var utils=require(_0xfa80('0x4'));var logger=require(_0xfa80('0x5'))('rpc');var config=require(_0xfa80('0x6'));var jayson=require(_0xfa80('0x7'));var client=jayson['client'][_0xfa80('0x8')]({'port':0x232a});config[_0xfa80('0x9')]=_[_0xfa80('0xa')](config[_0xfa80('0x9')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xfa80('0x9')]));require(_0xfa80('0xb'))[_0xfa80('0xc')](socket);function respondWithRpcPromise(_0xe4e554,_0x330b99,_0x356e8a){return new BPromise(function(_0x1077e3,_0x5275d4){return client['request'](_0xe4e554,_0x356e8a)[_0xfa80('0xd')](function(_0x1c5572){logger[_0xfa80('0xe')]('SmsQueue,\x20%s,\x20%s',_0x330b99,_0xfa80('0xf'));logger['debug'](_0xfa80('0x10'),_0x330b99,'request\x20sent',JSON['stringify'](_0x1c5572));if(_0x1c5572[_0xfa80('0x11')]){if(_0x1c5572[_0xfa80('0x11')][_0xfa80('0x12')]===0x1f4){logger[_0xfa80('0x11')]('SmsQueue,\x20%s,\x20%s',_0x330b99,_0x1c5572[_0xfa80('0x11')]['message']);return _0x5275d4(_0x1c5572[_0xfa80('0x11')]['message']);}logger[_0xfa80('0x11')]('SmsQueue,\x20%s,\x20%s',_0x330b99,_0x1c5572['error']['message']);return _0x1077e3(_0x1c5572['error'][_0xfa80('0x13')]);}else{logger[_0xfa80('0xe')]('SmsQueue,\x20%s,\x20%s',_0x330b99,_0xfa80('0xf'));_0x1077e3(_0x1c5572['result']['message']);}})['catch'](function(_0x3f1f91){logger[_0xfa80('0x11')](_0xfa80('0x14'),_0x330b99,_0x3f1f91);_0x5275d4(_0x3f1f91);});});}exports[_0xfa80('0x15')]=function(_0x4ac344){var _0x405bc2=this;return new Promise(function(_0x4de98d,_0x2c1953){return db[_0xfa80('0x16')][_0xfa80('0x17')]({'raw':_0x4ac344[_0xfa80('0x18')]?_0x4ac344[_0xfa80('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0x4ac344[_0xfa80('0x18')]?_0x4ac344[_0xfa80('0x18')][_0xfa80('0x19')]||null:null,'attributes':_0x4ac344[_0xfa80('0x18')]?_0x4ac344['options'][_0xfa80('0x1a')]||null:null,'limit':_0x4ac344[_0xfa80('0x18')]?_0x4ac344['options'][_0xfa80('0x1b')]||null:null,'include':_0x4ac344[_0xfa80('0x18')]?_0x4ac344[_0xfa80('0x18')][_0xfa80('0x1c')]?_[_0xfa80('0x1d')](_0x4ac344[_0xfa80('0x18')][_0xfa80('0x1c')],function(_0x1a1a18){return{'model':db[_0x1a1a18[_0xfa80('0x1e')]],'as':_0x1a1a18['as'],'attributes':_0x1a1a18[_0xfa80('0x1a')],'include':_0x1a1a18['include']?_[_0xfa80('0x1d')](_0x1a1a18['include'],function(_0x472247){return{'model':db[_0x472247[_0xfa80('0x1e')]],'as':_0x472247['as'],'attributes':_0x472247['attributes'],'include':_0x472247['include']?_['map'](_0x472247[_0xfa80('0x1c')],function(_0x59316a){return{'model':db[_0x59316a[_0xfa80('0x1e')]],'as':_0x59316a['as'],'attributes':_0x59316a[_0xfa80('0x1a')]};}):[]};}):[]};}):[]:[]})[_0xfa80('0xd')](function(_0x59a1fb){logger[_0xfa80('0xe')](_0xfa80('0x15'),_0x4ac344);logger[_0xfa80('0x1f')](_0xfa80('0x15'),_0x4ac344,JSON[_0xfa80('0x20')](_0x59a1fb));_0x4de98d(_0x59a1fb);})[_0xfa80('0x21')](function(_0x467a66){logger[_0xfa80('0x11')](_0xfa80('0x15'),_0x467a66['message'],_0x4ac344);_0x2c1953(_0x405bc2['error'](0x1f4,_0x467a66[_0xfa80('0x13')]));});});};exports[_0xfa80('0x22')]=function(_0x352f8b){var _0x1fd636=this;return new Promise(function(_0x193192,_0x41ae75){return db['SmsQueue'][_0xfa80('0x23')]({'raw':_0x352f8b[_0xfa80('0x18')]?_0x352f8b[_0xfa80('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0x352f8b[_0xfa80('0x18')]?_0x352f8b[_0xfa80('0x18')]['where']||null:null,'attributes':_0x352f8b[_0xfa80('0x18')]?_0x352f8b[_0xfa80('0x18')][_0xfa80('0x1a')]||null:null,'include':_0x352f8b[_0xfa80('0x18')]?_0x352f8b['options'][_0xfa80('0x1c')]?_[_0xfa80('0x1d')](_0x352f8b['options'][_0xfa80('0x1c')],function(_0x826e75){return{'model':db[_0x826e75[_0xfa80('0x1e')]],'as':_0x826e75['as'],'attributes':_0x826e75[_0xfa80('0x1a')],'include':_0x826e75[_0xfa80('0x1c')]?_[_0xfa80('0x1d')](_0x826e75[_0xfa80('0x1c')],function(_0x18ccc6){return{'model':db[_0x18ccc6[_0xfa80('0x1e')]],'as':_0x18ccc6['as'],'attributes':_0x18ccc6['attributes'],'include':_0x18ccc6[_0xfa80('0x1c')]?_[_0xfa80('0x1d')](_0x18ccc6['include'],function(_0x2febf2){return{'model':db[_0x2febf2[_0xfa80('0x1e')]],'as':_0x2febf2['as'],'attributes':_0x2febf2['attributes']};}):[]};}):[]};}):[]:[]})[_0xfa80('0xd')](function(_0x5a90e5){logger[_0xfa80('0xe')](_0xfa80('0x22'),_0x352f8b);logger['debug'](_0xfa80('0x22'),_0x352f8b,JSON[_0xfa80('0x20')](_0x5a90e5));_0x193192(_0x5a90e5);})[_0xfa80('0x21')](function(_0x3d361c){logger[_0xfa80('0x11')](_0xfa80('0x22'),_0x3d361c[_0xfa80('0x13')],_0x352f8b);_0x41ae75(_0x1fd636['error'](0x1f4,_0x3d361c[_0xfa80('0x13')]));});});};