Built motion from commit (unavailable).|2.5.6
[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 _0x7c9c=['moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','client','http','redis','defaults','localhost','socket.io-emitter','./whatsappMessage.socket','request','info','request\x20sent','error','code','message','WhatsappMessage,\x20%s,\x20%s','result','WhatsappMessage','create','body','options','raw','CreateWhatsappMessage','debug','catch','lodash'];(function(_0x203058,_0x357fcc){var _0x18f03c=function(_0x289712){while(--_0x289712){_0x203058['push'](_0x203058['shift']());}};_0x18f03c(++_0x357fcc);}(_0x7c9c,0x9f));var _0xc7c9=function(_0x37829c,_0x1a9992){_0x37829c=_0x37829c-0x0;var _0xaeaa8c=_0x7c9c[_0x37829c];return _0xaeaa8c;};'use strict';var _=require(_0xc7c9('0x0'));var util=require('util');var moment=require(_0xc7c9('0x1'));var BPromise=require(_0xc7c9('0x2'));var rs=require(_0xc7c9('0x3'));var fs=require('fs');var Redis=require(_0xc7c9('0x4'));var db=require(_0xc7c9('0x5'))['db'];var utils=require(_0xc7c9('0x6'));var logger=require('../../config/logger')(_0xc7c9('0x7'));var config=require(_0xc7c9('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xc7c9('0x9')][_0xc7c9('0xa')]({'port':0x232a});config[_0xc7c9('0xb')]=_[_0xc7c9('0xc')](config['redis'],{'host':_0xc7c9('0xd'),'port':0x18eb});var socket=require(_0xc7c9('0xe'))(new Redis(config[_0xc7c9('0xb')]));require(_0xc7c9('0xf'))['register'](socket);function respondWithRpcPromise(_0x46332d,_0x455c52,_0x233462){return new BPromise(function(_0x1eb29c,_0x2bec2e){return client[_0xc7c9('0x10')](_0x46332d,_0x233462)['then'](function(_0x560922){logger[_0xc7c9('0x11')]('WhatsappMessage,\x20%s,\x20%s',_0x455c52,_0xc7c9('0x12'));logger['debug']('WhatsappMessage,\x20%s,\x20%s,\x20%s',_0x455c52,'request\x20sent',JSON['stringify'](_0x560922));if(_0x560922[_0xc7c9('0x13')]){if(_0x560922[_0xc7c9('0x13')][_0xc7c9('0x14')]===0x1f4){logger[_0xc7c9('0x13')]('WhatsappMessage,\x20%s,\x20%s',_0x455c52,_0x560922[_0xc7c9('0x13')][_0xc7c9('0x15')]);return _0x2bec2e(_0x560922[_0xc7c9('0x13')]['message']);}logger['error'](_0xc7c9('0x16'),_0x455c52,_0x560922[_0xc7c9('0x13')][_0xc7c9('0x15')]);return _0x1eb29c(_0x560922['error'][_0xc7c9('0x15')]);}else{logger['info']('WhatsappMessage,\x20%s,\x20%s',_0x455c52,'request\x20sent');_0x1eb29c(_0x560922[_0xc7c9('0x17')]['message']);}})['catch'](function(_0x341fe7){logger[_0xc7c9('0x13')](_0xc7c9('0x16'),_0x455c52,_0x341fe7);_0x2bec2e(_0x341fe7);});});}exports['CreateWhatsappMessage']=function(_0x1a13ba){var _0x42a330=this;return new Promise(function(_0x25aede,_0xda5c65){return db[_0xc7c9('0x18')][_0xc7c9('0x19')](_0x1a13ba[_0xc7c9('0x1a')],{'raw':_0x1a13ba[_0xc7c9('0x1b')]?_0x1a13ba[_0xc7c9('0x1b')][_0xc7c9('0x1c')]===undefined?!![]:![]:!![]})['then'](function(_0x245c19){logger[_0xc7c9('0x11')](_0xc7c9('0x1d'),_0x1a13ba);logger[_0xc7c9('0x1e')](_0xc7c9('0x1d'),_0x1a13ba,JSON['stringify'](_0x245c19));_0x25aede(_0x245c19);})[_0xc7c9('0x1f')](function(_0xe583c3){logger[_0xc7c9('0x13')](_0xc7c9('0x1d'),_0xe583c3['message'],_0x1a13ba);_0xda5c65(_0x42a330[_0xc7c9('0x13')](0x1f4,_0xe583c3[_0xc7c9('0x15')]));});});};