ac7c67064e3a5e2ab82d50d28209fe18f1b4dc3e
[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 _0x0efe=['util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','defaults','redis','localhost','socket.io-emitter','./whatsappAccount.socket','register','then','WhatsappAccount,\x20%s,\x20%s','debug','WhatsappAccount,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','result','catch','ShowWhatsappAccount','find','options','raw','where','attributes','map','model','include','info','stringify','lodash'];(function(_0xa90718,_0x2fd952){var _0x56ed79=function(_0x41cff1){while(--_0x41cff1){_0xa90718['push'](_0xa90718['shift']());}};_0x56ed79(++_0x2fd952);}(_0x0efe,0x110));var _0xe0ef=function(_0xc73028,_0x1e49e6){_0xc73028=_0xc73028-0x0;var _0x3f198a=_0x0efe[_0xc73028];return _0x3f198a;};'use strict';var _=require(_0xe0ef('0x0'));var util=require(_0xe0ef('0x1'));var moment=require('moment');var BPromise=require(_0xe0ef('0x2'));var rs=require(_0xe0ef('0x3'));var fs=require('fs');var Redis=require(_0xe0ef('0x4'));var db=require(_0xe0ef('0x5'))['db'];var utils=require(_0xe0ef('0x6'));var logger=require(_0xe0ef('0x7'))(_0xe0ef('0x8'));var config=require(_0xe0ef('0x9'));var jayson=require(_0xe0ef('0xa'));var client=jayson[_0xe0ef('0xb')]['http']({'port':0x232a});config['redis']=_[_0xe0ef('0xc')](config[_0xe0ef('0xd')],{'host':_0xe0ef('0xe'),'port':0x18eb});var socket=require(_0xe0ef('0xf'))(new Redis(config[_0xe0ef('0xd')]));require(_0xe0ef('0x10'))[_0xe0ef('0x11')](socket);function respondWithRpcPromise(_0x4ec5dd,_0x538d1f,_0x12e93a){return new BPromise(function(_0x62fd61,_0x1e000c){return client['request'](_0x4ec5dd,_0x12e93a)[_0xe0ef('0x12')](function(_0x14569f){logger['info'](_0xe0ef('0x13'),_0x538d1f,'request\x20sent');logger[_0xe0ef('0x14')](_0xe0ef('0x15'),_0x538d1f,_0xe0ef('0x16'),JSON['stringify'](_0x14569f));if(_0x14569f['error']){if(_0x14569f[_0xe0ef('0x17')][_0xe0ef('0x18')]===0x1f4){logger[_0xe0ef('0x17')](_0xe0ef('0x13'),_0x538d1f,_0x14569f[_0xe0ef('0x17')][_0xe0ef('0x19')]);return _0x1e000c(_0x14569f[_0xe0ef('0x17')][_0xe0ef('0x19')]);}logger['error'](_0xe0ef('0x13'),_0x538d1f,_0x14569f[_0xe0ef('0x17')][_0xe0ef('0x19')]);return _0x62fd61(_0x14569f[_0xe0ef('0x17')][_0xe0ef('0x19')]);}else{logger['info'](_0xe0ef('0x13'),_0x538d1f,_0xe0ef('0x16'));_0x62fd61(_0x14569f[_0xe0ef('0x1a')][_0xe0ef('0x19')]);}})[_0xe0ef('0x1b')](function(_0x214c7f){logger[_0xe0ef('0x17')](_0xe0ef('0x13'),_0x538d1f,_0x214c7f);_0x1e000c(_0x214c7f);});});}exports[_0xe0ef('0x1c')]=function(_0x270f57){var _0xae50eb=this;return new Promise(function(_0x1e0dd8,_0x450321){return db['WhatsappAccount'][_0xe0ef('0x1d')]({'raw':_0x270f57[_0xe0ef('0x1e')]?_0x270f57[_0xe0ef('0x1e')][_0xe0ef('0x1f')]===undefined?!![]:![]:!![],'where':_0x270f57['options']?_0x270f57[_0xe0ef('0x1e')][_0xe0ef('0x20')]||null:null,'attributes':_0x270f57[_0xe0ef('0x1e')]?_0x270f57[_0xe0ef('0x1e')][_0xe0ef('0x21')]||null:null,'include':_0x270f57[_0xe0ef('0x1e')]?_0x270f57[_0xe0ef('0x1e')]['include']?_[_0xe0ef('0x22')](_0x270f57[_0xe0ef('0x1e')]['include'],function(_0x1d4ae8){return{'model':db[_0x1d4ae8[_0xe0ef('0x23')]],'as':_0x1d4ae8['as'],'attributes':_0x1d4ae8['attributes'],'include':_0x1d4ae8['include']?_['map'](_0x1d4ae8[_0xe0ef('0x24')],function(_0x4ee2c1){return{'model':db[_0x4ee2c1[_0xe0ef('0x23')]],'as':_0x4ee2c1['as'],'attributes':_0x4ee2c1[_0xe0ef('0x21')],'include':_0x4ee2c1[_0xe0ef('0x24')]?_['map'](_0x4ee2c1['include'],function(_0x52779c){return{'model':db[_0x52779c[_0xe0ef('0x23')]],'as':_0x52779c['as'],'attributes':_0x52779c[_0xe0ef('0x21')]};}):[]};}):[]};}):[]:[]})[_0xe0ef('0x12')](function(_0x31e576){logger[_0xe0ef('0x25')](_0xe0ef('0x1c'),_0x270f57);logger['debug']('ShowWhatsappAccount',_0x270f57,JSON[_0xe0ef('0x26')](_0x31e576));_0x1e0dd8(_0x31e576);})['catch'](function(_0x2bb21f){logger[_0xe0ef('0x17')]('ShowWhatsappAccount',_0x2bb21f['message'],_0x270f57);_0x450321(_0xae50eb[_0xe0ef('0x17')](0x1f4,_0x2bb21f[_0xe0ef('0x19')]));});});};