Built motion from commit (unavailable).|2.5.13
[motion2.git] / server / api / whatsappAccount / whatsappAccount.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 _0x7fff=['http','redis','localhost','socket.io-emitter','register','then','info','debug','WhatsappAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','code','error','WhatsappAccount,\x20%s,\x20%s','message','result','ShowWhatsappAccount','WhatsappAccount','find','options','raw','where','map','model','attributes','include','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise'];(function(_0x435e67,_0x2aa856){var _0x544f0c=function(_0x416cdb){while(--_0x416cdb){_0x435e67['push'](_0x435e67['shift']());}};_0x544f0c(++_0x2aa856);}(_0x7fff,0x1a6));var _0xf7ff=function(_0x486476,_0x5c400a){_0x486476=_0x486476-0x0;var _0x49b14a=_0x7fff[_0x486476];return _0x49b14a;};'use strict';var _=require(_0xf7ff('0x0'));var util=require(_0xf7ff('0x1'));var moment=require('moment');var BPromise=require(_0xf7ff('0x2'));var rs=require(_0xf7ff('0x3'));var fs=require('fs');var Redis=require(_0xf7ff('0x4'));var db=require(_0xf7ff('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xf7ff('0x6'))(_0xf7ff('0x7'));var config=require(_0xf7ff('0x8'));var jayson=require(_0xf7ff('0x9'));var client=jayson['client'][_0xf7ff('0xa')]({'port':0x232a});config[_0xf7ff('0xb')]=_['defaults'](config['redis'],{'host':_0xf7ff('0xc'),'port':0x18eb});var socket=require(_0xf7ff('0xd'))(new Redis(config[_0xf7ff('0xb')]));require('./whatsappAccount.socket')[_0xf7ff('0xe')](socket);function respondWithRpcPromise(_0x2399e3,_0x1cfeae,_0x2882c6){return new BPromise(function(_0x574dd7,_0x2f7b85){return client['request'](_0x2399e3,_0x2882c6)[_0xf7ff('0xf')](function(_0x15a0c0){logger[_0xf7ff('0x10')]('WhatsappAccount,\x20%s,\x20%s',_0x1cfeae,'request\x20sent');logger[_0xf7ff('0x11')](_0xf7ff('0x12'),_0x1cfeae,_0xf7ff('0x13'),JSON[_0xf7ff('0x14')](_0x15a0c0));if(_0x15a0c0['error']){if(_0x15a0c0['error'][_0xf7ff('0x15')]===0x1f4){logger[_0xf7ff('0x16')](_0xf7ff('0x17'),_0x1cfeae,_0x15a0c0[_0xf7ff('0x16')]['message']);return _0x2f7b85(_0x15a0c0[_0xf7ff('0x16')]['message']);}logger['error']('WhatsappAccount,\x20%s,\x20%s',_0x1cfeae,_0x15a0c0[_0xf7ff('0x16')][_0xf7ff('0x18')]);return _0x574dd7(_0x15a0c0[_0xf7ff('0x16')]['message']);}else{logger[_0xf7ff('0x10')](_0xf7ff('0x17'),_0x1cfeae,_0xf7ff('0x13'));_0x574dd7(_0x15a0c0[_0xf7ff('0x19')][_0xf7ff('0x18')]);}})['catch'](function(_0x144fd0){logger['error'](_0xf7ff('0x17'),_0x1cfeae,_0x144fd0);_0x2f7b85(_0x144fd0);});});}exports[_0xf7ff('0x1a')]=function(_0x13366b){var _0x2333bf=this;return new Promise(function(_0x15a9b0,_0x2a4c66){return db[_0xf7ff('0x1b')][_0xf7ff('0x1c')]({'raw':_0x13366b[_0xf7ff('0x1d')]?_0x13366b[_0xf7ff('0x1d')][_0xf7ff('0x1e')]===undefined?!![]:![]:!![],'where':_0x13366b[_0xf7ff('0x1d')]?_0x13366b[_0xf7ff('0x1d')][_0xf7ff('0x1f')]||null:null,'attributes':_0x13366b['options']?_0x13366b[_0xf7ff('0x1d')]['attributes']||null:null,'include':_0x13366b['options']?_0x13366b[_0xf7ff('0x1d')]['include']?_[_0xf7ff('0x20')](_0x13366b[_0xf7ff('0x1d')]['include'],function(_0x17f2d4){return{'model':db[_0x17f2d4[_0xf7ff('0x21')]],'as':_0x17f2d4['as'],'attributes':_0x17f2d4[_0xf7ff('0x22')],'include':_0x17f2d4[_0xf7ff('0x23')]?_[_0xf7ff('0x20')](_0x17f2d4[_0xf7ff('0x23')],function(_0x147109){return{'model':db[_0x147109[_0xf7ff('0x21')]],'as':_0x147109['as'],'attributes':_0x147109['attributes'],'include':_0x147109['include']?_[_0xf7ff('0x20')](_0x147109[_0xf7ff('0x23')],function(_0x2b1eea){return{'model':db[_0x2b1eea[_0xf7ff('0x21')]],'as':_0x2b1eea['as'],'attributes':_0x2b1eea[_0xf7ff('0x22')]};}):[]};}):[]};}):[]:[]})['then'](function(_0xb583d3){logger[_0xf7ff('0x10')](_0xf7ff('0x1a'),_0x13366b);logger['debug'](_0xf7ff('0x1a'),_0x13366b,JSON[_0xf7ff('0x14')](_0xb583d3));_0x15a9b0(_0xb583d3);})['catch'](function(_0xdb7b00){logger['error']('ShowWhatsappAccount',_0xdb7b00[_0xf7ff('0x18')],_0x13366b);_0x2a4c66(_0x2333bf['error'](0x1f4,_0xdb7b00[_0xf7ff('0x18')]));});});};