Built motion from commit f74363e9.|2.6.34
[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 _0x18b5=['request','then','info','WhatsappMessage,\x20%s,\x20%s','request\x20sent','debug','WhatsappMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','CreateWhatsappMessage','WhatsappMessage','create','body','options','raw','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','client','http','defaults','redis','./whatsappMessage.socket','register'];(function(_0x457bc0,_0x113db1){var _0x58c42e=function(_0x441134){while(--_0x441134){_0x457bc0['push'](_0x457bc0['shift']());}};_0x58c42e(++_0x113db1);}(_0x18b5,0x13b));var _0x518b=function(_0x8de54f,_0x271987){_0x8de54f=_0x8de54f-0x0;var _0x14cba4=_0x18b5[_0x8de54f];return _0x14cba4;};'use strict';var _=require(_0x518b('0x0'));var util=require(_0x518b('0x1'));var moment=require(_0x518b('0x2'));var BPromise=require(_0x518b('0x3'));var rs=require(_0x518b('0x4'));var fs=require('fs');var Redis=require(_0x518b('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0x518b('0x6'));var logger=require(_0x518b('0x7'))(_0x518b('0x8'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x518b('0x9')][_0x518b('0xa')]({'port':0x232a});config['redis']=_[_0x518b('0xb')](config[_0x518b('0xc')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x518b('0xc')]));require(_0x518b('0xd'))[_0x518b('0xe')](socket);function respondWithRpcPromise(_0x5c151a,_0x533a34,_0x132040){return new BPromise(function(_0x154d54,_0x35d76e){return client[_0x518b('0xf')](_0x5c151a,_0x132040)[_0x518b('0x10')](function(_0x48d0cc){logger[_0x518b('0x11')](_0x518b('0x12'),_0x533a34,_0x518b('0x13'));logger[_0x518b('0x14')](_0x518b('0x15'),_0x533a34,_0x518b('0x13'),JSON[_0x518b('0x16')](_0x48d0cc));if(_0x48d0cc[_0x518b('0x17')]){if(_0x48d0cc[_0x518b('0x17')][_0x518b('0x18')]===0x1f4){logger[_0x518b('0x17')](_0x518b('0x12'),_0x533a34,_0x48d0cc[_0x518b('0x17')][_0x518b('0x19')]);return _0x35d76e(_0x48d0cc[_0x518b('0x17')][_0x518b('0x19')]);}logger[_0x518b('0x17')]('WhatsappMessage,\x20%s,\x20%s',_0x533a34,_0x48d0cc[_0x518b('0x17')][_0x518b('0x19')]);return _0x154d54(_0x48d0cc['error'][_0x518b('0x19')]);}else{logger[_0x518b('0x11')]('WhatsappMessage,\x20%s,\x20%s',_0x533a34,'request\x20sent');_0x154d54(_0x48d0cc[_0x518b('0x1a')][_0x518b('0x19')]);}})['catch'](function(_0x2c16a6){logger[_0x518b('0x17')](_0x518b('0x12'),_0x533a34,_0x2c16a6);_0x35d76e(_0x2c16a6);});});}exports[_0x518b('0x1b')]=function(_0x352ae5){var _0x33e8a0=this;return new Promise(function(_0x3de111,_0x201348){return db[_0x518b('0x1c')][_0x518b('0x1d')](_0x352ae5[_0x518b('0x1e')],{'raw':_0x352ae5[_0x518b('0x1f')]?_0x352ae5['options'][_0x518b('0x20')]===undefined?!![]:![]:!![]})[_0x518b('0x10')](function(_0x97c53e){logger[_0x518b('0x11')]('CreateWhatsappMessage',_0x352ae5);logger[_0x518b('0x14')](_0x518b('0x1b'),_0x352ae5,JSON['stringify'](_0x97c53e));_0x3de111(_0x97c53e);})['catch'](function(_0x4ac2d3){logger[_0x518b('0x17')](_0x518b('0x1b'),_0x4ac2d3['message'],_0x352ae5);_0x201348(_0x33e8a0['error'](0x1f4,_0x4ac2d3[_0x518b('0x19')]));});});};