Built motion from commit 56a37f2a.|2.6.21
[motion2.git] / server / api / openchannelInteraction / openchannelInteraction.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 _0x1c02=['addTags','ids','omit','spread','AddTags','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','redis','defaults','localhost','socket.io-emitter','register','then','OpenchannelInteraction,\x20%s,\x20%s','request\x20sent','debug','OpenchannelInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','OpenchannelInteraction','update','body','options','where','UpdateOpenchannelInteraction','AddTagsToOpenchannelInteraction'];(function(_0x41a9e2,_0x32561b){var _0x5ae75e=function(_0x305f88){while(--_0x305f88){_0x41a9e2['push'](_0x41a9e2['shift']());}};_0x5ae75e(++_0x32561b);}(_0x1c02,0x164));var _0x21c0=function(_0x9bcd51,_0x44ba03){_0x9bcd51=_0x9bcd51-0x0;var _0x678fa=_0x1c02[_0x9bcd51];return _0x678fa;};'use strict';var _=require(_0x21c0('0x0'));var util=require(_0x21c0('0x1'));var moment=require(_0x21c0('0x2'));var BPromise=require(_0x21c0('0x3'));var rs=require(_0x21c0('0x4'));var fs=require('fs');var Redis=require(_0x21c0('0x5'));var db=require(_0x21c0('0x6'))['db'];var utils=require(_0x21c0('0x7'));var logger=require('../../config/logger')(_0x21c0('0x8'));var config=require(_0x21c0('0x9'));var jayson=require('jayson/promise');var client=jayson['client']['http']({'port':0x232a});config[_0x21c0('0xa')]=_[_0x21c0('0xb')](config[_0x21c0('0xa')],{'host':_0x21c0('0xc'),'port':0x18eb});var socket=require(_0x21c0('0xd'))(new Redis(config[_0x21c0('0xa')]));require('./openchannelInteraction.socket')[_0x21c0('0xe')](socket);function respondWithRpcPromise(_0x2bd970,_0x28c324,_0x5ad4bd){return new BPromise(function(_0x5c87f9,_0x218252){return client['request'](_0x2bd970,_0x5ad4bd)[_0x21c0('0xf')](function(_0x16afbe){logger['info'](_0x21c0('0x10'),_0x28c324,_0x21c0('0x11'));logger[_0x21c0('0x12')](_0x21c0('0x13'),_0x28c324,_0x21c0('0x11'),JSON[_0x21c0('0x14')](_0x16afbe));if(_0x16afbe[_0x21c0('0x15')]){if(_0x16afbe[_0x21c0('0x15')][_0x21c0('0x16')]===0x1f4){logger[_0x21c0('0x15')](_0x21c0('0x10'),_0x28c324,_0x16afbe['error'][_0x21c0('0x17')]);return _0x218252(_0x16afbe['error'][_0x21c0('0x17')]);}logger[_0x21c0('0x15')](_0x21c0('0x10'),_0x28c324,_0x16afbe[_0x21c0('0x15')]['message']);return _0x5c87f9(_0x16afbe[_0x21c0('0x15')][_0x21c0('0x17')]);}else{logger[_0x21c0('0x18')](_0x21c0('0x10'),_0x28c324,'request\x20sent');_0x5c87f9(_0x16afbe[_0x21c0('0x19')][_0x21c0('0x17')]);}})[_0x21c0('0x1a')](function(_0x1aa24b){logger['error'](_0x21c0('0x10'),_0x28c324,_0x1aa24b);_0x218252(_0x1aa24b);});});}exports['UpdateOpenchannelInteraction']=function(_0x42cd8f){var _0x52f323=this;return new Promise(function(_0x7879d,_0x51f492){return db[_0x21c0('0x1b')][_0x21c0('0x1c')](_0x42cd8f[_0x21c0('0x1d')],{'raw':_0x42cd8f[_0x21c0('0x1e')]?_0x42cd8f[_0x21c0('0x1e')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x42cd8f['options']?_0x42cd8f['options'][_0x21c0('0x1f')]||null:null,'attributes':_0x42cd8f[_0x21c0('0x1e')]?_0x42cd8f[_0x21c0('0x1e')]['attributes']||null:null,'limit':_0x42cd8f[_0x21c0('0x1e')]?_0x42cd8f['options']['limit']||null:null})[_0x21c0('0xf')](function(_0x5a7b4b){logger[_0x21c0('0x18')]('UpdateOpenchannelInteraction',_0x42cd8f);logger[_0x21c0('0x12')](_0x21c0('0x20'),_0x42cd8f,JSON['stringify'](_0x5a7b4b));_0x7879d(_0x5a7b4b);})[_0x21c0('0x1a')](function(_0x144af2){logger[_0x21c0('0x15')]('UpdateOpenchannelInteraction',_0x144af2[_0x21c0('0x17')],_0x42cd8f);_0x51f492(_0x52f323['error'](0x1f4,_0x144af2[_0x21c0('0x17')]));});});};exports[_0x21c0('0x21')]=function(_0x48c86f){return new Promise(function(_0x30af15,_0x599f64){return db[_0x21c0('0x1b')]['find']({'where':_0x48c86f[_0x21c0('0x1e')]?_0x48c86f[_0x21c0('0x1e')][_0x21c0('0x1f')]||null:null})[_0x21c0('0xf')](function(_0x19ff3f){if(_0x19ff3f){return _0x19ff3f[_0x21c0('0x22')](_0x48c86f[_0x21c0('0x1d')][_0x21c0('0x23')],_[_0x21c0('0x24')](_0x48c86f[_0x21c0('0x1d')],['ids','id'])||{});}})[_0x21c0('0x25')](function(_0x2ce86d){logger[_0x21c0('0x18')](_0x21c0('0x26'),_0x48c86f);logger['debug'](_0x21c0('0x26'),_0x48c86f,JSON[_0x21c0('0x14')](_0x2ce86d));_0x30af15(_0x2ce86d);})[_0x21c0('0x1a')](function(_0x1c5f8e){logger['error'](_0x21c0('0x26'),_0x1c5f8e['message'],_0x48c86f);_0x599f64(_this['error'](0x1f4,_0x1c5f8e['message']));});});};