Built motion from commit 26159a51.|2.5.44
[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 _0xe6a1=['jayson/promise','redis','defaults','localhost','socket.io-emitter','./whatsappAccount.socket','register','info','WhatsappAccount,\x20%s,\x20%s','request\x20sent','debug','WhatsappAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','ShowWhatsappAccount','WhatsappAccount','find','options','raw','attributes','include','map','model','then','util','moment','randomstring','ioredis','../../mysqldb','rpc','../../config/environment'];(function(_0x3a7634,_0x2db384){var _0x23bbe9=function(_0x226734){while(--_0x226734){_0x3a7634['push'](_0x3a7634['shift']());}};_0x23bbe9(++_0x2db384);}(_0xe6a1,0x111));var _0x1e6a=function(_0x58e055,_0x2a5f75){_0x58e055=_0x58e055-0x0;var _0xf1661=_0xe6a1[_0x58e055];return _0xf1661;};'use strict';var _=require('lodash');var util=require(_0x1e6a('0x0'));var moment=require(_0x1e6a('0x1'));var BPromise=require('bluebird');var rs=require(_0x1e6a('0x2'));var fs=require('fs');var Redis=require(_0x1e6a('0x3'));var db=require(_0x1e6a('0x4'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x1e6a('0x5'));var config=require(_0x1e6a('0x6'));var jayson=require(_0x1e6a('0x7'));var client=jayson['client']['http']({'port':0x232a});config[_0x1e6a('0x8')]=_[_0x1e6a('0x9')](config[_0x1e6a('0x8')],{'host':_0x1e6a('0xa'),'port':0x18eb});var socket=require(_0x1e6a('0xb'))(new Redis(config[_0x1e6a('0x8')]));require(_0x1e6a('0xc'))[_0x1e6a('0xd')](socket);function respondWithRpcPromise(_0xef37f5,_0x238a4a,_0x3cee37){return new BPromise(function(_0x24db27,_0xa28f89){return client['request'](_0xef37f5,_0x3cee37)['then'](function(_0xd38eaa){logger[_0x1e6a('0xe')](_0x1e6a('0xf'),_0x238a4a,_0x1e6a('0x10'));logger[_0x1e6a('0x11')](_0x1e6a('0x12'),_0x238a4a,_0x1e6a('0x10'),JSON[_0x1e6a('0x13')](_0xd38eaa));if(_0xd38eaa[_0x1e6a('0x14')]){if(_0xd38eaa['error'][_0x1e6a('0x15')]===0x1f4){logger[_0x1e6a('0x14')](_0x1e6a('0xf'),_0x238a4a,_0xd38eaa[_0x1e6a('0x14')][_0x1e6a('0x16')]);return _0xa28f89(_0xd38eaa[_0x1e6a('0x14')][_0x1e6a('0x16')]);}logger[_0x1e6a('0x14')](_0x1e6a('0xf'),_0x238a4a,_0xd38eaa[_0x1e6a('0x14')]['message']);return _0x24db27(_0xd38eaa[_0x1e6a('0x14')]['message']);}else{logger[_0x1e6a('0xe')]('WhatsappAccount,\x20%s,\x20%s',_0x238a4a,'request\x20sent');_0x24db27(_0xd38eaa[_0x1e6a('0x17')]['message']);}})[_0x1e6a('0x18')](function(_0x257d80){logger[_0x1e6a('0x14')](_0x1e6a('0xf'),_0x238a4a,_0x257d80);_0xa28f89(_0x257d80);});});}exports[_0x1e6a('0x19')]=function(_0x1d6a34){var _0x39f64b=this;return new Promise(function(_0x2dec19,_0x1b871d){return db[_0x1e6a('0x1a')][_0x1e6a('0x1b')]({'raw':_0x1d6a34[_0x1e6a('0x1c')]?_0x1d6a34[_0x1e6a('0x1c')][_0x1e6a('0x1d')]===undefined?!![]:![]:!![],'where':_0x1d6a34['options']?_0x1d6a34['options']['where']||null:null,'attributes':_0x1d6a34[_0x1e6a('0x1c')]?_0x1d6a34[_0x1e6a('0x1c')][_0x1e6a('0x1e')]||null:null,'include':_0x1d6a34[_0x1e6a('0x1c')]?_0x1d6a34[_0x1e6a('0x1c')][_0x1e6a('0x1f')]?_[_0x1e6a('0x20')](_0x1d6a34['options'][_0x1e6a('0x1f')],function(_0x891097){return{'model':db[_0x891097[_0x1e6a('0x21')]],'as':_0x891097['as'],'attributes':_0x891097['attributes'],'include':_0x891097['include']?_[_0x1e6a('0x20')](_0x891097[_0x1e6a('0x1f')],function(_0x9f944e){return{'model':db[_0x9f944e[_0x1e6a('0x21')]],'as':_0x9f944e['as'],'attributes':_0x9f944e['attributes'],'include':_0x9f944e[_0x1e6a('0x1f')]?_[_0x1e6a('0x20')](_0x9f944e[_0x1e6a('0x1f')],function(_0x19b155){return{'model':db[_0x19b155[_0x1e6a('0x21')]],'as':_0x19b155['as'],'attributes':_0x19b155[_0x1e6a('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x1e6a('0x22')](function(_0xc5fe0e){logger['info']('ShowWhatsappAccount',_0x1d6a34);logger[_0x1e6a('0x11')](_0x1e6a('0x19'),_0x1d6a34,JSON['stringify'](_0xc5fe0e));_0x2dec19(_0xc5fe0e);})[_0x1e6a('0x18')](function(_0x200a3c){logger['error']('ShowWhatsappAccount',_0x200a3c[_0x1e6a('0x16')],_0x1d6a34);_0x1b871d(_0x39f64b['error'](0x1f4,_0x200a3c[_0x1e6a('0x16')]));});});};