Built motion from commit d5e4af8c.|2.6.23
[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 _0x9f09=['create','options','raw','CreateWhatsappMessage','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./whatsappMessage.socket','register','request','then','info','WhatsappMessage,\x20%s,\x20%s','debug','request\x20sent','stringify','code','error','message','result','catch','WhatsappMessage'];(function(_0x19950b,_0x53d0d7){var _0x3c6b41=function(_0x3924ad){while(--_0x3924ad){_0x19950b['push'](_0x19950b['shift']());}};_0x3c6b41(++_0x53d0d7);}(_0x9f09,0x67));var _0x99f0=function(_0x36a6e6,_0x572048){_0x36a6e6=_0x36a6e6-0x0;var _0x4fd5f5=_0x9f09[_0x36a6e6];return _0x4fd5f5;};'use strict';var _=require(_0x99f0('0x0'));var util=require(_0x99f0('0x1'));var moment=require(_0x99f0('0x2'));var BPromise=require(_0x99f0('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x99f0('0x4'));var db=require(_0x99f0('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require(_0x99f0('0x6'));var jayson=require(_0x99f0('0x7'));var client=jayson[_0x99f0('0x8')][_0x99f0('0x9')]({'port':0x232a});config[_0x99f0('0xa')]=_[_0x99f0('0xb')](config[_0x99f0('0xa')],{'host':_0x99f0('0xc'),'port':0x18eb});var socket=require(_0x99f0('0xd'))(new Redis(config[_0x99f0('0xa')]));require(_0x99f0('0xe'))[_0x99f0('0xf')](socket);function respondWithRpcPromise(_0x275b13,_0x52ce5a,_0x1a000b){return new BPromise(function(_0x49725e,_0x20dd56){return client[_0x99f0('0x10')](_0x275b13,_0x1a000b)[_0x99f0('0x11')](function(_0x31e02b){logger[_0x99f0('0x12')](_0x99f0('0x13'),_0x52ce5a,'request\x20sent');logger[_0x99f0('0x14')]('WhatsappMessage,\x20%s,\x20%s,\x20%s',_0x52ce5a,_0x99f0('0x15'),JSON[_0x99f0('0x16')](_0x31e02b));if(_0x31e02b['error']){if(_0x31e02b['error'][_0x99f0('0x17')]===0x1f4){logger[_0x99f0('0x18')]('WhatsappMessage,\x20%s,\x20%s',_0x52ce5a,_0x31e02b[_0x99f0('0x18')][_0x99f0('0x19')]);return _0x20dd56(_0x31e02b[_0x99f0('0x18')]['message']);}logger[_0x99f0('0x18')](_0x99f0('0x13'),_0x52ce5a,_0x31e02b[_0x99f0('0x18')][_0x99f0('0x19')]);return _0x49725e(_0x31e02b[_0x99f0('0x18')]['message']);}else{logger[_0x99f0('0x12')](_0x99f0('0x13'),_0x52ce5a,_0x99f0('0x15'));_0x49725e(_0x31e02b[_0x99f0('0x1a')][_0x99f0('0x19')]);}})[_0x99f0('0x1b')](function(_0x37eb7d){logger[_0x99f0('0x18')]('WhatsappMessage,\x20%s,\x20%s',_0x52ce5a,_0x37eb7d);_0x20dd56(_0x37eb7d);});});}exports['CreateWhatsappMessage']=function(_0x24b4ca){var _0x53310c=this;return new Promise(function(_0x2742b3,_0x33c990){return db[_0x99f0('0x1c')][_0x99f0('0x1d')](_0x24b4ca['body'],{'raw':_0x24b4ca[_0x99f0('0x1e')]?_0x24b4ca[_0x99f0('0x1e')][_0x99f0('0x1f')]===undefined?!![]:![]:!![]})['then'](function(_0xf0ce4c){logger[_0x99f0('0x12')](_0x99f0('0x20'),_0x24b4ca);logger[_0x99f0('0x14')]('CreateWhatsappMessage',_0x24b4ca,JSON[_0x99f0('0x16')](_0xf0ce4c));_0x2742b3(_0xf0ce4c);})[_0x99f0('0x1b')](function(_0x4f15ca){logger[_0x99f0('0x18')](_0x99f0('0x20'),_0x4f15ca['message'],_0x24b4ca);_0x33c990(_0x53310c[_0x99f0('0x18')](0x1f4,_0x4f15ca[_0x99f0('0x19')]));});});};