Built motion from commit (unavailable).|2.4.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 _0x1365=['SmsQueue','findAll','options','raw','where','attributes','limit','map','include','model','GetSmsQueue','debug','ShowSmsQueue','find','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','redis','defaults','localhost','socket.io-emitter','register','request','then','info','SmsQueue,\x20%s,\x20%s','request\x20sent','SmsQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch'];(function(_0x3be82c,_0x3307d7){var _0x40d25a=function(_0x582dda){while(--_0x582dda){_0x3be82c['push'](_0x3be82c['shift']());}};_0x40d25a(++_0x3307d7);}(_0x1365,0x1b2));var _0x5136=function(_0xb67251,_0x1f6208){_0xb67251=_0xb67251-0x0;var _0x979d96=_0x1365[_0xb67251];return _0x979d96;};'use strict';var _=require('lodash');var util=require(_0x5136('0x0'));var moment=require('moment');var BPromise=require(_0x5136('0x1'));var rs=require(_0x5136('0x2'));var fs=require('fs');var Redis=require(_0x5136('0x3'));var db=require(_0x5136('0x4'))['db'];var utils=require(_0x5136('0x5'));var logger=require(_0x5136('0x6'))(_0x5136('0x7'));var config=require(_0x5136('0x8'));var jayson=require(_0x5136('0x9'));var client=jayson['client'][_0x5136('0xa')]({'port':0x232a});config[_0x5136('0xb')]=_[_0x5136('0xc')](config['redis'],{'host':_0x5136('0xd'),'port':0x18eb});var socket=require(_0x5136('0xe'))(new Redis(config[_0x5136('0xb')]));require('./smsQueue.socket')[_0x5136('0xf')](socket);function respondWithRpcPromise(_0x129f51,_0x1e0624,_0x2b8d1b){return new BPromise(function(_0x20ece4,_0x3b2e71){return client[_0x5136('0x10')](_0x129f51,_0x2b8d1b)[_0x5136('0x11')](function(_0x4f1f90){logger[_0x5136('0x12')](_0x5136('0x13'),_0x1e0624,_0x5136('0x14'));logger['debug'](_0x5136('0x15'),_0x1e0624,_0x5136('0x14'),JSON[_0x5136('0x16')](_0x4f1f90));if(_0x4f1f90['error']){if(_0x4f1f90[_0x5136('0x17')][_0x5136('0x18')]===0x1f4){logger['error']('SmsQueue,\x20%s,\x20%s',_0x1e0624,_0x4f1f90[_0x5136('0x17')][_0x5136('0x19')]);return _0x3b2e71(_0x4f1f90[_0x5136('0x17')][_0x5136('0x19')]);}logger[_0x5136('0x17')]('SmsQueue,\x20%s,\x20%s',_0x1e0624,_0x4f1f90['error'][_0x5136('0x19')]);return _0x20ece4(_0x4f1f90['error']['message']);}else{logger['info'](_0x5136('0x13'),_0x1e0624,'request\x20sent');_0x20ece4(_0x4f1f90[_0x5136('0x1a')]['message']);}})[_0x5136('0x1b')](function(_0x1563f9){logger[_0x5136('0x17')](_0x5136('0x13'),_0x1e0624,_0x1563f9);_0x3b2e71(_0x1563f9);});});}exports['GetSmsQueue']=function(_0x432425){var _0x23d83b=this;return new Promise(function(_0x5abdc1,_0x37b97b){return db[_0x5136('0x1c')][_0x5136('0x1d')]({'raw':_0x432425[_0x5136('0x1e')]?_0x432425[_0x5136('0x1e')][_0x5136('0x1f')]===undefined?!![]:![]:!![],'where':_0x432425[_0x5136('0x1e')]?_0x432425['options'][_0x5136('0x20')]||null:null,'attributes':_0x432425[_0x5136('0x1e')]?_0x432425['options'][_0x5136('0x21')]||null:null,'limit':_0x432425[_0x5136('0x1e')]?_0x432425[_0x5136('0x1e')][_0x5136('0x22')]||null:null,'include':_0x432425['options']?_0x432425['options']['include']?_[_0x5136('0x23')](_0x432425['options'][_0x5136('0x24')],function(_0x4b0691){return{'model':db[_0x4b0691[_0x5136('0x25')]],'as':_0x4b0691['as'],'attributes':_0x4b0691[_0x5136('0x21')],'include':_0x4b0691[_0x5136('0x24')]?_[_0x5136('0x23')](_0x4b0691['include'],function(_0x3a4ec7){return{'model':db[_0x3a4ec7[_0x5136('0x25')]],'as':_0x3a4ec7['as'],'attributes':_0x3a4ec7['attributes'],'include':_0x3a4ec7[_0x5136('0x24')]?_[_0x5136('0x23')](_0x3a4ec7['include'],function(_0x3f86d6){return{'model':db[_0x3f86d6[_0x5136('0x25')]],'as':_0x3f86d6['as'],'attributes':_0x3f86d6['attributes']};}):[]};}):[]};}):[]:[]})[_0x5136('0x11')](function(_0x5002c4){logger[_0x5136('0x12')](_0x5136('0x26'),_0x432425);logger[_0x5136('0x27')]('GetSmsQueue',_0x432425,JSON[_0x5136('0x16')](_0x5002c4));_0x5abdc1(_0x5002c4);})['catch'](function(_0x35668b){logger['error']('GetSmsQueue',_0x35668b[_0x5136('0x19')],_0x432425);_0x37b97b(_0x23d83b['error'](0x1f4,_0x35668b[_0x5136('0x19')]));});});};exports[_0x5136('0x28')]=function(_0xc35466){var _0x17e790=this;return new Promise(function(_0x3f2d53,_0x581a2c){return db[_0x5136('0x1c')][_0x5136('0x29')]({'raw':_0xc35466[_0x5136('0x1e')]?_0xc35466[_0x5136('0x1e')]['raw']===undefined?!![]:![]:!![],'where':_0xc35466[_0x5136('0x1e')]?_0xc35466[_0x5136('0x1e')][_0x5136('0x20')]||null:null,'attributes':_0xc35466[_0x5136('0x1e')]?_0xc35466[_0x5136('0x1e')][_0x5136('0x21')]||null:null,'include':_0xc35466[_0x5136('0x1e')]?_0xc35466['options']['include']?_[_0x5136('0x23')](_0xc35466[_0x5136('0x1e')][_0x5136('0x24')],function(_0x3c4c68){return{'model':db[_0x3c4c68['model']],'as':_0x3c4c68['as'],'attributes':_0x3c4c68[_0x5136('0x21')],'include':_0x3c4c68[_0x5136('0x24')]?_[_0x5136('0x23')](_0x3c4c68[_0x5136('0x24')],function(_0x3f170c){return{'model':db[_0x3f170c['model']],'as':_0x3f170c['as'],'attributes':_0x3f170c[_0x5136('0x21')],'include':_0x3f170c[_0x5136('0x24')]?_[_0x5136('0x23')](_0x3f170c[_0x5136('0x24')],function(_0x184187){return{'model':db[_0x184187[_0x5136('0x25')]],'as':_0x184187['as'],'attributes':_0x184187['attributes']};}):[]};}):[]};}):[]:[]})[_0x5136('0x11')](function(_0x9d1491){logger[_0x5136('0x12')]('ShowSmsQueue',_0xc35466);logger[_0x5136('0x27')](_0x5136('0x28'),_0xc35466,JSON[_0x5136('0x16')](_0x9d1491));_0x3f2d53(_0x9d1491);})[_0x5136('0x1b')](function(_0x6c91c0){logger['error']('ShowSmsQueue',_0x6c91c0[_0x5136('0x19')],_0xc35466);_0x581a2c(_0x17e790['error'](0x1f4,_0x6c91c0[_0x5136('0x19')]));});});};