9a9d3d4ea85b50e11b5acaff8088c2e8137378bc
[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 _0x8804=['request\x20sent','debug','WhatsappAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','WhatsappAccount','find','options','raw','where','attributes','include','map','model','ShowWhatsappAccount','lodash','util','moment','bluebird','randomstring','ioredis','rpc','../../config/environment','jayson/promise','http','defaults','redis','localhost','./whatsappAccount.socket','request','then','info','WhatsappAccount,\x20%s,\x20%s'];(function(_0x2155f5,_0x4e7345){var _0x2d8d88=function(_0x1d2e3a){while(--_0x1d2e3a){_0x2155f5['push'](_0x2155f5['shift']());}};_0x2d8d88(++_0x4e7345);}(_0x8804,0x160));var _0x4880=function(_0x18fa44,_0x1143f5){_0x18fa44=_0x18fa44-0x0;var _0x5cf7d0=_0x8804[_0x18fa44];return _0x5cf7d0;};'use strict';var _=require(_0x4880('0x0'));var util=require(_0x4880('0x1'));var moment=require(_0x4880('0x2'));var BPromise=require(_0x4880('0x3'));var rs=require(_0x4880('0x4'));var fs=require('fs');var Redis=require(_0x4880('0x5'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x4880('0x6'));var config=require(_0x4880('0x7'));var jayson=require(_0x4880('0x8'));var client=jayson['client'][_0x4880('0x9')]({'port':0x232a});config['redis']=_[_0x4880('0xa')](config[_0x4880('0xb')],{'host':_0x4880('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x4880('0xb')]));require(_0x4880('0xd'))['register'](socket);function respondWithRpcPromise(_0x392616,_0x5e9070,_0x5b7395){return new BPromise(function(_0x3c26b7,_0x1ecf06){return client[_0x4880('0xe')](_0x392616,_0x5b7395)[_0x4880('0xf')](function(_0x3445d3){logger[_0x4880('0x10')](_0x4880('0x11'),_0x5e9070,_0x4880('0x12'));logger[_0x4880('0x13')](_0x4880('0x14'),_0x5e9070,'request\x20sent',JSON[_0x4880('0x15')](_0x3445d3));if(_0x3445d3['error']){if(_0x3445d3[_0x4880('0x16')][_0x4880('0x17')]===0x1f4){logger[_0x4880('0x16')](_0x4880('0x11'),_0x5e9070,_0x3445d3['error'][_0x4880('0x18')]);return _0x1ecf06(_0x3445d3['error'][_0x4880('0x18')]);}logger[_0x4880('0x16')]('WhatsappAccount,\x20%s,\x20%s',_0x5e9070,_0x3445d3[_0x4880('0x16')][_0x4880('0x18')]);return _0x3c26b7(_0x3445d3['error'][_0x4880('0x18')]);}else{logger[_0x4880('0x10')](_0x4880('0x11'),_0x5e9070,'request\x20sent');_0x3c26b7(_0x3445d3[_0x4880('0x19')]['message']);}})[_0x4880('0x1a')](function(_0x127b28){logger['error']('WhatsappAccount,\x20%s,\x20%s',_0x5e9070,_0x127b28);_0x1ecf06(_0x127b28);});});}exports['ShowWhatsappAccount']=function(_0x15f964){var _0x28078a=this;return new Promise(function(_0x10dc6a,_0x516b69){return db[_0x4880('0x1b')][_0x4880('0x1c')]({'raw':_0x15f964[_0x4880('0x1d')]?_0x15f964[_0x4880('0x1d')][_0x4880('0x1e')]===undefined?!![]:![]:!![],'where':_0x15f964[_0x4880('0x1d')]?_0x15f964[_0x4880('0x1d')][_0x4880('0x1f')]||null:null,'attributes':_0x15f964[_0x4880('0x1d')]?_0x15f964[_0x4880('0x1d')][_0x4880('0x20')]||null:null,'include':_0x15f964['options']?_0x15f964['options'][_0x4880('0x21')]?_[_0x4880('0x22')](_0x15f964['options'][_0x4880('0x21')],function(_0x74639b){return{'model':db[_0x74639b['model']],'as':_0x74639b['as'],'attributes':_0x74639b[_0x4880('0x20')],'include':_0x74639b[_0x4880('0x21')]?_[_0x4880('0x22')](_0x74639b['include'],function(_0x1e97b3){return{'model':db[_0x1e97b3[_0x4880('0x23')]],'as':_0x1e97b3['as'],'attributes':_0x1e97b3[_0x4880('0x20')],'include':_0x1e97b3[_0x4880('0x21')]?_[_0x4880('0x22')](_0x1e97b3[_0x4880('0x21')],function(_0x40cf1f){return{'model':db[_0x40cf1f[_0x4880('0x23')]],'as':_0x40cf1f['as'],'attributes':_0x40cf1f[_0x4880('0x20')]};}):[]};}):[]};}):[]:[]})[_0x4880('0xf')](function(_0x4f5fef){logger['info']('ShowWhatsappAccount',_0x15f964);logger[_0x4880('0x13')](_0x4880('0x24'),_0x15f964,JSON[_0x4880('0x15')](_0x4f5fef));_0x10dc6a(_0x4f5fef);})[_0x4880('0x1a')](function(_0x33f1b8){logger[_0x4880('0x16')](_0x4880('0x24'),_0x33f1b8[_0x4880('0x18')],_0x15f964);_0x516b69(_0x28078a[_0x4880('0x16')](0x1f4,_0x33f1b8[_0x4880('0x18')]));});});};