918ce8085e2c48748d2216eaa583888c9de601d3
[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 _0xcc24=['message','result','catch','UpdateOpenchannelInteraction','OpenchannelInteraction','update','body','options','raw','attributes','limit','debug','stringify','AddTagsToOpenchannelInteraction','find','where','ids','spread','AddTags','lodash','util','moment','bluebird','randomstring','ioredis','../../config/logger','rpc','../../config/environment','jayson/promise','http','redis','defaults','localhost','socket.io-emitter','register','request','then','info','OpenchannelInteraction,\x20%s,\x20%s','request\x20sent','OpenchannelInteraction,\x20%s,\x20%s,\x20%s','error'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xcc24,0x91));var _0x4cc2=function(_0x4caaa0,_0x4b578e){_0x4caaa0=_0x4caaa0-0x0;var _0x544dda=_0xcc24[_0x4caaa0];return _0x544dda;};'use strict';var _=require(_0x4cc2('0x0'));var util=require(_0x4cc2('0x1'));var moment=require(_0x4cc2('0x2'));var BPromise=require(_0x4cc2('0x3'));var rs=require(_0x4cc2('0x4'));var fs=require('fs');var Redis=require(_0x4cc2('0x5'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x4cc2('0x6'))(_0x4cc2('0x7'));var config=require(_0x4cc2('0x8'));var jayson=require(_0x4cc2('0x9'));var client=jayson['client'][_0x4cc2('0xa')]({'port':0x232a});config[_0x4cc2('0xb')]=_[_0x4cc2('0xc')](config['redis'],{'host':_0x4cc2('0xd'),'port':0x18eb});var socket=require(_0x4cc2('0xe'))(new Redis(config[_0x4cc2('0xb')]));require('./openchannelInteraction.socket')[_0x4cc2('0xf')](socket);function respondWithRpcPromise(_0x5812ac,_0x2f0b8a,_0xc61915){return new BPromise(function(_0x4511f5,_0x1c8f49){return client[_0x4cc2('0x10')](_0x5812ac,_0xc61915)[_0x4cc2('0x11')](function(_0x2bc4c0){logger[_0x4cc2('0x12')](_0x4cc2('0x13'),_0x2f0b8a,_0x4cc2('0x14'));logger['debug'](_0x4cc2('0x15'),_0x2f0b8a,_0x4cc2('0x14'),JSON['stringify'](_0x2bc4c0));if(_0x2bc4c0['error']){if(_0x2bc4c0[_0x4cc2('0x16')]['code']===0x1f4){logger[_0x4cc2('0x16')](_0x4cc2('0x13'),_0x2f0b8a,_0x2bc4c0['error']['message']);return _0x1c8f49(_0x2bc4c0[_0x4cc2('0x16')][_0x4cc2('0x17')]);}logger[_0x4cc2('0x16')](_0x4cc2('0x13'),_0x2f0b8a,_0x2bc4c0['error'][_0x4cc2('0x17')]);return _0x4511f5(_0x2bc4c0[_0x4cc2('0x16')][_0x4cc2('0x17')]);}else{logger['info'](_0x4cc2('0x13'),_0x2f0b8a,'request\x20sent');_0x4511f5(_0x2bc4c0[_0x4cc2('0x18')]['message']);}})[_0x4cc2('0x19')](function(_0x3cf9a8){logger[_0x4cc2('0x16')](_0x4cc2('0x13'),_0x2f0b8a,_0x3cf9a8);_0x1c8f49(_0x3cf9a8);});});}exports[_0x4cc2('0x1a')]=function(_0x5da9ab){var _0x1e8ee1=this;return new Promise(function(_0x20c600,_0x45fa2b){return db[_0x4cc2('0x1b')][_0x4cc2('0x1c')](_0x5da9ab[_0x4cc2('0x1d')],{'raw':_0x5da9ab[_0x4cc2('0x1e')]?_0x5da9ab['options'][_0x4cc2('0x1f')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x5da9ab[_0x4cc2('0x1e')]?_0x5da9ab['options']['where']||null:null,'attributes':_0x5da9ab['options']?_0x5da9ab[_0x4cc2('0x1e')][_0x4cc2('0x20')]||null:null,'limit':_0x5da9ab[_0x4cc2('0x1e')]?_0x5da9ab[_0x4cc2('0x1e')][_0x4cc2('0x21')]||null:null})[_0x4cc2('0x11')](function(_0x224b4a){logger[_0x4cc2('0x12')](_0x4cc2('0x1a'),_0x5da9ab);logger[_0x4cc2('0x22')](_0x4cc2('0x1a'),_0x5da9ab,JSON[_0x4cc2('0x23')](_0x224b4a));_0x20c600(_0x224b4a);})['catch'](function(_0x101f17){logger[_0x4cc2('0x16')](_0x4cc2('0x1a'),_0x101f17['message'],_0x5da9ab);_0x45fa2b(_0x1e8ee1['error'](0x1f4,_0x101f17['message']));});});};exports[_0x4cc2('0x24')]=function(_0x4f8ea5){return new Promise(function(_0x5eda5f,_0x367d07){return db[_0x4cc2('0x1b')][_0x4cc2('0x25')]({'where':_0x4f8ea5[_0x4cc2('0x1e')]?_0x4f8ea5[_0x4cc2('0x1e')][_0x4cc2('0x26')]||null:null})[_0x4cc2('0x11')](function(_0x4482c6){if(_0x4482c6){return _0x4482c6['addTags'](_0x4f8ea5[_0x4cc2('0x1d')][_0x4cc2('0x27')],_['omit'](_0x4f8ea5['body'],[_0x4cc2('0x27'),'id'])||{});}})[_0x4cc2('0x28')](function(_0x5c73f6){logger[_0x4cc2('0x12')](_0x4cc2('0x29'),_0x4f8ea5);logger['debug'](_0x4cc2('0x29'),_0x4f8ea5,JSON['stringify'](_0x5c73f6));_0x5eda5f(_0x5c73f6);})[_0x4cc2('0x19')](function(_0x17de5b){logger[_0x4cc2('0x16')]('AddTags',_0x17de5b[_0x4cc2('0x17')],_0x4f8ea5);_0x367d07(_this['error'](0x1f4,_0x17de5b[_0x4cc2('0x17')]));});});};