Built motion from commit eddce310.|2.6.12
[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 _0x9deb=['util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','http','redis','socket.io-emitter','register','request','then','info','WhatsappAccount,\x20%s,\x20%s','request\x20sent','debug','WhatsappAccount,\x20%s,\x20%s,\x20%s','error','message','catch','WhatsappAccount','options','raw','where','attributes','include','model','ShowWhatsappAccount','lodash'];(function(_0x1b6186,_0x1ec7f2){var _0x186121=function(_0x1748a8){while(--_0x1748a8){_0x1b6186['push'](_0x1b6186['shift']());}};_0x186121(++_0x1ec7f2);}(_0x9deb,0xdf));var _0xb9de=function(_0x441fac,_0x3b7fd5){_0x441fac=_0x441fac-0x0;var _0x14b12e=_0x9deb[_0x441fac];return _0x14b12e;};'use strict';var _=require(_0xb9de('0x0'));var util=require(_0xb9de('0x1'));var moment=require(_0xb9de('0x2'));var BPromise=require('bluebird');var rs=require(_0xb9de('0x3'));var fs=require('fs');var Redis=require(_0xb9de('0x4'));var db=require(_0xb9de('0x5'))['db'];var utils=require(_0xb9de('0x6'));var logger=require(_0xb9de('0x7'))('rpc');var config=require(_0xb9de('0x8'));var jayson=require(_0xb9de('0x9'));var client=jayson['client'][_0xb9de('0xa')]({'port':0x232a});config[_0xb9de('0xb')]=_['defaults'](config[_0xb9de('0xb')],{'host':'localhost','port':0x18eb});var socket=require(_0xb9de('0xc'))(new Redis(config[_0xb9de('0xb')]));require('./whatsappAccount.socket')[_0xb9de('0xd')](socket);function respondWithRpcPromise(_0x1c9029,_0x443c39,_0x3ce511){return new BPromise(function(_0x1f2015,_0x391548){return client[_0xb9de('0xe')](_0x1c9029,_0x3ce511)[_0xb9de('0xf')](function(_0x2ca65d){logger[_0xb9de('0x10')](_0xb9de('0x11'),_0x443c39,_0xb9de('0x12'));logger[_0xb9de('0x13')](_0xb9de('0x14'),_0x443c39,'request\x20sent',JSON['stringify'](_0x2ca65d));if(_0x2ca65d[_0xb9de('0x15')]){if(_0x2ca65d[_0xb9de('0x15')]['code']===0x1f4){logger[_0xb9de('0x15')]('WhatsappAccount,\x20%s,\x20%s',_0x443c39,_0x2ca65d['error'][_0xb9de('0x16')]);return _0x391548(_0x2ca65d['error'][_0xb9de('0x16')]);}logger[_0xb9de('0x15')](_0xb9de('0x11'),_0x443c39,_0x2ca65d[_0xb9de('0x15')]['message']);return _0x1f2015(_0x2ca65d[_0xb9de('0x15')]['message']);}else{logger['info'](_0xb9de('0x11'),_0x443c39,_0xb9de('0x12'));_0x1f2015(_0x2ca65d['result'][_0xb9de('0x16')]);}})[_0xb9de('0x17')](function(_0xea22f){logger[_0xb9de('0x15')](_0xb9de('0x11'),_0x443c39,_0xea22f);_0x391548(_0xea22f);});});}exports['ShowWhatsappAccount']=function(_0x596d74){var _0x23fa66=this;return new Promise(function(_0x4e8938,_0x5d8051){return db[_0xb9de('0x18')]['find']({'raw':_0x596d74[_0xb9de('0x19')]?_0x596d74[_0xb9de('0x19')][_0xb9de('0x1a')]===undefined?!![]:![]:!![],'where':_0x596d74['options']?_0x596d74[_0xb9de('0x19')][_0xb9de('0x1b')]||null:null,'attributes':_0x596d74[_0xb9de('0x19')]?_0x596d74[_0xb9de('0x19')][_0xb9de('0x1c')]||null:null,'include':_0x596d74['options']?_0x596d74[_0xb9de('0x19')][_0xb9de('0x1d')]?_['map'](_0x596d74['options'][_0xb9de('0x1d')],function(_0x5ec08){return{'model':db[_0x5ec08[_0xb9de('0x1e')]],'as':_0x5ec08['as'],'attributes':_0x5ec08[_0xb9de('0x1c')],'include':_0x5ec08[_0xb9de('0x1d')]?_['map'](_0x5ec08['include'],function(_0x59de8f){return{'model':db[_0x59de8f['model']],'as':_0x59de8f['as'],'attributes':_0x59de8f[_0xb9de('0x1c')],'include':_0x59de8f[_0xb9de('0x1d')]?_['map'](_0x59de8f['include'],function(_0x2ab0ae){return{'model':db[_0x2ab0ae[_0xb9de('0x1e')]],'as':_0x2ab0ae['as'],'attributes':_0x2ab0ae['attributes']};}):[]};}):[]};}):[]:[]})[_0xb9de('0xf')](function(_0x3787d1){logger[_0xb9de('0x10')]('ShowWhatsappAccount',_0x596d74);logger[_0xb9de('0x13')](_0xb9de('0x1f'),_0x596d74,JSON['stringify'](_0x3787d1));_0x4e8938(_0x3787d1);})['catch'](function(_0xcce7c2){logger[_0xb9de('0x15')](_0xb9de('0x1f'),_0xcce7c2[_0xb9de('0x16')],_0x596d74);_0x5d8051(_0x23fa66['error'](0x1f4,_0xcce7c2[_0xb9de('0x16')]));});});};