40b632426c69c14d9dd075cd7b1ce0835b199cae
[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 _0xb237=['where','attributes','include','map','model','ShowWhatsappAccount','util','moment','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','redis','defaults','localhost','socket.io-emitter','./whatsappAccount.socket','request','then','info','WhatsappAccount,\x20%s,\x20%s','request\x20sent','debug','WhatsappAccount,\x20%s,\x20%s,\x20%s','stringify','code','error','message','result','catch','WhatsappAccount','find','options','raw'];(function(_0x343fc5,_0x2abe0f){var _0x56dd22=function(_0x48136f){while(--_0x48136f){_0x343fc5['push'](_0x343fc5['shift']());}};_0x56dd22(++_0x2abe0f);}(_0xb237,0x178));var _0x7b23=function(_0x33d306,_0x9f80ed){_0x33d306=_0x33d306-0x0;var _0x54d911=_0xb237[_0x33d306];return _0x54d911;};'use strict';var _=require('lodash');var util=require(_0x7b23('0x0'));var moment=require(_0x7b23('0x1'));var BPromise=require('bluebird');var rs=require(_0x7b23('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x7b23('0x3'))['db'];var utils=require(_0x7b23('0x4'));var logger=require(_0x7b23('0x5'))(_0x7b23('0x6'));var config=require(_0x7b23('0x7'));var jayson=require(_0x7b23('0x8'));var client=jayson['client']['http']({'port':0x232a});config[_0x7b23('0x9')]=_[_0x7b23('0xa')](config[_0x7b23('0x9')],{'host':_0x7b23('0xb'),'port':0x18eb});var socket=require(_0x7b23('0xc'))(new Redis(config[_0x7b23('0x9')]));require(_0x7b23('0xd'))['register'](socket);function respondWithRpcPromise(_0x5981f4,_0xb2fe5f,_0x2fc507){return new BPromise(function(_0x48ca0a,_0x2e8cae){return client[_0x7b23('0xe')](_0x5981f4,_0x2fc507)[_0x7b23('0xf')](function(_0x127c73){logger[_0x7b23('0x10')](_0x7b23('0x11'),_0xb2fe5f,_0x7b23('0x12'));logger[_0x7b23('0x13')](_0x7b23('0x14'),_0xb2fe5f,_0x7b23('0x12'),JSON[_0x7b23('0x15')](_0x127c73));if(_0x127c73['error']){if(_0x127c73['error'][_0x7b23('0x16')]===0x1f4){logger[_0x7b23('0x17')](_0x7b23('0x11'),_0xb2fe5f,_0x127c73[_0x7b23('0x17')][_0x7b23('0x18')]);return _0x2e8cae(_0x127c73[_0x7b23('0x17')][_0x7b23('0x18')]);}logger[_0x7b23('0x17')](_0x7b23('0x11'),_0xb2fe5f,_0x127c73[_0x7b23('0x17')][_0x7b23('0x18')]);return _0x48ca0a(_0x127c73[_0x7b23('0x17')]['message']);}else{logger['info'](_0x7b23('0x11'),_0xb2fe5f,_0x7b23('0x12'));_0x48ca0a(_0x127c73[_0x7b23('0x19')]['message']);}})[_0x7b23('0x1a')](function(_0x34bcf4){logger[_0x7b23('0x17')](_0x7b23('0x11'),_0xb2fe5f,_0x34bcf4);_0x2e8cae(_0x34bcf4);});});}exports['ShowWhatsappAccount']=function(_0x258dc1){var _0x55f840=this;return new Promise(function(_0x5767c3,_0x6a30d6){return db[_0x7b23('0x1b')][_0x7b23('0x1c')]({'raw':_0x258dc1[_0x7b23('0x1d')]?_0x258dc1['options'][_0x7b23('0x1e')]===undefined?!![]:![]:!![],'where':_0x258dc1[_0x7b23('0x1d')]?_0x258dc1['options'][_0x7b23('0x1f')]||null:null,'attributes':_0x258dc1[_0x7b23('0x1d')]?_0x258dc1[_0x7b23('0x1d')][_0x7b23('0x20')]||null:null,'include':_0x258dc1[_0x7b23('0x1d')]?_0x258dc1[_0x7b23('0x1d')][_0x7b23('0x21')]?_[_0x7b23('0x22')](_0x258dc1[_0x7b23('0x1d')][_0x7b23('0x21')],function(_0x1f8a85){return{'model':db[_0x1f8a85['model']],'as':_0x1f8a85['as'],'attributes':_0x1f8a85[_0x7b23('0x20')],'include':_0x1f8a85[_0x7b23('0x21')]?_[_0x7b23('0x22')](_0x1f8a85[_0x7b23('0x21')],function(_0x3a2d86){return{'model':db[_0x3a2d86[_0x7b23('0x23')]],'as':_0x3a2d86['as'],'attributes':_0x3a2d86['attributes'],'include':_0x3a2d86['include']?_[_0x7b23('0x22')](_0x3a2d86['include'],function(_0x4c34f2){return{'model':db[_0x4c34f2['model']],'as':_0x4c34f2['as'],'attributes':_0x4c34f2[_0x7b23('0x20')]};}):[]};}):[]};}):[]:[]})[_0x7b23('0xf')](function(_0x2a2b0f){logger[_0x7b23('0x10')](_0x7b23('0x24'),_0x258dc1);logger['debug'](_0x7b23('0x24'),_0x258dc1,JSON[_0x7b23('0x15')](_0x2a2b0f));_0x5767c3(_0x2a2b0f);})['catch'](function(_0x1d9523){logger[_0x7b23('0x17')]('ShowWhatsappAccount',_0x1d9523[_0x7b23('0x18')],_0x258dc1);_0x6a30d6(_0x55f840[_0x7b23('0x17')](0x1f4,_0x1d9523['message']));});});};