3253b1a148ec2bd5d665bf591d306959188cb4f2
[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 _0xd23a=['WhatsappAccount','find','options','where','attributes','include','map','model','ShowWhatsappAccount','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','jayson/promise','client','http','redis','localhost','./whatsappAccount.socket','register','request','then','info','WhatsappAccount,\x20%s,\x20%s','request\x20sent','debug','WhatsappAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch'];(function(_0x21eb60,_0x335cc4){var _0x32c61b=function(_0xcb8644){while(--_0xcb8644){_0x21eb60['push'](_0x21eb60['shift']());}};_0x32c61b(++_0x335cc4);}(_0xd23a,0xe7));var _0xad23=function(_0x47e639,_0x15659){_0x47e639=_0x47e639-0x0;var _0x416d6d=_0xd23a[_0x47e639];return _0x416d6d;};'use strict';var _=require(_0xad23('0x0'));var util=require('util');var moment=require(_0xad23('0x1'));var BPromise=require(_0xad23('0x2'));var rs=require(_0xad23('0x3'));var fs=require('fs');var Redis=require(_0xad23('0x4'));var db=require(_0xad23('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xad23('0x6'))(_0xad23('0x7'));var config=require('../../config/environment');var jayson=require(_0xad23('0x8'));var client=jayson[_0xad23('0x9')][_0xad23('0xa')]({'port':0x232a});config[_0xad23('0xb')]=_['defaults'](config[_0xad23('0xb')],{'host':_0xad23('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xad23('0xb')]));require(_0xad23('0xd'))[_0xad23('0xe')](socket);function respondWithRpcPromise(_0xd2e238,_0x5ce941,_0x5c66aa){return new BPromise(function(_0x3f3954,_0x25a158){return client[_0xad23('0xf')](_0xd2e238,_0x5c66aa)[_0xad23('0x10')](function(_0x5c35b5){logger[_0xad23('0x11')](_0xad23('0x12'),_0x5ce941,_0xad23('0x13'));logger[_0xad23('0x14')](_0xad23('0x15'),_0x5ce941,_0xad23('0x13'),JSON[_0xad23('0x16')](_0x5c35b5));if(_0x5c35b5[_0xad23('0x17')]){if(_0x5c35b5[_0xad23('0x17')][_0xad23('0x18')]===0x1f4){logger[_0xad23('0x17')]('WhatsappAccount,\x20%s,\x20%s',_0x5ce941,_0x5c35b5[_0xad23('0x17')][_0xad23('0x19')]);return _0x25a158(_0x5c35b5[_0xad23('0x17')][_0xad23('0x19')]);}logger[_0xad23('0x17')](_0xad23('0x12'),_0x5ce941,_0x5c35b5[_0xad23('0x17')][_0xad23('0x19')]);return _0x3f3954(_0x5c35b5[_0xad23('0x17')][_0xad23('0x19')]);}else{logger['info'](_0xad23('0x12'),_0x5ce941,_0xad23('0x13'));_0x3f3954(_0x5c35b5[_0xad23('0x1a')][_0xad23('0x19')]);}})[_0xad23('0x1b')](function(_0x1f1972){logger[_0xad23('0x17')]('WhatsappAccount,\x20%s,\x20%s',_0x5ce941,_0x1f1972);_0x25a158(_0x1f1972);});});}exports['ShowWhatsappAccount']=function(_0x444426){var _0x5e3119=this;return new Promise(function(_0x15eb54,_0x5d49f2){return db[_0xad23('0x1c')][_0xad23('0x1d')]({'raw':_0x444426[_0xad23('0x1e')]?_0x444426[_0xad23('0x1e')]['raw']===undefined?!![]:![]:!![],'where':_0x444426[_0xad23('0x1e')]?_0x444426['options'][_0xad23('0x1f')]||null:null,'attributes':_0x444426[_0xad23('0x1e')]?_0x444426[_0xad23('0x1e')][_0xad23('0x20')]||null:null,'include':_0x444426[_0xad23('0x1e')]?_0x444426['options'][_0xad23('0x21')]?_[_0xad23('0x22')](_0x444426[_0xad23('0x1e')][_0xad23('0x21')],function(_0x3f8f85){return{'model':db[_0x3f8f85[_0xad23('0x23')]],'as':_0x3f8f85['as'],'attributes':_0x3f8f85[_0xad23('0x20')],'include':_0x3f8f85[_0xad23('0x21')]?_['map'](_0x3f8f85['include'],function(_0x304b14){return{'model':db[_0x304b14[_0xad23('0x23')]],'as':_0x304b14['as'],'attributes':_0x304b14[_0xad23('0x20')],'include':_0x304b14['include']?_[_0xad23('0x22')](_0x304b14['include'],function(_0x4982cf){return{'model':db[_0x4982cf['model']],'as':_0x4982cf['as'],'attributes':_0x4982cf[_0xad23('0x20')]};}):[]};}):[]};}):[]:[]})[_0xad23('0x10')](function(_0x4f32c8){logger[_0xad23('0x11')](_0xad23('0x24'),_0x444426);logger[_0xad23('0x14')](_0xad23('0x24'),_0x444426,JSON[_0xad23('0x16')](_0x4f32c8));_0x15eb54(_0x4f32c8);})[_0xad23('0x1b')](function(_0x285676){logger[_0xad23('0x17')](_0xad23('0x24'),_0x285676[_0xad23('0x19')],_0x444426);_0x5d49f2(_0x5e3119[_0xad23('0x17')](0x1f4,_0x285676[_0xad23('0x19')]));});});};