Built motion from commit 14588770.|2.5.38
[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 _0x5b72=['WhatsappMessage,\x20%s,\x20%s,\x20%s','stringify','code','error','WhatsappMessage,\x20%s,\x20%s','message','result','CreateWhatsappMessage','WhatsappMessage','create','raw','info','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','./whatsappMessage.socket','register','request','debug'];(function(_0xc62bf6,_0x54eac4){var _0x1c4fb5=function(_0x2af6b6){while(--_0x2af6b6){_0xc62bf6['push'](_0xc62bf6['shift']());}};_0x1c4fb5(++_0x54eac4);}(_0x5b72,0x185));var _0x25b7=function(_0x14580c,_0xa50d45){_0x14580c=_0x14580c-0x0;var _0x99542d=_0x5b72[_0x14580c];return _0x99542d;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x25b7('0x0'));var BPromise=require(_0x25b7('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x25b7('0x2'));var db=require(_0x25b7('0x3'))['db'];var utils=require(_0x25b7('0x4'));var logger=require(_0x25b7('0x5'))('rpc');var config=require(_0x25b7('0x6'));var jayson=require(_0x25b7('0x7'));var client=jayson[_0x25b7('0x8')][_0x25b7('0x9')]({'port':0x232a});config[_0x25b7('0xa')]=_[_0x25b7('0xb')](config[_0x25b7('0xa')],{'host':_0x25b7('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x25b7('0xd'))[_0x25b7('0xe')](socket);function respondWithRpcPromise(_0x346bc9,_0x10c494,_0x559fa6){return new BPromise(function(_0x54f201,_0x10b4be){return client[_0x25b7('0xf')](_0x346bc9,_0x559fa6)['then'](function(_0x549a06){logger['info']('WhatsappMessage,\x20%s,\x20%s',_0x10c494,'request\x20sent');logger[_0x25b7('0x10')](_0x25b7('0x11'),_0x10c494,'request\x20sent',JSON[_0x25b7('0x12')](_0x549a06));if(_0x549a06['error']){if(_0x549a06['error'][_0x25b7('0x13')]===0x1f4){logger[_0x25b7('0x14')](_0x25b7('0x15'),_0x10c494,_0x549a06[_0x25b7('0x14')][_0x25b7('0x16')]);return _0x10b4be(_0x549a06[_0x25b7('0x14')]['message']);}logger['error'](_0x25b7('0x15'),_0x10c494,_0x549a06['error'][_0x25b7('0x16')]);return _0x54f201(_0x549a06[_0x25b7('0x14')]['message']);}else{logger['info'](_0x25b7('0x15'),_0x10c494,'request\x20sent');_0x54f201(_0x549a06[_0x25b7('0x17')][_0x25b7('0x16')]);}})['catch'](function(_0x2c147d){logger[_0x25b7('0x14')](_0x25b7('0x15'),_0x10c494,_0x2c147d);_0x10b4be(_0x2c147d);});});}exports[_0x25b7('0x18')]=function(_0xd49e6b){var _0x310855=this;return new Promise(function(_0x7e06d6,_0x4c7ed1){return db[_0x25b7('0x19')][_0x25b7('0x1a')](_0xd49e6b['body'],{'raw':_0xd49e6b['options']?_0xd49e6b['options'][_0x25b7('0x1b')]===undefined?!![]:![]:!![]})['then'](function(_0x4f9d6d){logger[_0x25b7('0x1c')](_0x25b7('0x18'),_0xd49e6b);logger['debug'](_0x25b7('0x18'),_0xd49e6b,JSON[_0x25b7('0x12')](_0x4f9d6d));_0x7e06d6(_0x4f9d6d);})['catch'](function(_0x47213d){logger['error'](_0x25b7('0x18'),_0x47213d['message'],_0xd49e6b);_0x4c7ed1(_0x310855[_0x25b7('0x14')](0x1f4,_0x47213d['message']));});});};