Built motion from commit 3c2ce842.|2.6.31
[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 _0x6487=['request\x20sent','stringify','code','error','message','result','UpdateOpenchannelInteraction','OpenchannelInteraction','update','body','options','raw','limit','AddTagsToOpenchannelInteraction','find','where','addTags','ids','omit','AddTags','lodash','util','moment','bluebird','randomstring','ioredis','../../config/logger','../../config/environment','jayson/promise','redis','localhost','socket.io-emitter','./openchannelInteraction.socket','register','request','then','info','OpenchannelInteraction,\x20%s,\x20%s','debug','OpenchannelInteraction,\x20%s,\x20%s,\x20%s'];(function(_0x74c1ee,_0x533e4f){var _0x43f6dc=function(_0x16a0b2){while(--_0x16a0b2){_0x74c1ee['push'](_0x74c1ee['shift']());}};_0x43f6dc(++_0x533e4f);}(_0x6487,0x1cc));var _0x7648=function(_0x3fc8f1,_0x5daafa){_0x3fc8f1=_0x3fc8f1-0x0;var _0x32779a=_0x6487[_0x3fc8f1];return _0x32779a;};'use strict';var _=require(_0x7648('0x0'));var util=require(_0x7648('0x1'));var moment=require(_0x7648('0x2'));var BPromise=require(_0x7648('0x3'));var rs=require(_0x7648('0x4'));var fs=require('fs');var Redis=require(_0x7648('0x5'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x7648('0x6'))('rpc');var config=require(_0x7648('0x7'));var jayson=require(_0x7648('0x8'));var client=jayson['client']['http']({'port':0x232a});config[_0x7648('0x9')]=_['defaults'](config['redis'],{'host':_0x7648('0xa'),'port':0x18eb});var socket=require(_0x7648('0xb'))(new Redis(config[_0x7648('0x9')]));require(_0x7648('0xc'))[_0x7648('0xd')](socket);function respondWithRpcPromise(_0x4293e6,_0x32988b,_0x1de1e3){return new BPromise(function(_0x37e253,_0x34fa29){return client[_0x7648('0xe')](_0x4293e6,_0x1de1e3)[_0x7648('0xf')](function(_0x3b1b66){logger[_0x7648('0x10')](_0x7648('0x11'),_0x32988b,'request\x20sent');logger[_0x7648('0x12')](_0x7648('0x13'),_0x32988b,_0x7648('0x14'),JSON[_0x7648('0x15')](_0x3b1b66));if(_0x3b1b66['error']){if(_0x3b1b66['error'][_0x7648('0x16')]===0x1f4){logger[_0x7648('0x17')](_0x7648('0x11'),_0x32988b,_0x3b1b66[_0x7648('0x17')][_0x7648('0x18')]);return _0x34fa29(_0x3b1b66[_0x7648('0x17')][_0x7648('0x18')]);}logger[_0x7648('0x17')](_0x7648('0x11'),_0x32988b,_0x3b1b66['error'][_0x7648('0x18')]);return _0x37e253(_0x3b1b66['error']['message']);}else{logger[_0x7648('0x10')](_0x7648('0x11'),_0x32988b,_0x7648('0x14'));_0x37e253(_0x3b1b66[_0x7648('0x19')][_0x7648('0x18')]);}})['catch'](function(_0x15bc72){logger[_0x7648('0x17')](_0x7648('0x11'),_0x32988b,_0x15bc72);_0x34fa29(_0x15bc72);});});}exports[_0x7648('0x1a')]=function(_0x20be79){var _0x30e402=this;return new Promise(function(_0x22b07e,_0x545284){return db[_0x7648('0x1b')][_0x7648('0x1c')](_0x20be79[_0x7648('0x1d')],{'raw':_0x20be79[_0x7648('0x1e')]?_0x20be79[_0x7648('0x1e')][_0x7648('0x1f')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x20be79['options']?_0x20be79[_0x7648('0x1e')]['where']||null:null,'attributes':_0x20be79[_0x7648('0x1e')]?_0x20be79[_0x7648('0x1e')]['attributes']||null:null,'limit':_0x20be79[_0x7648('0x1e')]?_0x20be79[_0x7648('0x1e')][_0x7648('0x20')]||null:null})[_0x7648('0xf')](function(_0x299d92){logger['info'](_0x7648('0x1a'),_0x20be79);logger['debug'](_0x7648('0x1a'),_0x20be79,JSON[_0x7648('0x15')](_0x299d92));_0x22b07e(_0x299d92);})['catch'](function(_0x3b9c59){logger[_0x7648('0x17')]('UpdateOpenchannelInteraction',_0x3b9c59[_0x7648('0x18')],_0x20be79);_0x545284(_0x30e402[_0x7648('0x17')](0x1f4,_0x3b9c59['message']));});});};exports[_0x7648('0x21')]=function(_0x8221d8){return new Promise(function(_0x3461e1,_0x1e107c){return db['OpenchannelInteraction'][_0x7648('0x22')]({'where':_0x8221d8[_0x7648('0x1e')]?_0x8221d8[_0x7648('0x1e')][_0x7648('0x23')]||null:null})[_0x7648('0xf')](function(_0x1d0b7e){if(_0x1d0b7e){return _0x1d0b7e[_0x7648('0x24')](_0x8221d8['body'][_0x7648('0x25')],_[_0x7648('0x26')](_0x8221d8[_0x7648('0x1d')],[_0x7648('0x25'),'id'])||{});}})['spread'](function(_0x23ae2d){logger[_0x7648('0x10')]('AddTags',_0x8221d8);logger[_0x7648('0x12')](_0x7648('0x27'),_0x8221d8,JSON[_0x7648('0x15')](_0x23ae2d));_0x3461e1(_0x23ae2d);})['catch'](function(_0x2e471d){logger[_0x7648('0x17')](_0x7648('0x27'),_0x2e471d[_0x7648('0x18')],_0x8221d8);_0x1e107c(_this['error'](0x1f4,_0x2e471d[_0x7648('0x18')]));});});};