Built motion from commit 7a4eb044.|2.5.36
[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 _0xe601=['then','info','request\x20sent','debug','WhatsappInteraction,\x20%s,\x20%s,\x20%s','stringify','code','error','message','WhatsappInteraction,\x20%s,\x20%s','result','catch','WhatsappInteraction','update','body','options','where','attributes','limit','UpdateWhatsappInteraction','AddTagsToWhatsappInteraction','addTags','ids','omit','spread','AddTags','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','redis','defaults','register','request'];(function(_0x4e2bdd,_0x57a05a){var _0x3d1531=function(_0x3205bc){while(--_0x3205bc){_0x4e2bdd['push'](_0x4e2bdd['shift']());}};_0x3d1531(++_0x57a05a);}(_0xe601,0xe2));var _0x1e60=function(_0x4a09b3,_0x2f88bc){_0x4a09b3=_0x4a09b3-0x0;var _0x297f9e=_0xe601[_0x4a09b3];return _0x297f9e;};'use strict';var _=require(_0x1e60('0x0'));var util=require(_0x1e60('0x1'));var moment=require(_0x1e60('0x2'));var BPromise=require(_0x1e60('0x3'));var rs=require(_0x1e60('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x1e60('0x5'))['db'];var utils=require(_0x1e60('0x6'));var logger=require(_0x1e60('0x7'))('rpc');var config=require(_0x1e60('0x8'));var jayson=require(_0x1e60('0x9'));var client=jayson['client']['http']({'port':0x232a});config[_0x1e60('0xa')]=_[_0x1e60('0xb')](config[_0x1e60('0xa')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x1e60('0xa')]));require('./whatsappInteraction.socket')[_0x1e60('0xc')](socket);function respondWithRpcPromise(_0x1f083b,_0x52beb1,_0x5b607e){return new BPromise(function(_0x5d4366,_0x4bd14c){return client[_0x1e60('0xd')](_0x1f083b,_0x5b607e)[_0x1e60('0xe')](function(_0x3d9206){logger[_0x1e60('0xf')]('WhatsappInteraction,\x20%s,\x20%s',_0x52beb1,_0x1e60('0x10'));logger[_0x1e60('0x11')](_0x1e60('0x12'),_0x52beb1,_0x1e60('0x10'),JSON[_0x1e60('0x13')](_0x3d9206));if(_0x3d9206['error']){if(_0x3d9206['error'][_0x1e60('0x14')]===0x1f4){logger[_0x1e60('0x15')]('WhatsappInteraction,\x20%s,\x20%s',_0x52beb1,_0x3d9206[_0x1e60('0x15')][_0x1e60('0x16')]);return _0x4bd14c(_0x3d9206[_0x1e60('0x15')][_0x1e60('0x16')]);}logger['error'](_0x1e60('0x17'),_0x52beb1,_0x3d9206[_0x1e60('0x15')][_0x1e60('0x16')]);return _0x5d4366(_0x3d9206['error'][_0x1e60('0x16')]);}else{logger[_0x1e60('0xf')](_0x1e60('0x17'),_0x52beb1,_0x1e60('0x10'));_0x5d4366(_0x3d9206[_0x1e60('0x18')][_0x1e60('0x16')]);}})[_0x1e60('0x19')](function(_0x1fbef4){logger['error']('WhatsappInteraction,\x20%s,\x20%s',_0x52beb1,_0x1fbef4);_0x4bd14c(_0x1fbef4);});});}exports['UpdateWhatsappInteraction']=function(_0x364239){var _0x5d10c4=this;return new Promise(function(_0x407b68,_0x39188a){return db[_0x1e60('0x1a')][_0x1e60('0x1b')](_0x364239[_0x1e60('0x1c')],{'raw':_0x364239[_0x1e60('0x1d')]?_0x364239[_0x1e60('0x1d')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x364239[_0x1e60('0x1d')]?_0x364239[_0x1e60('0x1d')][_0x1e60('0x1e')]||null:null,'attributes':_0x364239[_0x1e60('0x1d')]?_0x364239[_0x1e60('0x1d')][_0x1e60('0x1f')]||null:null,'limit':_0x364239[_0x1e60('0x1d')]?_0x364239[_0x1e60('0x1d')][_0x1e60('0x20')]||null:null})['then'](function(_0x87570a){logger[_0x1e60('0xf')](_0x1e60('0x21'),_0x364239);logger[_0x1e60('0x11')](_0x1e60('0x21'),_0x364239,JSON[_0x1e60('0x13')](_0x87570a));_0x407b68(_0x87570a);})['catch'](function(_0x21b1ac){logger['error'](_0x1e60('0x21'),_0x21b1ac['message'],_0x364239);_0x39188a(_0x5d10c4[_0x1e60('0x15')](0x1f4,_0x21b1ac['message']));});});};exports[_0x1e60('0x22')]=function(_0x4ecc34){return new Promise(function(_0x9128ae,_0x49cbb5){return db['WhatsappInteraction']['find']({'where':_0x4ecc34[_0x1e60('0x1d')]?_0x4ecc34[_0x1e60('0x1d')][_0x1e60('0x1e')]||null:null})['then'](function(_0x1941d3){if(_0x1941d3){return _0x1941d3[_0x1e60('0x23')](_0x4ecc34[_0x1e60('0x1c')][_0x1e60('0x24')],_[_0x1e60('0x25')](_0x4ecc34[_0x1e60('0x1c')],['ids','id'])||{});}})[_0x1e60('0x26')](function(_0x4e201b){logger[_0x1e60('0xf')](_0x1e60('0x27'),_0x4ecc34);logger[_0x1e60('0x11')](_0x1e60('0x27'),_0x4ecc34,JSON[_0x1e60('0x13')](_0x4e201b));_0x9128ae(_0x4e201b);})[_0x1e60('0x19')](function(_0x179281){logger[_0x1e60('0x15')](_0x1e60('0x27'),_0x179281[_0x1e60('0x16')],_0x4ecc34);_0x49cbb5(_this[_0x1e60('0x15')](0x1f4,_0x179281[_0x1e60('0x16')]));});});};