Built motion from commit (unavailable).|2.5.24
[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 _0x7c2b=['options','raw','CreateWhatsappMessage','lodash','util','ioredis','../../mysqldb','../../config/utils','../../config/logger','jayson/promise','http','defaults','redis','socket.io-emitter','./whatsappMessage.socket','register','then','WhatsappMessage,\x20%s,\x20%s','debug','request\x20sent','stringify','error','code','message','info','result','catch','WhatsappMessage','create','body'];(function(_0x296897,_0x4d23ea){var _0x2b44ab=function(_0xdf90d8){while(--_0xdf90d8){_0x296897['push'](_0x296897['shift']());}};_0x2b44ab(++_0x4d23ea);}(_0x7c2b,0x14d));var _0xb7c2=function(_0x1bdbbb,_0x309051){_0x1bdbbb=_0x1bdbbb-0x0;var _0x2f7b60=_0x7c2b[_0x1bdbbb];return _0x2f7b60;};'use strict';var _=require(_0xb7c2('0x0'));var util=require(_0xb7c2('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xb7c2('0x2'));var db=require(_0xb7c2('0x3'))['db'];var utils=require(_0xb7c2('0x4'));var logger=require(_0xb7c2('0x5'))('rpc');var config=require('../../config/environment');var jayson=require(_0xb7c2('0x6'));var client=jayson['client'][_0xb7c2('0x7')]({'port':0x232a});config['redis']=_[_0xb7c2('0x8')](config[_0xb7c2('0x9')],{'host':'localhost','port':0x18eb});var socket=require(_0xb7c2('0xa'))(new Redis(config['redis']));require(_0xb7c2('0xb'))[_0xb7c2('0xc')](socket);function respondWithRpcPromise(_0x2f1d08,_0x38d0af,_0x301ccd){return new BPromise(function(_0x5e1b47,_0x49c059){return client['request'](_0x2f1d08,_0x301ccd)[_0xb7c2('0xd')](function(_0x11a32b){logger['info'](_0xb7c2('0xe'),_0x38d0af,'request\x20sent');logger[_0xb7c2('0xf')]('WhatsappMessage,\x20%s,\x20%s,\x20%s',_0x38d0af,_0xb7c2('0x10'),JSON[_0xb7c2('0x11')](_0x11a32b));if(_0x11a32b[_0xb7c2('0x12')]){if(_0x11a32b[_0xb7c2('0x12')][_0xb7c2('0x13')]===0x1f4){logger[_0xb7c2('0x12')](_0xb7c2('0xe'),_0x38d0af,_0x11a32b[_0xb7c2('0x12')]['message']);return _0x49c059(_0x11a32b[_0xb7c2('0x12')][_0xb7c2('0x14')]);}logger['error']('WhatsappMessage,\x20%s,\x20%s',_0x38d0af,_0x11a32b[_0xb7c2('0x12')][_0xb7c2('0x14')]);return _0x5e1b47(_0x11a32b['error'][_0xb7c2('0x14')]);}else{logger[_0xb7c2('0x15')](_0xb7c2('0xe'),_0x38d0af,_0xb7c2('0x10'));_0x5e1b47(_0x11a32b[_0xb7c2('0x16')][_0xb7c2('0x14')]);}})[_0xb7c2('0x17')](function(_0x3bfdb2){logger[_0xb7c2('0x12')](_0xb7c2('0xe'),_0x38d0af,_0x3bfdb2);_0x49c059(_0x3bfdb2);});});}exports['CreateWhatsappMessage']=function(_0x3e8898){var _0x1f817d=this;return new Promise(function(_0x338f95,_0x90aedf){return db[_0xb7c2('0x18')][_0xb7c2('0x19')](_0x3e8898[_0xb7c2('0x1a')],{'raw':_0x3e8898[_0xb7c2('0x1b')]?_0x3e8898[_0xb7c2('0x1b')][_0xb7c2('0x1c')]===undefined?!![]:![]:!![]})['then'](function(_0x14eb3b){logger[_0xb7c2('0x15')](_0xb7c2('0x1d'),_0x3e8898);logger['debug'](_0xb7c2('0x1d'),_0x3e8898,JSON['stringify'](_0x14eb3b));_0x338f95(_0x14eb3b);})[_0xb7c2('0x17')](function(_0xccb81c){logger['error'](_0xb7c2('0x1d'),_0xccb81c[_0xb7c2('0x14')],_0x3e8898);_0x90aedf(_0x1f817d[_0xb7c2('0x12')](0x1f4,_0xccb81c[_0xb7c2('0x14')]));});});};