Built motion from commit 64440dd5.|2.6.29
[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 _0x2900=['then','info','WhatsappMessage,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','CreateWhatsappMessage','options','lodash','moment','ioredis','../../mysqldb','../../config/utils','rpc','client','http','defaults','localhost','socket.io-emitter','./whatsappMessage.socket','register','request'];(function(_0x1aefae,_0x45a7fa){var _0x292f09=function(_0x57526a){while(--_0x57526a){_0x1aefae['push'](_0x1aefae['shift']());}};_0x292f09(++_0x45a7fa);}(_0x2900,0x94));var _0x0290=function(_0x22868f,_0x450f48){_0x22868f=_0x22868f-0x0;var _0x97bc75=_0x2900[_0x22868f];return _0x97bc75;};'use strict';var _=require(_0x0290('0x0'));var util=require('util');var moment=require(_0x0290('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x0290('0x2'));var db=require(_0x0290('0x3'))['db'];var utils=require(_0x0290('0x4'));var logger=require('../../config/logger')(_0x0290('0x5'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x0290('0x6')][_0x0290('0x7')]({'port':0x232a});config['redis']=_[_0x0290('0x8')](config['redis'],{'host':_0x0290('0x9'),'port':0x18eb});var socket=require(_0x0290('0xa'))(new Redis(config['redis']));require(_0x0290('0xb'))[_0x0290('0xc')](socket);function respondWithRpcPromise(_0xd1e37f,_0x21fb1d,_0x16c0f9){return new BPromise(function(_0x57413d,_0x1c2a48){return client[_0x0290('0xd')](_0xd1e37f,_0x16c0f9)[_0x0290('0xe')](function(_0x398d99){logger[_0x0290('0xf')](_0x0290('0x10'),_0x21fb1d,_0x0290('0x11'));logger[_0x0290('0x12')]('WhatsappMessage,\x20%s,\x20%s,\x20%s',_0x21fb1d,_0x0290('0x11'),JSON[_0x0290('0x13')](_0x398d99));if(_0x398d99[_0x0290('0x14')]){if(_0x398d99[_0x0290('0x14')][_0x0290('0x15')]===0x1f4){logger['error'](_0x0290('0x10'),_0x21fb1d,_0x398d99[_0x0290('0x14')][_0x0290('0x16')]);return _0x1c2a48(_0x398d99[_0x0290('0x14')][_0x0290('0x16')]);}logger[_0x0290('0x14')](_0x0290('0x10'),_0x21fb1d,_0x398d99['error'][_0x0290('0x16')]);return _0x57413d(_0x398d99[_0x0290('0x14')][_0x0290('0x16')]);}else{logger['info']('WhatsappMessage,\x20%s,\x20%s',_0x21fb1d,_0x0290('0x11'));_0x57413d(_0x398d99[_0x0290('0x17')][_0x0290('0x16')]);}})[_0x0290('0x18')](function(_0x8890bc){logger[_0x0290('0x14')]('WhatsappMessage,\x20%s,\x20%s',_0x21fb1d,_0x8890bc);_0x1c2a48(_0x8890bc);});});}exports[_0x0290('0x19')]=function(_0x3ac9c0){var _0x1cf9dd=this;return new Promise(function(_0x3158df,_0x531c88){return db['WhatsappMessage']['create'](_0x3ac9c0['body'],{'raw':_0x3ac9c0[_0x0290('0x1a')]?_0x3ac9c0[_0x0290('0x1a')]['raw']===undefined?!![]:![]:!![]})[_0x0290('0xe')](function(_0x2f09e2){logger[_0x0290('0xf')](_0x0290('0x19'),_0x3ac9c0);logger[_0x0290('0x12')](_0x0290('0x19'),_0x3ac9c0,JSON[_0x0290('0x13')](_0x2f09e2));_0x3158df(_0x2f09e2);})[_0x0290('0x18')](function(_0x473f62){logger[_0x0290('0x14')](_0x0290('0x19'),_0x473f62[_0x0290('0x16')],_0x3ac9c0);_0x531c88(_0x1cf9dd[_0x0290('0x14')](0x1f4,_0x473f62[_0x0290('0x16')]));});});};