Built motion from commit (unavailable).|2.5.4
[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 _0x622a=['../../config/logger','rpc','../../config/environment','client','http','redis','defaults','localhost','socket.io-emitter','./whatsappMessage.socket','register','then','WhatsappMessage,\x20%s,\x20%s','request\x20sent','debug','WhatsappMessage,\x20%s,\x20%s,\x20%s','error','code','message','info','result','catch','CreateWhatsappMessage','create','options','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils'];(function(_0x25bf36,_0x3d5f07){var _0x4e5078=function(_0xc4984f){while(--_0xc4984f){_0x25bf36['push'](_0x25bf36['shift']());}};_0x4e5078(++_0x3d5f07);}(_0x622a,0x79));var _0xa622=function(_0x264ff3,_0x5b7be8){_0x264ff3=_0x264ff3-0x0;var _0x2673af=_0x622a[_0x264ff3];return _0x2673af;};'use strict';var _=require(_0xa622('0x0'));var util=require(_0xa622('0x1'));var moment=require('moment');var BPromise=require(_0xa622('0x2'));var rs=require(_0xa622('0x3'));var fs=require('fs');var Redis=require(_0xa622('0x4'));var db=require(_0xa622('0x5'))['db'];var utils=require(_0xa622('0x6'));var logger=require(_0xa622('0x7'))(_0xa622('0x8'));var config=require(_0xa622('0x9'));var jayson=require('jayson/promise');var client=jayson[_0xa622('0xa')][_0xa622('0xb')]({'port':0x232a});config[_0xa622('0xc')]=_[_0xa622('0xd')](config[_0xa622('0xc')],{'host':_0xa622('0xe'),'port':0x18eb});var socket=require(_0xa622('0xf'))(new Redis(config[_0xa622('0xc')]));require(_0xa622('0x10'))[_0xa622('0x11')](socket);function respondWithRpcPromise(_0x3d4323,_0x4ea98a,_0x298c79){return new BPromise(function(_0x4f08f3,_0x4a42d0){return client['request'](_0x3d4323,_0x298c79)[_0xa622('0x12')](function(_0x21e318){logger['info'](_0xa622('0x13'),_0x4ea98a,_0xa622('0x14'));logger[_0xa622('0x15')](_0xa622('0x16'),_0x4ea98a,'request\x20sent',JSON['stringify'](_0x21e318));if(_0x21e318[_0xa622('0x17')]){if(_0x21e318[_0xa622('0x17')][_0xa622('0x18')]===0x1f4){logger['error']('WhatsappMessage,\x20%s,\x20%s',_0x4ea98a,_0x21e318['error']['message']);return _0x4a42d0(_0x21e318['error'][_0xa622('0x19')]);}logger['error'](_0xa622('0x13'),_0x4ea98a,_0x21e318[_0xa622('0x17')]['message']);return _0x4f08f3(_0x21e318['error'][_0xa622('0x19')]);}else{logger[_0xa622('0x1a')](_0xa622('0x13'),_0x4ea98a,_0xa622('0x14'));_0x4f08f3(_0x21e318[_0xa622('0x1b')][_0xa622('0x19')]);}})[_0xa622('0x1c')](function(_0x22b7a2){logger['error'](_0xa622('0x13'),_0x4ea98a,_0x22b7a2);_0x4a42d0(_0x22b7a2);});});}exports[_0xa622('0x1d')]=function(_0x158f17){var _0x308d1a=this;return new Promise(function(_0x416b39,_0x3dd7eb){return db['WhatsappMessage'][_0xa622('0x1e')](_0x158f17['body'],{'raw':_0x158f17[_0xa622('0x1f')]?_0x158f17[_0xa622('0x1f')]['raw']===undefined?!![]:![]:!![]})[_0xa622('0x12')](function(_0x497373){logger[_0xa622('0x1a')](_0xa622('0x1d'),_0x158f17);logger['debug'](_0xa622('0x1d'),_0x158f17,JSON['stringify'](_0x497373));_0x416b39(_0x497373);})[_0xa622('0x1c')](function(_0x482387){logger[_0xa622('0x17')]('CreateWhatsappMessage',_0x482387[_0xa622('0x19')],_0x158f17);_0x3dd7eb(_0x308d1a[_0xa622('0x17')](0x1f4,_0x482387[_0xa622('0x19')]));});});};