1789d4cda73392caf943b637539cbc56243f1adc
[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 _0x35b6=['result','catch','UpdateOpenchannelInteraction','OpenchannelInteraction','update','body','options','raw','where','attributes','limit','stringify','AddTagsToOpenchannelInteraction','addTags','ids','omit','spread','AddTags','lodash','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','redis','defaults','localhost','socket.io-emitter','register','then','info','OpenchannelInteraction,\x20%s,\x20%s','request\x20sent','OpenchannelInteraction,\x20%s,\x20%s,\x20%s','error','code','message'];(function(_0x4c09f4,_0x60bb8f){var _0x393e5e=function(_0x1a489c){while(--_0x1a489c){_0x4c09f4['push'](_0x4c09f4['shift']());}};_0x393e5e(++_0x60bb8f);}(_0x35b6,0x90));var _0x635b=function(_0x10377e,_0x2433c9){_0x10377e=_0x10377e-0x0;var _0x3d6230=_0x35b6[_0x10377e];return _0x3d6230;};'use strict';var _=require(_0x635b('0x0'));var util=require('util');var moment=require(_0x635b('0x1'));var BPromise=require(_0x635b('0x2'));var rs=require(_0x635b('0x3'));var fs=require('fs');var Redis=require(_0x635b('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x635b('0x5'));var logger=require(_0x635b('0x6'))(_0x635b('0x7'));var config=require(_0x635b('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x635b('0x9')][_0x635b('0xa')]({'port':0x232a});config[_0x635b('0xb')]=_[_0x635b('0xc')](config[_0x635b('0xb')],{'host':_0x635b('0xd'),'port':0x18eb});var socket=require(_0x635b('0xe'))(new Redis(config[_0x635b('0xb')]));require('./openchannelInteraction.socket')[_0x635b('0xf')](socket);function respondWithRpcPromise(_0x19fa84,_0x6a6566,_0x5d6951){return new BPromise(function(_0x32ed3e,_0x562427){return client['request'](_0x19fa84,_0x5d6951)[_0x635b('0x10')](function(_0x1516ea){logger[_0x635b('0x11')](_0x635b('0x12'),_0x6a6566,_0x635b('0x13'));logger['debug'](_0x635b('0x14'),_0x6a6566,_0x635b('0x13'),JSON['stringify'](_0x1516ea));if(_0x1516ea[_0x635b('0x15')]){if(_0x1516ea['error'][_0x635b('0x16')]===0x1f4){logger[_0x635b('0x15')](_0x635b('0x12'),_0x6a6566,_0x1516ea[_0x635b('0x15')][_0x635b('0x17')]);return _0x562427(_0x1516ea[_0x635b('0x15')]['message']);}logger[_0x635b('0x15')](_0x635b('0x12'),_0x6a6566,_0x1516ea[_0x635b('0x15')][_0x635b('0x17')]);return _0x32ed3e(_0x1516ea[_0x635b('0x15')]['message']);}else{logger['info'](_0x635b('0x12'),_0x6a6566,'request\x20sent');_0x32ed3e(_0x1516ea[_0x635b('0x18')][_0x635b('0x17')]);}})[_0x635b('0x19')](function(_0x30e447){logger[_0x635b('0x15')](_0x635b('0x12'),_0x6a6566,_0x30e447);_0x562427(_0x30e447);});});}exports[_0x635b('0x1a')]=function(_0xad36f6){var _0x249e77=this;return new Promise(function(_0x3c71c9,_0x1b5831){return db[_0x635b('0x1b')][_0x635b('0x1c')](_0xad36f6[_0x635b('0x1d')],{'raw':_0xad36f6[_0x635b('0x1e')]?_0xad36f6['options'][_0x635b('0x1f')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xad36f6['options']?_0xad36f6[_0x635b('0x1e')][_0x635b('0x20')]||null:null,'attributes':_0xad36f6[_0x635b('0x1e')]?_0xad36f6['options'][_0x635b('0x21')]||null:null,'limit':_0xad36f6['options']?_0xad36f6[_0x635b('0x1e')][_0x635b('0x22')]||null:null})[_0x635b('0x10')](function(_0x8265fc){logger['info'](_0x635b('0x1a'),_0xad36f6);logger['debug'](_0x635b('0x1a'),_0xad36f6,JSON[_0x635b('0x23')](_0x8265fc));_0x3c71c9(_0x8265fc);})[_0x635b('0x19')](function(_0x252189){logger[_0x635b('0x15')](_0x635b('0x1a'),_0x252189[_0x635b('0x17')],_0xad36f6);_0x1b5831(_0x249e77[_0x635b('0x15')](0x1f4,_0x252189[_0x635b('0x17')]));});});};exports[_0x635b('0x24')]=function(_0x311971){return new Promise(function(_0x4640dc,_0x20934b){return db[_0x635b('0x1b')]['find']({'where':_0x311971[_0x635b('0x1e')]?_0x311971[_0x635b('0x1e')][_0x635b('0x20')]||null:null})[_0x635b('0x10')](function(_0x26c525){if(_0x26c525){return _0x26c525[_0x635b('0x25')](_0x311971['body'][_0x635b('0x26')],_[_0x635b('0x27')](_0x311971[_0x635b('0x1d')],[_0x635b('0x26'),'id'])||{});}})[_0x635b('0x28')](function(_0xccc3a1){logger['info'](_0x635b('0x29'),_0x311971);logger['debug'](_0x635b('0x29'),_0x311971,JSON['stringify'](_0xccc3a1));_0x4640dc(_0xccc3a1);})[_0x635b('0x19')](function(_0x18a6b){logger[_0x635b('0x15')](_0x635b('0x29'),_0x18a6b[_0x635b('0x17')],_0x311971);_0x20934b(_this[_0x635b('0x15')](0x1f4,_0x18a6b[_0x635b('0x17')]));});});};