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 _0xf206=['http','redis','defaults','socket.io-emitter','./whatsappMessage.socket','register','request','then','WhatsappMessage,\x20%s,\x20%s','stringify','error','code','message','info','result','CreateWhatsappMessage','WhatsappMessage','body','options','raw','catch','lodash','util','bluebird','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client'];(function(_0x5ca026,_0x4503b4){var _0x552a89=function(_0x494721){while(--_0x494721){_0x5ca026['push'](_0x5ca026['shift']());}};_0x552a89(++_0x4503b4);}(_0xf206,0x1b9));var _0x6f20=function(_0x531acc,_0x39af25){_0x531acc=_0x531acc-0x0;var _0x5215d9=_0xf206[_0x531acc];return _0x5215d9;};'use strict';var _=require(_0x6f20('0x0'));var util=require(_0x6f20('0x1'));var moment=require('moment');var BPromise=require(_0x6f20('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x6f20('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x6f20('0x4'))(_0x6f20('0x5'));var config=require(_0x6f20('0x6'));var jayson=require(_0x6f20('0x7'));var client=jayson[_0x6f20('0x8')][_0x6f20('0x9')]({'port':0x232a});config[_0x6f20('0xa')]=_[_0x6f20('0xb')](config[_0x6f20('0xa')],{'host':'localhost','port':0x18eb});var socket=require(_0x6f20('0xc'))(new Redis(config['redis']));require(_0x6f20('0xd'))[_0x6f20('0xe')](socket);function respondWithRpcPromise(_0x433dcf,_0x2a36be,_0x53ffca){return new BPromise(function(_0x2c965d,_0x57fc56){return client[_0x6f20('0xf')](_0x433dcf,_0x53ffca)[_0x6f20('0x10')](function(_0x172972){logger['info'](_0x6f20('0x11'),_0x2a36be,'request\x20sent');logger['debug']('WhatsappMessage,\x20%s,\x20%s,\x20%s',_0x2a36be,'request\x20sent',JSON[_0x6f20('0x12')](_0x172972));if(_0x172972[_0x6f20('0x13')]){if(_0x172972['error'][_0x6f20('0x14')]===0x1f4){logger[_0x6f20('0x13')](_0x6f20('0x11'),_0x2a36be,_0x172972[_0x6f20('0x13')]['message']);return _0x57fc56(_0x172972['error']['message']);}logger[_0x6f20('0x13')](_0x6f20('0x11'),_0x2a36be,_0x172972[_0x6f20('0x13')]['message']);return _0x2c965d(_0x172972[_0x6f20('0x13')][_0x6f20('0x15')]);}else{logger[_0x6f20('0x16')]('WhatsappMessage,\x20%s,\x20%s',_0x2a36be,'request\x20sent');_0x2c965d(_0x172972[_0x6f20('0x17')][_0x6f20('0x15')]);}})['catch'](function(_0x44f6b9){logger['error'](_0x6f20('0x11'),_0x2a36be,_0x44f6b9);_0x57fc56(_0x44f6b9);});});}exports[_0x6f20('0x18')]=function(_0x487ff3){var _0x449a21=this;return new Promise(function(_0x12ecc9,_0x2f399b){return db[_0x6f20('0x19')]['create'](_0x487ff3[_0x6f20('0x1a')],{'raw':_0x487ff3[_0x6f20('0x1b')]?_0x487ff3[_0x6f20('0x1b')][_0x6f20('0x1c')]===undefined?!![]:![]:!![]})[_0x6f20('0x10')](function(_0x16dae9){logger[_0x6f20('0x16')](_0x6f20('0x18'),_0x487ff3);logger['debug'](_0x6f20('0x18'),_0x487ff3,JSON[_0x6f20('0x12')](_0x16dae9));_0x12ecc9(_0x16dae9);})[_0x6f20('0x1d')](function(_0x1df304){logger['error'](_0x6f20('0x18'),_0x1df304['message'],_0x487ff3);_0x2f399b(_0x449a21[_0x6f20('0x13')](0x1f4,_0x1df304[_0x6f20('0x15')]));});});};