ea63eff26fcba990c76f70e728e1c04413eb5bea
[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 _0xeac5=['WhatsappInteraction,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','UpdateWhatsappInteraction','WhatsappInteraction','update','body','options','where','attributes','catch','AddTagsToWhatsappInteraction','find','addTags','omit','ids','spread','AddTags','lodash','util','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','redis','socket.io-emitter','./whatsappInteraction.socket','register','then','info','WhatsappInteraction,\x20%s,\x20%s'];(function(_0x22802c,_0x223957){var _0x595397=function(_0x201b06){while(--_0x201b06){_0x22802c['push'](_0x22802c['shift']());}};_0x595397(++_0x223957);}(_0xeac5,0x112));var _0x5eac=function(_0x5ef905,_0x564b87){_0x5ef905=_0x5ef905-0x0;var _0x367808=_0xeac5[_0x5ef905];return _0x367808;};'use strict';var _=require(_0x5eac('0x0'));var util=require(_0x5eac('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x5eac('0x2'))['db'];var utils=require(_0x5eac('0x3'));var logger=require(_0x5eac('0x4'))(_0x5eac('0x5'));var config=require('../../config/environment');var jayson=require(_0x5eac('0x6'));var client=jayson['client']['http']({'port':0x232a});config[_0x5eac('0x7')]=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x5eac('0x8'))(new Redis(config[_0x5eac('0x7')]));require(_0x5eac('0x9'))[_0x5eac('0xa')](socket);function respondWithRpcPromise(_0x5cf75c,_0x53b6f1,_0x5ecbaf){return new BPromise(function(_0x3ef5a5,_0x2b80bd){return client['request'](_0x5cf75c,_0x5ecbaf)[_0x5eac('0xb')](function(_0x1bdda9){logger[_0x5eac('0xc')](_0x5eac('0xd'),_0x53b6f1,'request\x20sent');logger['debug'](_0x5eac('0xe'),_0x53b6f1,_0x5eac('0xf'),JSON[_0x5eac('0x10')](_0x1bdda9));if(_0x1bdda9[_0x5eac('0x11')]){if(_0x1bdda9[_0x5eac('0x11')][_0x5eac('0x12')]===0x1f4){logger[_0x5eac('0x11')](_0x5eac('0xd'),_0x53b6f1,_0x1bdda9[_0x5eac('0x11')]['message']);return _0x2b80bd(_0x1bdda9[_0x5eac('0x11')]['message']);}logger[_0x5eac('0x11')](_0x5eac('0xd'),_0x53b6f1,_0x1bdda9[_0x5eac('0x11')][_0x5eac('0x13')]);return _0x3ef5a5(_0x1bdda9[_0x5eac('0x11')][_0x5eac('0x13')]);}else{logger[_0x5eac('0xc')](_0x5eac('0xd'),_0x53b6f1,_0x5eac('0xf'));_0x3ef5a5(_0x1bdda9[_0x5eac('0x14')][_0x5eac('0x13')]);}})['catch'](function(_0x4f5ef6){logger[_0x5eac('0x11')](_0x5eac('0xd'),_0x53b6f1,_0x4f5ef6);_0x2b80bd(_0x4f5ef6);});});}exports[_0x5eac('0x15')]=function(_0x41453d){var _0x432abf=this;return new Promise(function(_0x3c8350,_0x985c1a){return db[_0x5eac('0x16')][_0x5eac('0x17')](_0x41453d[_0x5eac('0x18')],{'raw':_0x41453d[_0x5eac('0x19')]?_0x41453d[_0x5eac('0x19')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x41453d['options']?_0x41453d['options'][_0x5eac('0x1a')]||null:null,'attributes':_0x41453d[_0x5eac('0x19')]?_0x41453d[_0x5eac('0x19')][_0x5eac('0x1b')]||null:null,'limit':_0x41453d[_0x5eac('0x19')]?_0x41453d[_0x5eac('0x19')]['limit']||null:null})['then'](function(_0x22f2ac){logger[_0x5eac('0xc')](_0x5eac('0x15'),_0x41453d);logger['debug'](_0x5eac('0x15'),_0x41453d,JSON['stringify'](_0x22f2ac));_0x3c8350(_0x22f2ac);})[_0x5eac('0x1c')](function(_0x3e6a8a){logger['error']('UpdateWhatsappInteraction',_0x3e6a8a[_0x5eac('0x13')],_0x41453d);_0x985c1a(_0x432abf[_0x5eac('0x11')](0x1f4,_0x3e6a8a[_0x5eac('0x13')]));});});};exports[_0x5eac('0x1d')]=function(_0x3aa2c7){return new Promise(function(_0x2702d3,_0x3be774){return db[_0x5eac('0x16')][_0x5eac('0x1e')]({'where':_0x3aa2c7[_0x5eac('0x19')]?_0x3aa2c7['options']['where']||null:null})[_0x5eac('0xb')](function(_0x271b14){if(_0x271b14){return _0x271b14[_0x5eac('0x1f')](_0x3aa2c7[_0x5eac('0x18')]['ids'],_[_0x5eac('0x20')](_0x3aa2c7[_0x5eac('0x18')],[_0x5eac('0x21'),'id'])||{});}})[_0x5eac('0x22')](function(_0x56720b){logger[_0x5eac('0xc')](_0x5eac('0x23'),_0x3aa2c7);logger['debug'](_0x5eac('0x23'),_0x3aa2c7,JSON[_0x5eac('0x10')](_0x56720b));_0x2702d3(_0x56720b);})[_0x5eac('0x1c')](function(_0x503f52){logger[_0x5eac('0x11')]('AddTags',_0x503f52[_0x5eac('0x13')],_0x3aa2c7);_0x3be774(_this[_0x5eac('0x11')](0x1f4,_0x503f52[_0x5eac('0x13')]));});});};