Built motion from commit 3d3e98f2.|2.6.29
[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 _0x769a=['http','redis','localhost','./openchannelInteraction.socket','register','request','info','request\x20sent','OpenchannelInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code','OpenchannelInteraction,\x20%s,\x20%s','message','result','catch','UpdateOpenchannelInteraction','OpenchannelInteraction','update','body','options','attributes','limit','then','debug','find','where','addTags','ids','omit','spread','AddTags','lodash','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client'];(function(_0x235f7c,_0x1782b2){var _0x172576=function(_0x376a13){while(--_0x376a13){_0x235f7c['push'](_0x235f7c['shift']());}};_0x172576(++_0x1782b2);}(_0x769a,0x76));var _0xa769=function(_0x10d670,_0x178996){_0x10d670=_0x10d670-0x0;var _0x20d6f8=_0x769a[_0x10d670];return _0x20d6f8;};'use strict';var _=require(_0xa769('0x0'));var util=require('util');var moment=require(_0xa769('0x1'));var BPromise=require(_0xa769('0x2'));var rs=require(_0xa769('0x3'));var fs=require('fs');var Redis=require(_0xa769('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xa769('0x5'));var logger=require(_0xa769('0x6'))(_0xa769('0x7'));var config=require(_0xa769('0x8'));var jayson=require(_0xa769('0x9'));var client=jayson[_0xa769('0xa')][_0xa769('0xb')]({'port':0x232a});config['redis']=_['defaults'](config[_0xa769('0xc')],{'host':_0xa769('0xd'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xa769('0xc')]));require(_0xa769('0xe'))[_0xa769('0xf')](socket);function respondWithRpcPromise(_0x16bd77,_0x41e716,_0x580137){return new BPromise(function(_0x564460,_0x4bd8ee){return client[_0xa769('0x10')](_0x16bd77,_0x580137)['then'](function(_0x286900){logger[_0xa769('0x11')]('OpenchannelInteraction,\x20%s,\x20%s',_0x41e716,_0xa769('0x12'));logger['debug'](_0xa769('0x13'),_0x41e716,_0xa769('0x12'),JSON[_0xa769('0x14')](_0x286900));if(_0x286900[_0xa769('0x15')]){if(_0x286900[_0xa769('0x15')][_0xa769('0x16')]===0x1f4){logger[_0xa769('0x15')](_0xa769('0x17'),_0x41e716,_0x286900[_0xa769('0x15')]['message']);return _0x4bd8ee(_0x286900[_0xa769('0x15')][_0xa769('0x18')]);}logger[_0xa769('0x15')](_0xa769('0x17'),_0x41e716,_0x286900[_0xa769('0x15')][_0xa769('0x18')]);return _0x564460(_0x286900['error']['message']);}else{logger[_0xa769('0x11')](_0xa769('0x17'),_0x41e716,_0xa769('0x12'));_0x564460(_0x286900[_0xa769('0x19')][_0xa769('0x18')]);}})[_0xa769('0x1a')](function(_0x436705){logger[_0xa769('0x15')]('OpenchannelInteraction,\x20%s,\x20%s',_0x41e716,_0x436705);_0x4bd8ee(_0x436705);});});}exports[_0xa769('0x1b')]=function(_0x1bc695){var _0x45a616=this;return new Promise(function(_0xe18dd9,_0x2b14d3){return db[_0xa769('0x1c')][_0xa769('0x1d')](_0x1bc695[_0xa769('0x1e')],{'raw':_0x1bc695[_0xa769('0x1f')]?_0x1bc695['options']['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1bc695[_0xa769('0x1f')]?_0x1bc695[_0xa769('0x1f')]['where']||null:null,'attributes':_0x1bc695[_0xa769('0x1f')]?_0x1bc695['options'][_0xa769('0x20')]||null:null,'limit':_0x1bc695[_0xa769('0x1f')]?_0x1bc695['options'][_0xa769('0x21')]||null:null})[_0xa769('0x22')](function(_0x1fd510){logger['info'](_0xa769('0x1b'),_0x1bc695);logger[_0xa769('0x23')](_0xa769('0x1b'),_0x1bc695,JSON['stringify'](_0x1fd510));_0xe18dd9(_0x1fd510);})[_0xa769('0x1a')](function(_0x8bc257){logger[_0xa769('0x15')](_0xa769('0x1b'),_0x8bc257[_0xa769('0x18')],_0x1bc695);_0x2b14d3(_0x45a616[_0xa769('0x15')](0x1f4,_0x8bc257[_0xa769('0x18')]));});});};exports['AddTagsToOpenchannelInteraction']=function(_0x42e4e5){return new Promise(function(_0x281eba,_0x59fa12){return db[_0xa769('0x1c')][_0xa769('0x24')]({'where':_0x42e4e5[_0xa769('0x1f')]?_0x42e4e5[_0xa769('0x1f')][_0xa769('0x25')]||null:null})[_0xa769('0x22')](function(_0x92313b){if(_0x92313b){return _0x92313b[_0xa769('0x26')](_0x42e4e5[_0xa769('0x1e')][_0xa769('0x27')],_[_0xa769('0x28')](_0x42e4e5[_0xa769('0x1e')],[_0xa769('0x27'),'id'])||{});}})[_0xa769('0x29')](function(_0x3d82eb){logger['info'](_0xa769('0x2a'),_0x42e4e5);logger['debug'](_0xa769('0x2a'),_0x42e4e5,JSON['stringify'](_0x3d82eb));_0x281eba(_0x3d82eb);})[_0xa769('0x1a')](function(_0x3dadc2){logger[_0xa769('0x15')]('AddTags',_0x3dadc2[_0xa769('0x18')],_0x42e4e5);_0x59fa12(_this[_0xa769('0x15')](0x1f4,_0x3dadc2['message']));});});};