26cf1afd0133231eaacb67083a4c2cb2efc25060
[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 _0x17ea=['WhatsappInteraction,\x20%s,\x20%s','request\x20sent','debug','WhatsappInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','UpdateWhatsappInteraction','WhatsappInteraction','update','body','options','raw','where','attributes','limit','catch','AddTagsToWhatsappInteraction','find','then','addTags','ids','spread','info','AddTags','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','defaults','redis','socket.io-emitter','./whatsappInteraction.socket','register','request'];(function(_0x451df6,_0x55922e){var _0x2fe4f4=function(_0x3d073a){while(--_0x3d073a){_0x451df6['push'](_0x451df6['shift']());}};_0x2fe4f4(++_0x55922e);}(_0x17ea,0xfc));var _0xa17e=function(_0x508e62,_0x499844){_0x508e62=_0x508e62-0x0;var _0x22c1c3=_0x17ea[_0x508e62];return _0x22c1c3;};'use strict';var _=require(_0xa17e('0x0'));var util=require(_0xa17e('0x1'));var moment=require(_0xa17e('0x2'));var BPromise=require(_0xa17e('0x3'));var rs=require(_0xa17e('0x4'));var fs=require('fs');var Redis=require(_0xa17e('0x5'));var db=require(_0xa17e('0x6'))['db'];var utils=require(_0xa17e('0x7'));var logger=require(_0xa17e('0x8'))(_0xa17e('0x9'));var config=require(_0xa17e('0xa'));var jayson=require('jayson/promise');var client=jayson[_0xa17e('0xb')]['http']({'port':0x232a});config['redis']=_[_0xa17e('0xc')](config[_0xa17e('0xd')],{'host':'localhost','port':0x18eb});var socket=require(_0xa17e('0xe'))(new Redis(config[_0xa17e('0xd')]));require(_0xa17e('0xf'))[_0xa17e('0x10')](socket);function respondWithRpcPromise(_0x284c25,_0x457fca,_0x10e2b6){return new BPromise(function(_0x2308e7,_0x48c073){return client[_0xa17e('0x11')](_0x284c25,_0x10e2b6)['then'](function(_0x2b355b){logger['info'](_0xa17e('0x12'),_0x457fca,_0xa17e('0x13'));logger[_0xa17e('0x14')](_0xa17e('0x15'),_0x457fca,_0xa17e('0x13'),JSON[_0xa17e('0x16')](_0x2b355b));if(_0x2b355b[_0xa17e('0x17')]){if(_0x2b355b['error'][_0xa17e('0x18')]===0x1f4){logger['error'](_0xa17e('0x12'),_0x457fca,_0x2b355b[_0xa17e('0x17')][_0xa17e('0x19')]);return _0x48c073(_0x2b355b[_0xa17e('0x17')]['message']);}logger[_0xa17e('0x17')](_0xa17e('0x12'),_0x457fca,_0x2b355b[_0xa17e('0x17')][_0xa17e('0x19')]);return _0x2308e7(_0x2b355b[_0xa17e('0x17')]['message']);}else{logger['info'](_0xa17e('0x12'),_0x457fca,_0xa17e('0x13'));_0x2308e7(_0x2b355b[_0xa17e('0x1a')]['message']);}})['catch'](function(_0x23e061){logger[_0xa17e('0x17')](_0xa17e('0x12'),_0x457fca,_0x23e061);_0x48c073(_0x23e061);});});}exports[_0xa17e('0x1b')]=function(_0x364fec){var _0x1ea942=this;return new Promise(function(_0x62628f,_0x248474){return db[_0xa17e('0x1c')][_0xa17e('0x1d')](_0x364fec[_0xa17e('0x1e')],{'raw':_0x364fec[_0xa17e('0x1f')]?_0x364fec['options'][_0xa17e('0x20')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x364fec['options']?_0x364fec['options'][_0xa17e('0x21')]||null:null,'attributes':_0x364fec[_0xa17e('0x1f')]?_0x364fec[_0xa17e('0x1f')][_0xa17e('0x22')]||null:null,'limit':_0x364fec[_0xa17e('0x1f')]?_0x364fec['options'][_0xa17e('0x23')]||null:null})['then'](function(_0x1719fe){logger['info'](_0xa17e('0x1b'),_0x364fec);logger[_0xa17e('0x14')](_0xa17e('0x1b'),_0x364fec,JSON[_0xa17e('0x16')](_0x1719fe));_0x62628f(_0x1719fe);})[_0xa17e('0x24')](function(_0x271949){logger[_0xa17e('0x17')](_0xa17e('0x1b'),_0x271949[_0xa17e('0x19')],_0x364fec);_0x248474(_0x1ea942[_0xa17e('0x17')](0x1f4,_0x271949[_0xa17e('0x19')]));});});};exports[_0xa17e('0x25')]=function(_0x1e871e){return new Promise(function(_0x2dd294,_0x1c6928){return db['WhatsappInteraction'][_0xa17e('0x26')]({'where':_0x1e871e[_0xa17e('0x1f')]?_0x1e871e[_0xa17e('0x1f')]['where']||null:null})[_0xa17e('0x27')](function(_0x40d1b8){if(_0x40d1b8){return _0x40d1b8[_0xa17e('0x28')](_0x1e871e[_0xa17e('0x1e')]['ids'],_['omit'](_0x1e871e[_0xa17e('0x1e')],[_0xa17e('0x29'),'id'])||{});}})[_0xa17e('0x2a')](function(_0x10f16c){logger[_0xa17e('0x2b')](_0xa17e('0x2c'),_0x1e871e);logger['debug'](_0xa17e('0x2c'),_0x1e871e,JSON['stringify'](_0x10f16c));_0x2dd294(_0x10f16c);})['catch'](function(_0x1e4b4c){logger[_0xa17e('0x17')](_0xa17e('0x2c'),_0x1e4b4c[_0xa17e('0x19')],_0x1e871e);_0x1c6928(_this['error'](0x1f4,_0x1e4b4c['message']));});});};