bc10ef40fa9c1b18972615b6240776e33a0cb8d1
[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 _0x074c=['../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','defaults','redis','localhost','info','WhatsappAccount,\x20%s,\x20%s','debug','WhatsappAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','catch','ShowWhatsappAccount','WhatsappAccount','find','options','where','attributes','include','map','model','lodash','moment','bluebird','ioredis','../../mysqldb'];(function(_0xfae23b,_0x2be4ba){var _0x200640=function(_0x4ae258){while(--_0x4ae258){_0xfae23b['push'](_0xfae23b['shift']());}};_0x200640(++_0x2be4ba);}(_0x074c,0x1d7));var _0xc074=function(_0x2576d7,_0x167624){_0x2576d7=_0x2576d7-0x0;var _0x16a08c=_0x074c[_0x2576d7];return _0x16a08c;};'use strict';var _=require(_0xc074('0x0'));var util=require('util');var moment=require(_0xc074('0x1'));var BPromise=require(_0xc074('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xc074('0x3'));var db=require(_0xc074('0x4'))['db'];var utils=require(_0xc074('0x5'));var logger=require(_0xc074('0x6'))(_0xc074('0x7'));var config=require(_0xc074('0x8'));var jayson=require(_0xc074('0x9'));var client=jayson[_0xc074('0xa')][_0xc074('0xb')]({'port':0x232a});config['redis']=_[_0xc074('0xc')](config[_0xc074('0xd')],{'host':_0xc074('0xe'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require('./whatsappAccount.socket')['register'](socket);function respondWithRpcPromise(_0x2a9ee7,_0x5b74a4,_0x21e703){return new BPromise(function(_0x4b548c,_0x3f9208){return client['request'](_0x2a9ee7,_0x21e703)['then'](function(_0x3a1752){logger[_0xc074('0xf')](_0xc074('0x10'),_0x5b74a4,'request\x20sent');logger[_0xc074('0x11')](_0xc074('0x12'),_0x5b74a4,_0xc074('0x13'),JSON[_0xc074('0x14')](_0x3a1752));if(_0x3a1752[_0xc074('0x15')]){if(_0x3a1752[_0xc074('0x15')][_0xc074('0x16')]===0x1f4){logger['error'](_0xc074('0x10'),_0x5b74a4,_0x3a1752[_0xc074('0x15')]['message']);return _0x3f9208(_0x3a1752[_0xc074('0x15')]['message']);}logger[_0xc074('0x15')](_0xc074('0x10'),_0x5b74a4,_0x3a1752[_0xc074('0x15')][_0xc074('0x17')]);return _0x4b548c(_0x3a1752[_0xc074('0x15')][_0xc074('0x17')]);}else{logger[_0xc074('0xf')](_0xc074('0x10'),_0x5b74a4,'request\x20sent');_0x4b548c(_0x3a1752['result'][_0xc074('0x17')]);}})[_0xc074('0x18')](function(_0x36d0a6){logger[_0xc074('0x15')](_0xc074('0x10'),_0x5b74a4,_0x36d0a6);_0x3f9208(_0x36d0a6);});});}exports[_0xc074('0x19')]=function(_0x5c5847){var _0x2f6f1f=this;return new Promise(function(_0x4fba63,_0x7f3126){return db[_0xc074('0x1a')][_0xc074('0x1b')]({'raw':_0x5c5847['options']?_0x5c5847[_0xc074('0x1c')]['raw']===undefined?!![]:![]:!![],'where':_0x5c5847['options']?_0x5c5847['options'][_0xc074('0x1d')]||null:null,'attributes':_0x5c5847[_0xc074('0x1c')]?_0x5c5847[_0xc074('0x1c')][_0xc074('0x1e')]||null:null,'include':_0x5c5847[_0xc074('0x1c')]?_0x5c5847[_0xc074('0x1c')][_0xc074('0x1f')]?_[_0xc074('0x20')](_0x5c5847[_0xc074('0x1c')]['include'],function(_0x1bc2db){return{'model':db[_0x1bc2db[_0xc074('0x21')]],'as':_0x1bc2db['as'],'attributes':_0x1bc2db[_0xc074('0x1e')],'include':_0x1bc2db['include']?_[_0xc074('0x20')](_0x1bc2db[_0xc074('0x1f')],function(_0x2f4a72){return{'model':db[_0x2f4a72[_0xc074('0x21')]],'as':_0x2f4a72['as'],'attributes':_0x2f4a72[_0xc074('0x1e')],'include':_0x2f4a72[_0xc074('0x1f')]?_[_0xc074('0x20')](_0x2f4a72[_0xc074('0x1f')],function(_0x142226){return{'model':db[_0x142226['model']],'as':_0x142226['as'],'attributes':_0x142226[_0xc074('0x1e')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x3939fa){logger['info']('ShowWhatsappAccount',_0x5c5847);logger[_0xc074('0x11')](_0xc074('0x19'),_0x5c5847,JSON['stringify'](_0x3939fa));_0x4fba63(_0x3939fa);})[_0xc074('0x18')](function(_0x320abd){logger[_0xc074('0x15')](_0xc074('0x19'),_0x320abd[_0xc074('0x17')],_0x5c5847);_0x7f3126(_0x2f6f1f[_0xc074('0x15')](0x1f4,_0x320abd[_0xc074('0x17')]));});});};