Built motion from commit (unavailable).|2.5.12
[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 _0xbc70=['WhatsappMessage','create','options','raw','then','debug','stringify','catch','lodash','util','randomstring','ioredis','../../mysqldb','../../config/utils','jayson/promise','redis','defaults','localhost','./whatsappMessage.socket','register','info','request\x20sent','error','code','WhatsappMessage,\x20%s,\x20%s','message','result','CreateWhatsappMessage'];(function(_0x2d85f9,_0x1add32){var _0x2e0f3f=function(_0x58102d){while(--_0x58102d){_0x2d85f9['push'](_0x2d85f9['shift']());}};_0x2e0f3f(++_0x1add32);}(_0xbc70,0x104));var _0x0bc7=function(_0x7ea384,_0x357dce){_0x7ea384=_0x7ea384-0x0;var _0x370966=_0xbc70[_0x7ea384];return _0x370966;};'use strict';var _=require(_0x0bc7('0x0'));var util=require(_0x0bc7('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x0bc7('0x2'));var fs=require('fs');var Redis=require(_0x0bc7('0x3'));var db=require(_0x0bc7('0x4'))['db'];var utils=require(_0x0bc7('0x5'));var logger=require('../../config/logger')('rpc');var config=require('../../config/environment');var jayson=require(_0x0bc7('0x6'));var client=jayson['client']['http']({'port':0x232a});config[_0x0bc7('0x7')]=_[_0x0bc7('0x8')](config[_0x0bc7('0x7')],{'host':_0x0bc7('0x9'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x0bc7('0x7')]));require(_0x0bc7('0xa'))[_0x0bc7('0xb')](socket);function respondWithRpcPromise(_0x3f678b,_0x3c31ed,_0x1b7433){return new BPromise(function(_0x16575b,_0x1d7018){return client['request'](_0x3f678b,_0x1b7433)['then'](function(_0x3394fd){logger[_0x0bc7('0xc')]('WhatsappMessage,\x20%s,\x20%s',_0x3c31ed,_0x0bc7('0xd'));logger['debug']('WhatsappMessage,\x20%s,\x20%s,\x20%s',_0x3c31ed,_0x0bc7('0xd'),JSON['stringify'](_0x3394fd));if(_0x3394fd[_0x0bc7('0xe')]){if(_0x3394fd[_0x0bc7('0xe')][_0x0bc7('0xf')]===0x1f4){logger[_0x0bc7('0xe')](_0x0bc7('0x10'),_0x3c31ed,_0x3394fd[_0x0bc7('0xe')][_0x0bc7('0x11')]);return _0x1d7018(_0x3394fd[_0x0bc7('0xe')][_0x0bc7('0x11')]);}logger['error'](_0x0bc7('0x10'),_0x3c31ed,_0x3394fd[_0x0bc7('0xe')]['message']);return _0x16575b(_0x3394fd[_0x0bc7('0xe')][_0x0bc7('0x11')]);}else{logger[_0x0bc7('0xc')]('WhatsappMessage,\x20%s,\x20%s',_0x3c31ed,'request\x20sent');_0x16575b(_0x3394fd[_0x0bc7('0x12')][_0x0bc7('0x11')]);}})['catch'](function(_0x14d25c){logger[_0x0bc7('0xe')](_0x0bc7('0x10'),_0x3c31ed,_0x14d25c);_0x1d7018(_0x14d25c);});});}exports[_0x0bc7('0x13')]=function(_0x9e0579){var _0x10c21c=this;return new Promise(function(_0x4441a8,_0x2989a7){return db[_0x0bc7('0x14')][_0x0bc7('0x15')](_0x9e0579['body'],{'raw':_0x9e0579[_0x0bc7('0x16')]?_0x9e0579[_0x0bc7('0x16')][_0x0bc7('0x17')]===undefined?!![]:![]:!![]})[_0x0bc7('0x18')](function(_0xb620b5){logger[_0x0bc7('0xc')](_0x0bc7('0x13'),_0x9e0579);logger[_0x0bc7('0x19')](_0x0bc7('0x13'),_0x9e0579,JSON[_0x0bc7('0x1a')](_0xb620b5));_0x4441a8(_0xb620b5);})[_0x0bc7('0x1b')](function(_0x288f0e){logger[_0x0bc7('0xe')](_0x0bc7('0x13'),_0x288f0e['message'],_0x9e0579);_0x2989a7(_0x10c21c[_0x0bc7('0xe')](0x1f4,_0x288f0e[_0x0bc7('0x11')]));});});};