Built motion from commit (unavailable).|2.5.6
[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 _0xf938=['request','then','info','WhatsappQueue,\x20%s,\x20%s','request\x20sent','debug','WhatsappQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','options','raw','attributes','limit','map','model','include','GetWhatsappQueue','ShowWhatsappQueue','WhatsappQueue','where','util','moment','randomstring','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','./whatsappQueue.socket'];(function(_0x15dee4,_0xf1fa24){var _0x42fc7b=function(_0x3529af){while(--_0x3529af){_0x15dee4['push'](_0x15dee4['shift']());}};_0x42fc7b(++_0xf1fa24);}(_0xf938,0x86));var _0x8f93=function(_0x177dc7,_0x13501c){_0x177dc7=_0x177dc7-0x0;var _0x19b7dc=_0xf938[_0x177dc7];return _0x19b7dc;};'use strict';var _=require('lodash');var util=require(_0x8f93('0x0'));var moment=require(_0x8f93('0x1'));var BPromise=require('bluebird');var rs=require(_0x8f93('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x8f93('0x3'))['db'];var utils=require(_0x8f93('0x4'));var logger=require(_0x8f93('0x5'))('rpc');var config=require(_0x8f93('0x6'));var jayson=require(_0x8f93('0x7'));var client=jayson[_0x8f93('0x8')][_0x8f93('0x9')]({'port':0x232a});config[_0x8f93('0xa')]=_[_0x8f93('0xb')](config[_0x8f93('0xa')],{'host':_0x8f93('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x8f93('0xa')]));require(_0x8f93('0xd'))['register'](socket);function respondWithRpcPromise(_0x518d60,_0x3f9087,_0x4e6528){return new BPromise(function(_0x276ad9,_0x4b1201){return client[_0x8f93('0xe')](_0x518d60,_0x4e6528)[_0x8f93('0xf')](function(_0x28d8dc){logger[_0x8f93('0x10')](_0x8f93('0x11'),_0x3f9087,_0x8f93('0x12'));logger[_0x8f93('0x13')](_0x8f93('0x14'),_0x3f9087,_0x8f93('0x12'),JSON[_0x8f93('0x15')](_0x28d8dc));if(_0x28d8dc['error']){if(_0x28d8dc[_0x8f93('0x16')][_0x8f93('0x17')]===0x1f4){logger[_0x8f93('0x16')](_0x8f93('0x11'),_0x3f9087,_0x28d8dc[_0x8f93('0x16')][_0x8f93('0x18')]);return _0x4b1201(_0x28d8dc[_0x8f93('0x16')]['message']);}logger[_0x8f93('0x16')](_0x8f93('0x11'),_0x3f9087,_0x28d8dc[_0x8f93('0x16')][_0x8f93('0x18')]);return _0x276ad9(_0x28d8dc['error']['message']);}else{logger[_0x8f93('0x10')](_0x8f93('0x11'),_0x3f9087,_0x8f93('0x12'));_0x276ad9(_0x28d8dc['result'][_0x8f93('0x18')]);}})[_0x8f93('0x19')](function(_0x35d5cc){logger[_0x8f93('0x16')]('WhatsappQueue,\x20%s,\x20%s',_0x3f9087,_0x35d5cc);_0x4b1201(_0x35d5cc);});});}exports['GetWhatsappQueue']=function(_0x3a8948){var _0x26f069=this;return new Promise(function(_0x5d5382,_0x3930a8){return db['WhatsappQueue']['findAll']({'raw':_0x3a8948[_0x8f93('0x1a')]?_0x3a8948['options'][_0x8f93('0x1b')]===undefined?!![]:![]:!![],'where':_0x3a8948[_0x8f93('0x1a')]?_0x3a8948['options']['where']||null:null,'attributes':_0x3a8948[_0x8f93('0x1a')]?_0x3a8948['options'][_0x8f93('0x1c')]||null:null,'limit':_0x3a8948['options']?_0x3a8948[_0x8f93('0x1a')][_0x8f93('0x1d')]||null:null,'include':_0x3a8948[_0x8f93('0x1a')]?_0x3a8948[_0x8f93('0x1a')]['include']?_[_0x8f93('0x1e')](_0x3a8948[_0x8f93('0x1a')]['include'],function(_0x120e96){return{'model':db[_0x120e96[_0x8f93('0x1f')]],'as':_0x120e96['as'],'attributes':_0x120e96[_0x8f93('0x1c')],'include':_0x120e96[_0x8f93('0x20')]?_[_0x8f93('0x1e')](_0x120e96['include'],function(_0x2e2eb4){return{'model':db[_0x2e2eb4[_0x8f93('0x1f')]],'as':_0x2e2eb4['as'],'attributes':_0x2e2eb4[_0x8f93('0x1c')],'include':_0x2e2eb4['include']?_[_0x8f93('0x1e')](_0x2e2eb4[_0x8f93('0x20')],function(_0x1c0ea7){return{'model':db[_0x1c0ea7[_0x8f93('0x1f')]],'as':_0x1c0ea7['as'],'attributes':_0x1c0ea7[_0x8f93('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x8f93('0xf')](function(_0x11b0f1){logger[_0x8f93('0x10')](_0x8f93('0x21'),_0x3a8948);logger[_0x8f93('0x13')](_0x8f93('0x21'),_0x3a8948,JSON[_0x8f93('0x15')](_0x11b0f1));_0x5d5382(_0x11b0f1);})[_0x8f93('0x19')](function(_0x6222ad){logger[_0x8f93('0x16')](_0x8f93('0x21'),_0x6222ad[_0x8f93('0x18')],_0x3a8948);_0x3930a8(_0x26f069[_0x8f93('0x16')](0x1f4,_0x6222ad[_0x8f93('0x18')]));});});};exports[_0x8f93('0x22')]=function(_0x1db086){var _0x4911d0=this;return new Promise(function(_0x235c29,_0x4aaedf){return db[_0x8f93('0x23')]['find']({'raw':_0x1db086[_0x8f93('0x1a')]?_0x1db086[_0x8f93('0x1a')][_0x8f93('0x1b')]===undefined?!![]:![]:!![],'where':_0x1db086[_0x8f93('0x1a')]?_0x1db086[_0x8f93('0x1a')][_0x8f93('0x24')]||null:null,'attributes':_0x1db086[_0x8f93('0x1a')]?_0x1db086[_0x8f93('0x1a')]['attributes']||null:null,'include':_0x1db086['options']?_0x1db086['options'][_0x8f93('0x20')]?_[_0x8f93('0x1e')](_0x1db086[_0x8f93('0x1a')][_0x8f93('0x20')],function(_0x1298b3){return{'model':db[_0x1298b3['model']],'as':_0x1298b3['as'],'attributes':_0x1298b3[_0x8f93('0x1c')],'include':_0x1298b3[_0x8f93('0x20')]?_[_0x8f93('0x1e')](_0x1298b3['include'],function(_0x573353){return{'model':db[_0x573353[_0x8f93('0x1f')]],'as':_0x573353['as'],'attributes':_0x573353[_0x8f93('0x1c')],'include':_0x573353[_0x8f93('0x20')]?_[_0x8f93('0x1e')](_0x573353['include'],function(_0x646840){return{'model':db[_0x646840[_0x8f93('0x1f')]],'as':_0x646840['as'],'attributes':_0x646840[_0x8f93('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x10b832){logger[_0x8f93('0x10')]('ShowWhatsappQueue',_0x1db086);logger[_0x8f93('0x13')](_0x8f93('0x22'),_0x1db086,JSON['stringify'](_0x10b832));_0x235c29(_0x10b832);})['catch'](function(_0x3e6bbf){logger[_0x8f93('0x16')](_0x8f93('0x22'),_0x3e6bbf['message'],_0x1db086);_0x4aaedf(_0x4911d0[_0x8f93('0x16')](0x1f4,_0x3e6bbf[_0x8f93('0x18')]));});});};