ed780eb82a88fd5b62c692a0c1338c1f815049a8
[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 _0x214f=['defaults','localhost','socket.io-emitter','register','then','info','OpenchannelInteraction,\x20%s,\x20%s','request\x20sent','OpenchannelInteraction,\x20%s,\x20%s,\x20%s','stringify','code','error','message','result','catch','UpdateOpenchannelInteraction','OpenchannelInteraction','body','options','raw','where','debug','AddTagsToOpenchannelInteraction','find','addTags','ids','omit','spread','AddTags','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','http','redis'];(function(_0x8a969d,_0x339d9f){var _0x1d8dc7=function(_0x283ec0){while(--_0x283ec0){_0x8a969d['push'](_0x8a969d['shift']());}};_0x1d8dc7(++_0x339d9f);}(_0x214f,0x6f));var _0xf214=function(_0x2a911f,_0x79ee44){_0x2a911f=_0x2a911f-0x0;var _0x4eafde=_0x214f[_0x2a911f];return _0x4eafde;};'use strict';var _=require('lodash');var util=require(_0xf214('0x0'));var moment=require(_0xf214('0x1'));var BPromise=require(_0xf214('0x2'));var rs=require(_0xf214('0x3'));var fs=require('fs');var Redis=require(_0xf214('0x4'));var db=require(_0xf214('0x5'))['db'];var utils=require(_0xf214('0x6'));var logger=require(_0xf214('0x7'))(_0xf214('0x8'));var config=require('../../config/environment');var jayson=require(_0xf214('0x9'));var client=jayson['client'][_0xf214('0xa')]({'port':0x232a});config[_0xf214('0xb')]=_[_0xf214('0xc')](config['redis'],{'host':_0xf214('0xd'),'port':0x18eb});var socket=require(_0xf214('0xe'))(new Redis(config[_0xf214('0xb')]));require('./openchannelInteraction.socket')[_0xf214('0xf')](socket);function respondWithRpcPromise(_0x1a8cbe,_0x129627,_0x5960f2){return new BPromise(function(_0x63f600,_0x4fc071){return client['request'](_0x1a8cbe,_0x5960f2)[_0xf214('0x10')](function(_0x1ce233){logger[_0xf214('0x11')](_0xf214('0x12'),_0x129627,_0xf214('0x13'));logger['debug'](_0xf214('0x14'),_0x129627,_0xf214('0x13'),JSON[_0xf214('0x15')](_0x1ce233));if(_0x1ce233['error']){if(_0x1ce233['error'][_0xf214('0x16')]===0x1f4){logger[_0xf214('0x17')](_0xf214('0x12'),_0x129627,_0x1ce233[_0xf214('0x17')][_0xf214('0x18')]);return _0x4fc071(_0x1ce233[_0xf214('0x17')][_0xf214('0x18')]);}logger[_0xf214('0x17')](_0xf214('0x12'),_0x129627,_0x1ce233['error'][_0xf214('0x18')]);return _0x63f600(_0x1ce233[_0xf214('0x17')][_0xf214('0x18')]);}else{logger[_0xf214('0x11')](_0xf214('0x12'),_0x129627,'request\x20sent');_0x63f600(_0x1ce233[_0xf214('0x19')]['message']);}})[_0xf214('0x1a')](function(_0x5834d4){logger[_0xf214('0x17')](_0xf214('0x12'),_0x129627,_0x5834d4);_0x4fc071(_0x5834d4);});});}exports[_0xf214('0x1b')]=function(_0x193b5d){var _0x56b2f9=this;return new Promise(function(_0x4ce6a1,_0x16a30c){return db[_0xf214('0x1c')]['update'](_0x193b5d[_0xf214('0x1d')],{'raw':_0x193b5d[_0xf214('0x1e')]?_0x193b5d[_0xf214('0x1e')][_0xf214('0x1f')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x193b5d[_0xf214('0x1e')]?_0x193b5d[_0xf214('0x1e')][_0xf214('0x20')]||null:null,'attributes':_0x193b5d[_0xf214('0x1e')]?_0x193b5d['options']['attributes']||null:null,'limit':_0x193b5d[_0xf214('0x1e')]?_0x193b5d[_0xf214('0x1e')]['limit']||null:null})[_0xf214('0x10')](function(_0x2b476e){logger[_0xf214('0x11')]('UpdateOpenchannelInteraction',_0x193b5d);logger[_0xf214('0x21')](_0xf214('0x1b'),_0x193b5d,JSON[_0xf214('0x15')](_0x2b476e));_0x4ce6a1(_0x2b476e);})[_0xf214('0x1a')](function(_0x31d56c){logger[_0xf214('0x17')]('UpdateOpenchannelInteraction',_0x31d56c[_0xf214('0x18')],_0x193b5d);_0x16a30c(_0x56b2f9[_0xf214('0x17')](0x1f4,_0x31d56c[_0xf214('0x18')]));});});};exports[_0xf214('0x22')]=function(_0x1d4f1f){return new Promise(function(_0x416b2c,_0x2f3c2c){return db[_0xf214('0x1c')][_0xf214('0x23')]({'where':_0x1d4f1f[_0xf214('0x1e')]?_0x1d4f1f['options'][_0xf214('0x20')]||null:null})[_0xf214('0x10')](function(_0x174413){if(_0x174413){return _0x174413[_0xf214('0x24')](_0x1d4f1f[_0xf214('0x1d')][_0xf214('0x25')],_[_0xf214('0x26')](_0x1d4f1f[_0xf214('0x1d')],[_0xf214('0x25'),'id'])||{});}})[_0xf214('0x27')](function(_0x5d0fbd){logger[_0xf214('0x11')](_0xf214('0x28'),_0x1d4f1f);logger[_0xf214('0x21')](_0xf214('0x28'),_0x1d4f1f,JSON['stringify'](_0x5d0fbd));_0x416b2c(_0x5d0fbd);})[_0xf214('0x1a')](function(_0x1e357c){logger[_0xf214('0x17')]('AddTags',_0x1e357c['message'],_0x1d4f1f);_0x2f3c2c(_this['error'](0x1f4,_0x1e357c[_0xf214('0x18')]));});});};