Built motion from commit 10af8726.|2.6.34
[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 _0xeeaf=['lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','localhost','redis','register','request','info','OpenchannelInteraction,\x20%s,\x20%s','debug','OpenchannelInteraction,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','UpdateOpenchannelInteraction','OpenchannelInteraction','update','body','options','raw','where','attributes','then','ids','omit','AddTags'];(function(_0x142cb4,_0x46741a){var _0x21599a=function(_0x3b38b3){while(--_0x3b38b3){_0x142cb4['push'](_0x142cb4['shift']());}};_0x21599a(++_0x46741a);}(_0xeeaf,0x186));var _0xfeea=function(_0x5c4207,_0x56c4f9){_0x5c4207=_0x5c4207-0x0;var _0x1d5b50=_0xeeaf[_0x5c4207];return _0x1d5b50;};'use strict';var _=require(_0xfeea('0x0'));var util=require(_0xfeea('0x1'));var moment=require('moment');var BPromise=require(_0xfeea('0x2'));var rs=require(_0xfeea('0x3'));var fs=require('fs');var Redis=require(_0xfeea('0x4'));var db=require(_0xfeea('0x5'))['db'];var utils=require(_0xfeea('0x6'));var logger=require('../../config/logger')(_0xfeea('0x7'));var config=require(_0xfeea('0x8'));var jayson=require(_0xfeea('0x9'));var client=jayson[_0xfeea('0xa')][_0xfeea('0xb')]({'port':0x232a});config['redis']=_['defaults'](config['redis'],{'host':_0xfeea('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xfeea('0xd')]));require('./openchannelInteraction.socket')[_0xfeea('0xe')](socket);function respondWithRpcPromise(_0x254f30,_0x1f9c9d,_0x2e01bd){return new BPromise(function(_0xeb40d7,_0x36980a){return client[_0xfeea('0xf')](_0x254f30,_0x2e01bd)['then'](function(_0x431285){logger[_0xfeea('0x10')](_0xfeea('0x11'),_0x1f9c9d,'request\x20sent');logger[_0xfeea('0x12')](_0xfeea('0x13'),_0x1f9c9d,_0xfeea('0x14'),JSON[_0xfeea('0x15')](_0x431285));if(_0x431285[_0xfeea('0x16')]){if(_0x431285[_0xfeea('0x16')][_0xfeea('0x17')]===0x1f4){logger[_0xfeea('0x16')](_0xfeea('0x11'),_0x1f9c9d,_0x431285[_0xfeea('0x16')][_0xfeea('0x18')]);return _0x36980a(_0x431285[_0xfeea('0x16')]['message']);}logger['error'](_0xfeea('0x11'),_0x1f9c9d,_0x431285[_0xfeea('0x16')]['message']);return _0xeb40d7(_0x431285[_0xfeea('0x16')]['message']);}else{logger['info']('OpenchannelInteraction,\x20%s,\x20%s',_0x1f9c9d,_0xfeea('0x14'));_0xeb40d7(_0x431285[_0xfeea('0x19')][_0xfeea('0x18')]);}})[_0xfeea('0x1a')](function(_0x428a81){logger['error'](_0xfeea('0x11'),_0x1f9c9d,_0x428a81);_0x36980a(_0x428a81);});});}exports[_0xfeea('0x1b')]=function(_0x8bfba){var _0x4da958=this;return new Promise(function(_0x9c38ad,_0x2f5fb3){return db[_0xfeea('0x1c')][_0xfeea('0x1d')](_0x8bfba[_0xfeea('0x1e')],{'raw':_0x8bfba['options']?_0x8bfba[_0xfeea('0x1f')][_0xfeea('0x20')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x8bfba[_0xfeea('0x1f')]?_0x8bfba[_0xfeea('0x1f')][_0xfeea('0x21')]||null:null,'attributes':_0x8bfba[_0xfeea('0x1f')]?_0x8bfba[_0xfeea('0x1f')][_0xfeea('0x22')]||null:null,'limit':_0x8bfba[_0xfeea('0x1f')]?_0x8bfba[_0xfeea('0x1f')]['limit']||null:null})[_0xfeea('0x23')](function(_0x19c816){logger[_0xfeea('0x10')]('UpdateOpenchannelInteraction',_0x8bfba);logger[_0xfeea('0x12')]('UpdateOpenchannelInteraction',_0x8bfba,JSON[_0xfeea('0x15')](_0x19c816));_0x9c38ad(_0x19c816);})[_0xfeea('0x1a')](function(_0x4a6022){logger['error'](_0xfeea('0x1b'),_0x4a6022['message'],_0x8bfba);_0x2f5fb3(_0x4da958[_0xfeea('0x16')](0x1f4,_0x4a6022[_0xfeea('0x18')]));});});};exports['AddTagsToOpenchannelInteraction']=function(_0x5752f8){return new Promise(function(_0x4c6ccf,_0x275df7){return db['OpenchannelInteraction']['find']({'where':_0x5752f8[_0xfeea('0x1f')]?_0x5752f8[_0xfeea('0x1f')]['where']||null:null})[_0xfeea('0x23')](function(_0x4fd401){if(_0x4fd401){return _0x4fd401['addTags'](_0x5752f8[_0xfeea('0x1e')][_0xfeea('0x24')],_[_0xfeea('0x25')](_0x5752f8[_0xfeea('0x1e')],[_0xfeea('0x24'),'id'])||{});}})['spread'](function(_0x3a3275){logger[_0xfeea('0x10')](_0xfeea('0x26'),_0x5752f8);logger[_0xfeea('0x12')](_0xfeea('0x26'),_0x5752f8,JSON['stringify'](_0x3a3275));_0x4c6ccf(_0x3a3275);})['catch'](function(_0x245810){logger['error'](_0xfeea('0x26'),_0x245810[_0xfeea('0x18')],_0x5752f8);_0x275df7(_this[_0xfeea('0x16')](0x1f4,_0x245810['message']));});});};