Built motion from commit 85328c08.|2.5.50
[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 _0xeb94=['bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./whatsappAccount.socket','register','info','WhatsappAccount,\x20%s,\x20%s','debug','stringify','error','code','message','result','catch','ShowWhatsappAccount','WhatsappAccount','find','options','where','attributes','map','include','model','util','moment'];(function(_0x31b435,_0x23fbe2){var _0x326305=function(_0x4b0961){while(--_0x4b0961){_0x31b435['push'](_0x31b435['shift']());}};_0x326305(++_0x23fbe2);}(_0xeb94,0x1d2));var _0x4eb9=function(_0xa69733,_0x2aa122){_0xa69733=_0xa69733-0x0;var _0xca5645=_0xeb94[_0xa69733];return _0xca5645;};'use strict';var _=require('lodash');var util=require(_0x4eb9('0x0'));var moment=require(_0x4eb9('0x1'));var BPromise=require(_0x4eb9('0x2'));var rs=require(_0x4eb9('0x3'));var fs=require('fs');var Redis=require(_0x4eb9('0x4'));var db=require(_0x4eb9('0x5'))['db'];var utils=require(_0x4eb9('0x6'));var logger=require('../../config/logger')(_0x4eb9('0x7'));var config=require(_0x4eb9('0x8'));var jayson=require(_0x4eb9('0x9'));var client=jayson[_0x4eb9('0xa')][_0x4eb9('0xb')]({'port':0x232a});config[_0x4eb9('0xc')]=_[_0x4eb9('0xd')](config[_0x4eb9('0xc')],{'host':_0x4eb9('0xe'),'port':0x18eb});var socket=require(_0x4eb9('0xf'))(new Redis(config[_0x4eb9('0xc')]));require(_0x4eb9('0x10'))[_0x4eb9('0x11')](socket);function respondWithRpcPromise(_0x239fbb,_0x595ffb,_0x57eda4){return new BPromise(function(_0x467515,_0x246b34){return client['request'](_0x239fbb,_0x57eda4)['then'](function(_0xb6a808){logger[_0x4eb9('0x12')](_0x4eb9('0x13'),_0x595ffb,'request\x20sent');logger[_0x4eb9('0x14')]('WhatsappAccount,\x20%s,\x20%s,\x20%s',_0x595ffb,'request\x20sent',JSON[_0x4eb9('0x15')](_0xb6a808));if(_0xb6a808['error']){if(_0xb6a808[_0x4eb9('0x16')][_0x4eb9('0x17')]===0x1f4){logger[_0x4eb9('0x16')](_0x4eb9('0x13'),_0x595ffb,_0xb6a808[_0x4eb9('0x16')][_0x4eb9('0x18')]);return _0x246b34(_0xb6a808['error'][_0x4eb9('0x18')]);}logger[_0x4eb9('0x16')](_0x4eb9('0x13'),_0x595ffb,_0xb6a808[_0x4eb9('0x16')][_0x4eb9('0x18')]);return _0x467515(_0xb6a808[_0x4eb9('0x16')][_0x4eb9('0x18')]);}else{logger[_0x4eb9('0x12')](_0x4eb9('0x13'),_0x595ffb,'request\x20sent');_0x467515(_0xb6a808[_0x4eb9('0x19')][_0x4eb9('0x18')]);}})[_0x4eb9('0x1a')](function(_0x42f4e0){logger['error']('WhatsappAccount,\x20%s,\x20%s',_0x595ffb,_0x42f4e0);_0x246b34(_0x42f4e0);});});}exports[_0x4eb9('0x1b')]=function(_0x1b41d7){var _0x31e07c=this;return new Promise(function(_0x443679,_0x13631d){return db[_0x4eb9('0x1c')][_0x4eb9('0x1d')]({'raw':_0x1b41d7[_0x4eb9('0x1e')]?_0x1b41d7[_0x4eb9('0x1e')]['raw']===undefined?!![]:![]:!![],'where':_0x1b41d7[_0x4eb9('0x1e')]?_0x1b41d7[_0x4eb9('0x1e')][_0x4eb9('0x1f')]||null:null,'attributes':_0x1b41d7['options']?_0x1b41d7[_0x4eb9('0x1e')][_0x4eb9('0x20')]||null:null,'include':_0x1b41d7[_0x4eb9('0x1e')]?_0x1b41d7[_0x4eb9('0x1e')]['include']?_[_0x4eb9('0x21')](_0x1b41d7[_0x4eb9('0x1e')][_0x4eb9('0x22')],function(_0xbf7a9e){return{'model':db[_0xbf7a9e[_0x4eb9('0x23')]],'as':_0xbf7a9e['as'],'attributes':_0xbf7a9e[_0x4eb9('0x20')],'include':_0xbf7a9e[_0x4eb9('0x22')]?_[_0x4eb9('0x21')](_0xbf7a9e[_0x4eb9('0x22')],function(_0x325b2f){return{'model':db[_0x325b2f[_0x4eb9('0x23')]],'as':_0x325b2f['as'],'attributes':_0x325b2f[_0x4eb9('0x20')],'include':_0x325b2f['include']?_[_0x4eb9('0x21')](_0x325b2f[_0x4eb9('0x22')],function(_0x4222d1){return{'model':db[_0x4222d1[_0x4eb9('0x23')]],'as':_0x4222d1['as'],'attributes':_0x4222d1['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x1c1c1c){logger[_0x4eb9('0x12')]('ShowWhatsappAccount',_0x1b41d7);logger[_0x4eb9('0x14')](_0x4eb9('0x1b'),_0x1b41d7,JSON[_0x4eb9('0x15')](_0x1c1c1c));_0x443679(_0x1c1c1c);})[_0x4eb9('0x1a')](function(_0x5039f1){logger[_0x4eb9('0x16')](_0x4eb9('0x1b'),_0x5039f1[_0x4eb9('0x18')],_0x1b41d7);_0x13631d(_0x31e07c['error'](0x1f4,_0x5039f1['message']));});});};