Built motion from commit b0a9a629.|2.6.33
[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 _0x3c6f=['error','message','catch','CreateWhatsappMessage','WhatsappMessage','create','body','options','raw','lodash','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','redis','defaults','localhost','socket.io-emitter','./whatsappMessage.socket','then','info','WhatsappMessage,\x20%s,\x20%s','request\x20sent','debug','WhatsappMessage,\x20%s,\x20%s,\x20%s','stringify'];(function(_0x76c36d,_0x3fd4ec){var _0x15a4ae=function(_0x467817){while(--_0x467817){_0x76c36d['push'](_0x76c36d['shift']());}};_0x15a4ae(++_0x3fd4ec);}(_0x3c6f,0x135));var _0xf3c6=function(_0x42608a,_0x149a88){_0x42608a=_0x42608a-0x0;var _0xa4375f=_0x3c6f[_0x42608a];return _0xa4375f;};'use strict';var _=require(_0xf3c6('0x0'));var util=require('util');var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0xf3c6('0x1'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xf3c6('0x2'))['db'];var utils=require(_0xf3c6('0x3'));var logger=require(_0xf3c6('0x4'))(_0xf3c6('0x5'));var config=require(_0xf3c6('0x6'));var jayson=require('jayson/promise');var client=jayson[_0xf3c6('0x7')][_0xf3c6('0x8')]({'port':0x232a});config[_0xf3c6('0x9')]=_[_0xf3c6('0xa')](config[_0xf3c6('0x9')],{'host':_0xf3c6('0xb'),'port':0x18eb});var socket=require(_0xf3c6('0xc'))(new Redis(config['redis']));require(_0xf3c6('0xd'))['register'](socket);function respondWithRpcPromise(_0x5a73b8,_0x5f37b1,_0x59bae7){return new BPromise(function(_0xd85dbd,_0x26763d){return client['request'](_0x5a73b8,_0x59bae7)[_0xf3c6('0xe')](function(_0x1d27eb){logger[_0xf3c6('0xf')](_0xf3c6('0x10'),_0x5f37b1,_0xf3c6('0x11'));logger[_0xf3c6('0x12')](_0xf3c6('0x13'),_0x5f37b1,'request\x20sent',JSON[_0xf3c6('0x14')](_0x1d27eb));if(_0x1d27eb[_0xf3c6('0x15')]){if(_0x1d27eb['error']['code']===0x1f4){logger[_0xf3c6('0x15')]('WhatsappMessage,\x20%s,\x20%s',_0x5f37b1,_0x1d27eb['error'][_0xf3c6('0x16')]);return _0x26763d(_0x1d27eb[_0xf3c6('0x15')]['message']);}logger[_0xf3c6('0x15')](_0xf3c6('0x10'),_0x5f37b1,_0x1d27eb[_0xf3c6('0x15')][_0xf3c6('0x16')]);return _0xd85dbd(_0x1d27eb['error'][_0xf3c6('0x16')]);}else{logger[_0xf3c6('0xf')]('WhatsappMessage,\x20%s,\x20%s',_0x5f37b1,_0xf3c6('0x11'));_0xd85dbd(_0x1d27eb['result'][_0xf3c6('0x16')]);}})[_0xf3c6('0x17')](function(_0x3df5d0){logger[_0xf3c6('0x15')](_0xf3c6('0x10'),_0x5f37b1,_0x3df5d0);_0x26763d(_0x3df5d0);});});}exports[_0xf3c6('0x18')]=function(_0x295789){var _0x131511=this;return new Promise(function(_0x5aa63d,_0x257277){return db[_0xf3c6('0x19')][_0xf3c6('0x1a')](_0x295789[_0xf3c6('0x1b')],{'raw':_0x295789['options']?_0x295789[_0xf3c6('0x1c')][_0xf3c6('0x1d')]===undefined?!![]:![]:!![]})[_0xf3c6('0xe')](function(_0x46040f){logger[_0xf3c6('0xf')](_0xf3c6('0x18'),_0x295789);logger['debug']('CreateWhatsappMessage',_0x295789,JSON[_0xf3c6('0x14')](_0x46040f));_0x5aa63d(_0x46040f);})[_0xf3c6('0x17')](function(_0x533387){logger[_0xf3c6('0x15')](_0xf3c6('0x18'),_0x533387[_0xf3c6('0x16')],_0x295789);_0x257277(_0x131511[_0xf3c6('0x15')](0x1f4,_0x533387['message']));});});};