85bab4782206f0bb00ebed8318339ebb4e05f522
[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 _0xfc4c=['defaults','localhost','./whatsappMessage.socket','register','request','then','info','WhatsappMessage,\x20%s,\x20%s','request\x20sent','WhatsappMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','CreateWhatsappMessage','WhatsappMessage','create','body','options','debug','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','redis'];(function(_0x1cd47d,_0x55bc75){var _0x29d52f=function(_0x37737a){while(--_0x37737a){_0x1cd47d['push'](_0x1cd47d['shift']());}};_0x29d52f(++_0x55bc75);}(_0xfc4c,0x151));var _0xcfc4=function(_0xc5fc35,_0x4ccb1d){_0xc5fc35=_0xc5fc35-0x0;var _0xdea0a4=_0xfc4c[_0xc5fc35];return _0xdea0a4;};'use strict';var _=require(_0xcfc4('0x0'));var util=require(_0xcfc4('0x1'));var moment=require(_0xcfc4('0x2'));var BPromise=require(_0xcfc4('0x3'));var rs=require(_0xcfc4('0x4'));var fs=require('fs');var Redis=require(_0xcfc4('0x5'));var db=require(_0xcfc4('0x6'))['db'];var utils=require(_0xcfc4('0x7'));var logger=require(_0xcfc4('0x8'))('rpc');var config=require(_0xcfc4('0x9'));var jayson=require(_0xcfc4('0xa'));var client=jayson[_0xcfc4('0xb')]['http']({'port':0x232a});config[_0xcfc4('0xc')]=_[_0xcfc4('0xd')](config['redis'],{'host':_0xcfc4('0xe'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xcfc4('0xc')]));require(_0xcfc4('0xf'))[_0xcfc4('0x10')](socket);function respondWithRpcPromise(_0x41921e,_0x4b39f1,_0x17384a){return new BPromise(function(_0x5789ce,_0x98c25e){return client[_0xcfc4('0x11')](_0x41921e,_0x17384a)[_0xcfc4('0x12')](function(_0x82e8a4){logger[_0xcfc4('0x13')](_0xcfc4('0x14'),_0x4b39f1,_0xcfc4('0x15'));logger['debug'](_0xcfc4('0x16'),_0x4b39f1,_0xcfc4('0x15'),JSON[_0xcfc4('0x17')](_0x82e8a4));if(_0x82e8a4[_0xcfc4('0x18')]){if(_0x82e8a4[_0xcfc4('0x18')][_0xcfc4('0x19')]===0x1f4){logger[_0xcfc4('0x18')](_0xcfc4('0x14'),_0x4b39f1,_0x82e8a4[_0xcfc4('0x18')][_0xcfc4('0x1a')]);return _0x98c25e(_0x82e8a4[_0xcfc4('0x18')][_0xcfc4('0x1a')]);}logger[_0xcfc4('0x18')](_0xcfc4('0x14'),_0x4b39f1,_0x82e8a4[_0xcfc4('0x18')][_0xcfc4('0x1a')]);return _0x5789ce(_0x82e8a4[_0xcfc4('0x18')][_0xcfc4('0x1a')]);}else{logger[_0xcfc4('0x13')](_0xcfc4('0x14'),_0x4b39f1,'request\x20sent');_0x5789ce(_0x82e8a4[_0xcfc4('0x1b')][_0xcfc4('0x1a')]);}})[_0xcfc4('0x1c')](function(_0x4b906d){logger[_0xcfc4('0x18')](_0xcfc4('0x14'),_0x4b39f1,_0x4b906d);_0x98c25e(_0x4b906d);});});}exports[_0xcfc4('0x1d')]=function(_0x2cd3e0){var _0x3a290d=this;return new Promise(function(_0x29ba60,_0x1afab5){return db[_0xcfc4('0x1e')][_0xcfc4('0x1f')](_0x2cd3e0[_0xcfc4('0x20')],{'raw':_0x2cd3e0[_0xcfc4('0x21')]?_0x2cd3e0['options']['raw']===undefined?!![]:![]:!![]})[_0xcfc4('0x12')](function(_0x446ae0){logger[_0xcfc4('0x13')](_0xcfc4('0x1d'),_0x2cd3e0);logger[_0xcfc4('0x22')](_0xcfc4('0x1d'),_0x2cd3e0,JSON[_0xcfc4('0x17')](_0x446ae0));_0x29ba60(_0x446ae0);})[_0xcfc4('0x1c')](function(_0x104539){logger[_0xcfc4('0x18')]('CreateWhatsappMessage',_0x104539[_0xcfc4('0x1a')],_0x2cd3e0);_0x1afab5(_0x3a290d[_0xcfc4('0x18')](0x1f4,_0x104539[_0xcfc4('0x1a')]));});});};