Built motion from commit c0cdc9d8.|2.6.28
[motion2.git] / server / api / whatsappInteraction / whatsappInteraction.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 _0xf597=['AddTagsToWhatsappInteraction','find','addTags','ids','omit','spread','AddTags','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','redis','defaults','localhost','socket.io-emitter','register','request','then','info','WhatsappInteraction,\x20%s,\x20%s','debug','WhatsappInteraction,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','catch','UpdateWhatsappInteraction','WhatsappInteraction','update','body','options','where','attributes'];(function(_0x6287b6,_0x5682e7){var _0x5d6be4=function(_0x3e3975){while(--_0x3e3975){_0x6287b6['push'](_0x6287b6['shift']());}};_0x5d6be4(++_0x5682e7);}(_0xf597,0x11f));var _0x7f59=function(_0x2820e2,_0x3ce800){_0x2820e2=_0x2820e2-0x0;var _0x582f72=_0xf597[_0x2820e2];return _0x582f72;};'use strict';var _=require(_0x7f59('0x0'));var util=require('util');var moment=require(_0x7f59('0x1'));var BPromise=require(_0x7f59('0x2'));var rs=require(_0x7f59('0x3'));var fs=require('fs');var Redis=require(_0x7f59('0x4'));var db=require(_0x7f59('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x7f59('0x6'))(_0x7f59('0x7'));var config=require(_0x7f59('0x8'));var jayson=require('jayson/promise');var client=jayson['client']['http']({'port':0x232a});config[_0x7f59('0x9')]=_[_0x7f59('0xa')](config['redis'],{'host':_0x7f59('0xb'),'port':0x18eb});var socket=require(_0x7f59('0xc'))(new Redis(config[_0x7f59('0x9')]));require('./whatsappInteraction.socket')[_0x7f59('0xd')](socket);function respondWithRpcPromise(_0x1a4b34,_0x5e3c66,_0x248783){return new BPromise(function(_0x3cd2fb,_0x44f414){return client[_0x7f59('0xe')](_0x1a4b34,_0x248783)[_0x7f59('0xf')](function(_0x290acc){logger[_0x7f59('0x10')](_0x7f59('0x11'),_0x5e3c66,'request\x20sent');logger[_0x7f59('0x12')](_0x7f59('0x13'),_0x5e3c66,_0x7f59('0x14'),JSON[_0x7f59('0x15')](_0x290acc));if(_0x290acc[_0x7f59('0x16')]){if(_0x290acc[_0x7f59('0x16')][_0x7f59('0x17')]===0x1f4){logger[_0x7f59('0x16')](_0x7f59('0x11'),_0x5e3c66,_0x290acc[_0x7f59('0x16')][_0x7f59('0x18')]);return _0x44f414(_0x290acc[_0x7f59('0x16')][_0x7f59('0x18')]);}logger[_0x7f59('0x16')](_0x7f59('0x11'),_0x5e3c66,_0x290acc[_0x7f59('0x16')][_0x7f59('0x18')]);return _0x3cd2fb(_0x290acc[_0x7f59('0x16')][_0x7f59('0x18')]);}else{logger[_0x7f59('0x10')]('WhatsappInteraction,\x20%s,\x20%s',_0x5e3c66,_0x7f59('0x14'));_0x3cd2fb(_0x290acc['result'][_0x7f59('0x18')]);}})[_0x7f59('0x19')](function(_0x3cd181){logger[_0x7f59('0x16')](_0x7f59('0x11'),_0x5e3c66,_0x3cd181);_0x44f414(_0x3cd181);});});}exports[_0x7f59('0x1a')]=function(_0xcf4f38){var _0x3b8dd1=this;return new Promise(function(_0x537841,_0x147447){return db[_0x7f59('0x1b')][_0x7f59('0x1c')](_0xcf4f38[_0x7f59('0x1d')],{'raw':_0xcf4f38[_0x7f59('0x1e')]?_0xcf4f38[_0x7f59('0x1e')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xcf4f38['options']?_0xcf4f38[_0x7f59('0x1e')][_0x7f59('0x1f')]||null:null,'attributes':_0xcf4f38[_0x7f59('0x1e')]?_0xcf4f38[_0x7f59('0x1e')][_0x7f59('0x20')]||null:null,'limit':_0xcf4f38[_0x7f59('0x1e')]?_0xcf4f38['options']['limit']||null:null})[_0x7f59('0xf')](function(_0x33cf70){logger[_0x7f59('0x10')](_0x7f59('0x1a'),_0xcf4f38);logger['debug'](_0x7f59('0x1a'),_0xcf4f38,JSON[_0x7f59('0x15')](_0x33cf70));_0x537841(_0x33cf70);})['catch'](function(_0x13c0d2){logger['error'](_0x7f59('0x1a'),_0x13c0d2[_0x7f59('0x18')],_0xcf4f38);_0x147447(_0x3b8dd1[_0x7f59('0x16')](0x1f4,_0x13c0d2[_0x7f59('0x18')]));});});};exports[_0x7f59('0x21')]=function(_0x3a727a){return new Promise(function(_0x5be2b7,_0x3bf495){return db[_0x7f59('0x1b')][_0x7f59('0x22')]({'where':_0x3a727a[_0x7f59('0x1e')]?_0x3a727a[_0x7f59('0x1e')][_0x7f59('0x1f')]||null:null})[_0x7f59('0xf')](function(_0x5453cb){if(_0x5453cb){return _0x5453cb[_0x7f59('0x23')](_0x3a727a[_0x7f59('0x1d')][_0x7f59('0x24')],_[_0x7f59('0x25')](_0x3a727a['body'],[_0x7f59('0x24'),'id'])||{});}})[_0x7f59('0x26')](function(_0x12776f){logger[_0x7f59('0x10')](_0x7f59('0x27'),_0x3a727a);logger[_0x7f59('0x12')](_0x7f59('0x27'),_0x3a727a,JSON['stringify'](_0x12776f));_0x5be2b7(_0x12776f);})[_0x7f59('0x19')](function(_0x299a20){logger[_0x7f59('0x16')](_0x7f59('0x27'),_0x299a20[_0x7f59('0x18')],_0x3a727a);_0x3bf495(_this[_0x7f59('0x16')](0x1f4,_0x299a20[_0x7f59('0x18')]));});});};