Built motion from commit (unavailable).|2.5.5
[motion2.git] / server / api / whatsappQueue / whatsappQueue.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 _0x2ae0=['../../mysqldb','../../config/environment','jayson/promise','client','http','defaults','localhost','redis','./whatsappQueue.socket','request\x20sent','WhatsappQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','WhatsappQueue,\x20%s,\x20%s','message','info','result','catch','GetWhatsappQueue','WhatsappQueue','findAll','options','where','attributes','limit','include','map','model','then','debug','ShowWhatsappQueue','raw','lodash','util','moment','bluebird','randomstring','ioredis'];(function(_0x25b5f4,_0x763825){var _0x17ccc7=function(_0x539f6b){while(--_0x539f6b){_0x25b5f4['push'](_0x25b5f4['shift']());}};_0x17ccc7(++_0x763825);}(_0x2ae0,0xbd));var _0x02ae=function(_0x2bc3ab,_0x5aec1b){_0x2bc3ab=_0x2bc3ab-0x0;var _0x3625c9=_0x2ae0[_0x2bc3ab];return _0x3625c9;};'use strict';var _=require(_0x02ae('0x0'));var util=require(_0x02ae('0x1'));var moment=require(_0x02ae('0x2'));var BPromise=require(_0x02ae('0x3'));var rs=require(_0x02ae('0x4'));var fs=require('fs');var Redis=require(_0x02ae('0x5'));var db=require(_0x02ae('0x6'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require(_0x02ae('0x7'));var jayson=require(_0x02ae('0x8'));var client=jayson[_0x02ae('0x9')][_0x02ae('0xa')]({'port':0x232a});config['redis']=_[_0x02ae('0xb')](config['redis'],{'host':_0x02ae('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x02ae('0xd')]));require(_0x02ae('0xe'))['register'](socket);function respondWithRpcPromise(_0x542671,_0x1fefdd,_0x180a42){return new BPromise(function(_0x128cb0,_0x27f04e){return client['request'](_0x542671,_0x180a42)['then'](function(_0x53642c){logger['info']('WhatsappQueue,\x20%s,\x20%s',_0x1fefdd,_0x02ae('0xf'));logger['debug'](_0x02ae('0x10'),_0x1fefdd,_0x02ae('0xf'),JSON[_0x02ae('0x11')](_0x53642c));if(_0x53642c[_0x02ae('0x12')]){if(_0x53642c[_0x02ae('0x12')][_0x02ae('0x13')]===0x1f4){logger[_0x02ae('0x12')](_0x02ae('0x14'),_0x1fefdd,_0x53642c['error'][_0x02ae('0x15')]);return _0x27f04e(_0x53642c[_0x02ae('0x12')]['message']);}logger[_0x02ae('0x12')](_0x02ae('0x14'),_0x1fefdd,_0x53642c['error'][_0x02ae('0x15')]);return _0x128cb0(_0x53642c[_0x02ae('0x12')]['message']);}else{logger[_0x02ae('0x16')](_0x02ae('0x14'),_0x1fefdd,_0x02ae('0xf'));_0x128cb0(_0x53642c[_0x02ae('0x17')][_0x02ae('0x15')]);}})[_0x02ae('0x18')](function(_0x56c81c){logger[_0x02ae('0x12')]('WhatsappQueue,\x20%s,\x20%s',_0x1fefdd,_0x56c81c);_0x27f04e(_0x56c81c);});});}exports[_0x02ae('0x19')]=function(_0x53d911){var _0x1ee159=this;return new Promise(function(_0x14be2d,_0x405bab){return db[_0x02ae('0x1a')][_0x02ae('0x1b')]({'raw':_0x53d911[_0x02ae('0x1c')]?_0x53d911[_0x02ae('0x1c')]['raw']===undefined?!![]:![]:!![],'where':_0x53d911[_0x02ae('0x1c')]?_0x53d911[_0x02ae('0x1c')][_0x02ae('0x1d')]||null:null,'attributes':_0x53d911[_0x02ae('0x1c')]?_0x53d911[_0x02ae('0x1c')][_0x02ae('0x1e')]||null:null,'limit':_0x53d911[_0x02ae('0x1c')]?_0x53d911[_0x02ae('0x1c')][_0x02ae('0x1f')]||null:null,'include':_0x53d911[_0x02ae('0x1c')]?_0x53d911[_0x02ae('0x1c')][_0x02ae('0x20')]?_[_0x02ae('0x21')](_0x53d911['options'][_0x02ae('0x20')],function(_0x228196){return{'model':db[_0x228196['model']],'as':_0x228196['as'],'attributes':_0x228196[_0x02ae('0x1e')],'include':_0x228196['include']?_['map'](_0x228196['include'],function(_0x78be37){return{'model':db[_0x78be37[_0x02ae('0x22')]],'as':_0x78be37['as'],'attributes':_0x78be37[_0x02ae('0x1e')],'include':_0x78be37[_0x02ae('0x20')]?_[_0x02ae('0x21')](_0x78be37[_0x02ae('0x20')],function(_0x5f7eea){return{'model':db[_0x5f7eea[_0x02ae('0x22')]],'as':_0x5f7eea['as'],'attributes':_0x5f7eea['attributes']};}):[]};}):[]};}):[]:[]})[_0x02ae('0x23')](function(_0x33132f){logger[_0x02ae('0x16')](_0x02ae('0x19'),_0x53d911);logger[_0x02ae('0x24')](_0x02ae('0x19'),_0x53d911,JSON[_0x02ae('0x11')](_0x33132f));_0x14be2d(_0x33132f);})['catch'](function(_0x78ca93){logger['error'](_0x02ae('0x19'),_0x78ca93['message'],_0x53d911);_0x405bab(_0x1ee159[_0x02ae('0x12')](0x1f4,_0x78ca93[_0x02ae('0x15')]));});});};exports[_0x02ae('0x25')]=function(_0xc876be){var _0x2a63a2=this;return new Promise(function(_0x2afce0,_0x55b89e){return db['WhatsappQueue']['find']({'raw':_0xc876be[_0x02ae('0x1c')]?_0xc876be[_0x02ae('0x1c')][_0x02ae('0x26')]===undefined?!![]:![]:!![],'where':_0xc876be[_0x02ae('0x1c')]?_0xc876be[_0x02ae('0x1c')][_0x02ae('0x1d')]||null:null,'attributes':_0xc876be[_0x02ae('0x1c')]?_0xc876be[_0x02ae('0x1c')][_0x02ae('0x1e')]||null:null,'include':_0xc876be[_0x02ae('0x1c')]?_0xc876be[_0x02ae('0x1c')][_0x02ae('0x20')]?_['map'](_0xc876be[_0x02ae('0x1c')][_0x02ae('0x20')],function(_0x4b18f9){return{'model':db[_0x4b18f9[_0x02ae('0x22')]],'as':_0x4b18f9['as'],'attributes':_0x4b18f9[_0x02ae('0x1e')],'include':_0x4b18f9[_0x02ae('0x20')]?_[_0x02ae('0x21')](_0x4b18f9['include'],function(_0x522188){return{'model':db[_0x522188['model']],'as':_0x522188['as'],'attributes':_0x522188[_0x02ae('0x1e')],'include':_0x522188['include']?_['map'](_0x522188[_0x02ae('0x20')],function(_0x1d9219){return{'model':db[_0x1d9219[_0x02ae('0x22')]],'as':_0x1d9219['as'],'attributes':_0x1d9219[_0x02ae('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x02ae('0x23')](function(_0x52751c){logger[_0x02ae('0x16')](_0x02ae('0x25'),_0xc876be);logger['debug'](_0x02ae('0x25'),_0xc876be,JSON[_0x02ae('0x11')](_0x52751c));_0x2afce0(_0x52751c);})['catch'](function(_0x5ac135){logger[_0x02ae('0x12')]('ShowWhatsappQueue',_0x5ac135[_0x02ae('0x15')],_0xc876be);_0x55b89e(_0x2a63a2[_0x02ae('0x12')](0x1f4,_0x5ac135['message']));});});};