Built motion from commit ddca4d0d.|2.5.47
[motion2.git] / server / api / whatsappMessage / whatsappMessage.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 _0x65a0=['redis','defaults','localhost','./whatsappMessage.socket','register','request','then','info','debug','WhatsappMessage,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','WhatsappMessage,\x20%s,\x20%s','result','CreateWhatsappMessage','WhatsappMessage','create','body','options','raw','stringify','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/environment','jayson/promise','client','http'];(function(_0x163742,_0x467e36){var _0x1152ac=function(_0x40a83d){while(--_0x40a83d){_0x163742['push'](_0x163742['shift']());}};_0x1152ac(++_0x467e36);}(_0x65a0,0x1c8));var _0x065a=function(_0x4cb1ca,_0x34610f){_0x4cb1ca=_0x4cb1ca-0x0;var _0x55e988=_0x65a0[_0x4cb1ca];return _0x55e988;};'use strict';var _=require(_0x065a('0x0'));var util=require(_0x065a('0x1'));var moment=require(_0x065a('0x2'));var BPromise=require(_0x065a('0x3'));var rs=require(_0x065a('0x4'));var fs=require('fs');var Redis=require(_0x065a('0x5'));var db=require(_0x065a('0x6'))['db'];var utils=require(_0x065a('0x7'));var logger=require('../../config/logger')('rpc');var config=require(_0x065a('0x8'));var jayson=require(_0x065a('0x9'));var client=jayson[_0x065a('0xa')][_0x065a('0xb')]({'port':0x232a});config[_0x065a('0xc')]=_[_0x065a('0xd')](config['redis'],{'host':_0x065a('0xe'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x065a('0xc')]));require(_0x065a('0xf'))[_0x065a('0x10')](socket);function respondWithRpcPromise(_0x4ed0c9,_0x3106b8,_0x5e03eb){return new BPromise(function(_0x55e9bf,_0x48621f){return client[_0x065a('0x11')](_0x4ed0c9,_0x5e03eb)[_0x065a('0x12')](function(_0x3e6c4b){logger[_0x065a('0x13')]('WhatsappMessage,\x20%s,\x20%s',_0x3106b8,'request\x20sent');logger[_0x065a('0x14')](_0x065a('0x15'),_0x3106b8,_0x065a('0x16'),JSON['stringify'](_0x3e6c4b));if(_0x3e6c4b['error']){if(_0x3e6c4b[_0x065a('0x17')][_0x065a('0x18')]===0x1f4){logger[_0x065a('0x17')]('WhatsappMessage,\x20%s,\x20%s',_0x3106b8,_0x3e6c4b['error'][_0x065a('0x19')]);return _0x48621f(_0x3e6c4b[_0x065a('0x17')][_0x065a('0x19')]);}logger[_0x065a('0x17')](_0x065a('0x1a'),_0x3106b8,_0x3e6c4b[_0x065a('0x17')]['message']);return _0x55e9bf(_0x3e6c4b[_0x065a('0x17')][_0x065a('0x19')]);}else{logger['info']('WhatsappMessage,\x20%s,\x20%s',_0x3106b8,'request\x20sent');_0x55e9bf(_0x3e6c4b[_0x065a('0x1b')][_0x065a('0x19')]);}})['catch'](function(_0x508b22){logger[_0x065a('0x17')](_0x065a('0x1a'),_0x3106b8,_0x508b22);_0x48621f(_0x508b22);});});}exports[_0x065a('0x1c')]=function(_0x5698c9){var _0x2ef939=this;return new Promise(function(_0x5209c1,_0x3a54de){return db[_0x065a('0x1d')][_0x065a('0x1e')](_0x5698c9[_0x065a('0x1f')],{'raw':_0x5698c9[_0x065a('0x20')]?_0x5698c9[_0x065a('0x20')][_0x065a('0x21')]===undefined?!![]:![]:!![]})[_0x065a('0x12')](function(_0x64e482){logger[_0x065a('0x13')](_0x065a('0x1c'),_0x5698c9);logger[_0x065a('0x14')](_0x065a('0x1c'),_0x5698c9,JSON[_0x065a('0x22')](_0x64e482));_0x5209c1(_0x64e482);})[_0x065a('0x23')](function(_0x4e033a){logger[_0x065a('0x17')]('CreateWhatsappMessage',_0x4e033a[_0x065a('0x19')],_0x5698c9);_0x3a54de(_0x2ef939[_0x065a('0x17')](0x1f4,_0x4e033a[_0x065a('0x19')]));});});};