Built motion from commit cb845558.|2.6.34
[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 _0x5d6c=['http','redis','localhost','socket.io-emitter','./whatsappMessage.socket','register','request','info','request\x20sent','debug','stringify','WhatsappMessage,\x20%s,\x20%s','error','message','result','catch','WhatsappMessage','options','raw','then','CreateWhatsappMessage','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','client'];(function(_0x4bc65f,_0x39ec43){var _0x44f85f=function(_0x175343){while(--_0x175343){_0x4bc65f['push'](_0x4bc65f['shift']());}};_0x44f85f(++_0x39ec43);}(_0x5d6c,0xf5));var _0xc5d6=function(_0x10747e,_0x9f1892){_0x10747e=_0x10747e-0x0;var _0x37735f=_0x5d6c[_0x10747e];return _0x37735f;};'use strict';var _=require(_0xc5d6('0x0'));var util=require(_0xc5d6('0x1'));var moment=require(_0xc5d6('0x2'));var BPromise=require(_0xc5d6('0x3'));var rs=require(_0xc5d6('0x4'));var fs=require('fs');var Redis=require(_0xc5d6('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0xc5d6('0x6'));var logger=require(_0xc5d6('0x7'))(_0xc5d6('0x8'));var config=require(_0xc5d6('0x9'));var jayson=require('jayson/promise');var client=jayson[_0xc5d6('0xa')][_0xc5d6('0xb')]({'port':0x232a});config[_0xc5d6('0xc')]=_['defaults'](config['redis'],{'host':_0xc5d6('0xd'),'port':0x18eb});var socket=require(_0xc5d6('0xe'))(new Redis(config[_0xc5d6('0xc')]));require(_0xc5d6('0xf'))[_0xc5d6('0x10')](socket);function respondWithRpcPromise(_0x512efc,_0x54bf5a,_0x3a4319){return new BPromise(function(_0x3e6e07,_0x38e979){return client[_0xc5d6('0x11')](_0x512efc,_0x3a4319)['then'](function(_0xb7fab6){logger[_0xc5d6('0x12')]('WhatsappMessage,\x20%s,\x20%s',_0x54bf5a,_0xc5d6('0x13'));logger[_0xc5d6('0x14')]('WhatsappMessage,\x20%s,\x20%s,\x20%s',_0x54bf5a,_0xc5d6('0x13'),JSON[_0xc5d6('0x15')](_0xb7fab6));if(_0xb7fab6['error']){if(_0xb7fab6['error']['code']===0x1f4){logger['error'](_0xc5d6('0x16'),_0x54bf5a,_0xb7fab6[_0xc5d6('0x17')][_0xc5d6('0x18')]);return _0x38e979(_0xb7fab6[_0xc5d6('0x17')][_0xc5d6('0x18')]);}logger[_0xc5d6('0x17')](_0xc5d6('0x16'),_0x54bf5a,_0xb7fab6[_0xc5d6('0x17')][_0xc5d6('0x18')]);return _0x3e6e07(_0xb7fab6['error'][_0xc5d6('0x18')]);}else{logger['info'](_0xc5d6('0x16'),_0x54bf5a,_0xc5d6('0x13'));_0x3e6e07(_0xb7fab6[_0xc5d6('0x19')][_0xc5d6('0x18')]);}})[_0xc5d6('0x1a')](function(_0x4df785){logger['error']('WhatsappMessage,\x20%s,\x20%s',_0x54bf5a,_0x4df785);_0x38e979(_0x4df785);});});}exports['CreateWhatsappMessage']=function(_0x41e84f){var _0x13655f=this;return new Promise(function(_0x2584d9,_0x395c0b){return db[_0xc5d6('0x1b')]['create'](_0x41e84f['body'],{'raw':_0x41e84f['options']?_0x41e84f[_0xc5d6('0x1c')][_0xc5d6('0x1d')]===undefined?!![]:![]:!![]})[_0xc5d6('0x1e')](function(_0xeb482f){logger[_0xc5d6('0x12')]('CreateWhatsappMessage',_0x41e84f);logger[_0xc5d6('0x14')]('CreateWhatsappMessage',_0x41e84f,JSON[_0xc5d6('0x15')](_0xeb482f));_0x2584d9(_0xeb482f);})[_0xc5d6('0x1a')](function(_0x2557ae){logger[_0xc5d6('0x17')](_0xc5d6('0x1f'),_0x2557ae[_0xc5d6('0x18')],_0x41e84f);_0x395c0b(_0x13655f['error'](0x1f4,_0x2557ae[_0xc5d6('0x18')]));});});};