eaa5fad2002a10125c58987002557254fe3f8b68
[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 _0xf783=['./whatsappMessage.socket','register','request','then','info','request\x20sent','debug','error','WhatsappMessage,\x20%s,\x20%s','message','result','options','raw','CreateWhatsappMessage','stringify','catch','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','redis','defaults','localhost','socket.io-emitter'];(function(_0x64aff8,_0x106082){var _0x5488a3=function(_0x36969c){while(--_0x36969c){_0x64aff8['push'](_0x64aff8['shift']());}};_0x5488a3(++_0x106082);}(_0xf783,0x1f0));var _0x3f78=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xf783[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0x3f78('0x0'));var util=require(_0x3f78('0x1'));var moment=require(_0x3f78('0x2'));var BPromise=require('bluebird');var rs=require(_0x3f78('0x3'));var fs=require('fs');var Redis=require(_0x3f78('0x4'));var db=require(_0x3f78('0x5'))['db'];var utils=require(_0x3f78('0x6'));var logger=require(_0x3f78('0x7'))(_0x3f78('0x8'));var config=require(_0x3f78('0x9'));var jayson=require(_0x3f78('0xa'));var client=jayson['client'][_0x3f78('0xb')]({'port':0x232a});config[_0x3f78('0xc')]=_[_0x3f78('0xd')](config[_0x3f78('0xc')],{'host':_0x3f78('0xe'),'port':0x18eb});var socket=require(_0x3f78('0xf'))(new Redis(config[_0x3f78('0xc')]));require(_0x3f78('0x10'))[_0x3f78('0x11')](socket);function respondWithRpcPromise(_0x14f0dd,_0x160560,_0x444df1){return new BPromise(function(_0x4206c3,_0x2f0e83){return client[_0x3f78('0x12')](_0x14f0dd,_0x444df1)[_0x3f78('0x13')](function(_0xdcd162){logger[_0x3f78('0x14')]('WhatsappMessage,\x20%s,\x20%s',_0x160560,_0x3f78('0x15'));logger[_0x3f78('0x16')]('WhatsappMessage,\x20%s,\x20%s,\x20%s',_0x160560,'request\x20sent',JSON['stringify'](_0xdcd162));if(_0xdcd162[_0x3f78('0x17')]){if(_0xdcd162[_0x3f78('0x17')]['code']===0x1f4){logger[_0x3f78('0x17')](_0x3f78('0x18'),_0x160560,_0xdcd162['error'][_0x3f78('0x19')]);return _0x2f0e83(_0xdcd162[_0x3f78('0x17')][_0x3f78('0x19')]);}logger[_0x3f78('0x17')](_0x3f78('0x18'),_0x160560,_0xdcd162[_0x3f78('0x17')][_0x3f78('0x19')]);return _0x4206c3(_0xdcd162[_0x3f78('0x17')][_0x3f78('0x19')]);}else{logger[_0x3f78('0x14')]('WhatsappMessage,\x20%s,\x20%s',_0x160560,'request\x20sent');_0x4206c3(_0xdcd162[_0x3f78('0x1a')][_0x3f78('0x19')]);}})['catch'](function(_0x123be2){logger[_0x3f78('0x17')]('WhatsappMessage,\x20%s,\x20%s',_0x160560,_0x123be2);_0x2f0e83(_0x123be2);});});}exports['CreateWhatsappMessage']=function(_0x57a57d){var _0x4db3dc=this;return new Promise(function(_0x162531,_0x26c637){return db['WhatsappMessage']['create'](_0x57a57d['body'],{'raw':_0x57a57d[_0x3f78('0x1b')]?_0x57a57d[_0x3f78('0x1b')][_0x3f78('0x1c')]===undefined?!![]:![]:!![]})[_0x3f78('0x13')](function(_0x2d1095){logger[_0x3f78('0x14')](_0x3f78('0x1d'),_0x57a57d);logger['debug']('CreateWhatsappMessage',_0x57a57d,JSON[_0x3f78('0x1e')](_0x2d1095));_0x162531(_0x2d1095);})[_0x3f78('0x1f')](function(_0x8347bf){logger[_0x3f78('0x17')](_0x3f78('0x1d'),_0x8347bf[_0x3f78('0x19')],_0x57a57d);_0x26c637(_0x4db3dc['error'](0x1f4,_0x8347bf[_0x3f78('0x19')]));});});};