Built motion from commit (unavailable).|2.5.4
[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 _0xd171=['stringify','error','code','message','info','catch','body','options','UpdateOpenchannelInteraction','OpenchannelInteraction','find','addTags','ids','omit','AddTags','lodash','util','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','defaults','redis','localhost','socket.io-emitter','./openchannelInteraction.socket','request','then','OpenchannelInteraction,\x20%s,\x20%s','request\x20sent','debug','OpenchannelInteraction,\x20%s,\x20%s,\x20%s'];(function(_0x5e24e4,_0x452216){var _0xf9243e=function(_0x455625){while(--_0x455625){_0x5e24e4['push'](_0x5e24e4['shift']());}};_0xf9243e(++_0x452216);}(_0xd171,0xa3));var _0x1d17=function(_0x5f170f,_0x553d8e){_0x5f170f=_0x5f170f-0x0;var _0x2419de=_0xd171[_0x5f170f];return _0x2419de;};'use strict';var _=require(_0x1d17('0x0'));var util=require(_0x1d17('0x1'));var moment=require(_0x1d17('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x1d17('0x3'));var db=require(_0x1d17('0x4'))['db'];var utils=require(_0x1d17('0x5'));var logger=require(_0x1d17('0x6'))(_0x1d17('0x7'));var config=require(_0x1d17('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x1d17('0x9')][_0x1d17('0xa')]({'port':0x232a});config['redis']=_[_0x1d17('0xb')](config[_0x1d17('0xc')],{'host':_0x1d17('0xd'),'port':0x18eb});var socket=require(_0x1d17('0xe'))(new Redis(config[_0x1d17('0xc')]));require(_0x1d17('0xf'))['register'](socket);function respondWithRpcPromise(_0x27138b,_0x342094,_0x312f5b){return new BPromise(function(_0x1eda27,_0x6fe1fa){return client[_0x1d17('0x10')](_0x27138b,_0x312f5b)[_0x1d17('0x11')](function(_0x5c950a){logger['info'](_0x1d17('0x12'),_0x342094,_0x1d17('0x13'));logger[_0x1d17('0x14')](_0x1d17('0x15'),_0x342094,_0x1d17('0x13'),JSON[_0x1d17('0x16')](_0x5c950a));if(_0x5c950a[_0x1d17('0x17')]){if(_0x5c950a['error'][_0x1d17('0x18')]===0x1f4){logger[_0x1d17('0x17')](_0x1d17('0x12'),_0x342094,_0x5c950a['error'][_0x1d17('0x19')]);return _0x6fe1fa(_0x5c950a[_0x1d17('0x17')][_0x1d17('0x19')]);}logger[_0x1d17('0x17')](_0x1d17('0x12'),_0x342094,_0x5c950a[_0x1d17('0x17')][_0x1d17('0x19')]);return _0x1eda27(_0x5c950a[_0x1d17('0x17')][_0x1d17('0x19')]);}else{logger[_0x1d17('0x1a')](_0x1d17('0x12'),_0x342094,_0x1d17('0x13'));_0x1eda27(_0x5c950a['result'][_0x1d17('0x19')]);}})[_0x1d17('0x1b')](function(_0x34ffb5){logger[_0x1d17('0x17')](_0x1d17('0x12'),_0x342094,_0x34ffb5);_0x6fe1fa(_0x34ffb5);});});}exports['UpdateOpenchannelInteraction']=function(_0x5e64d2){var _0x549333=this;return new Promise(function(_0x1188d2,_0x29eca5){return db['OpenchannelInteraction']['update'](_0x5e64d2[_0x1d17('0x1c')],{'raw':_0x5e64d2[_0x1d17('0x1d')]?_0x5e64d2[_0x1d17('0x1d')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x5e64d2[_0x1d17('0x1d')]?_0x5e64d2[_0x1d17('0x1d')]['where']||null:null,'attributes':_0x5e64d2[_0x1d17('0x1d')]?_0x5e64d2['options']['attributes']||null:null,'limit':_0x5e64d2[_0x1d17('0x1d')]?_0x5e64d2[_0x1d17('0x1d')]['limit']||null:null})[_0x1d17('0x11')](function(_0x5716fd){logger[_0x1d17('0x1a')](_0x1d17('0x1e'),_0x5e64d2);logger[_0x1d17('0x14')](_0x1d17('0x1e'),_0x5e64d2,JSON[_0x1d17('0x16')](_0x5716fd));_0x1188d2(_0x5716fd);})[_0x1d17('0x1b')](function(_0x50e797){logger[_0x1d17('0x17')](_0x1d17('0x1e'),_0x50e797['message'],_0x5e64d2);_0x29eca5(_0x549333['error'](0x1f4,_0x50e797[_0x1d17('0x19')]));});});};exports['AddTagsToOpenchannelInteraction']=function(_0x32d8d0){return new Promise(function(_0x135b1c,_0x242387){return db[_0x1d17('0x1f')][_0x1d17('0x20')]({'where':_0x32d8d0[_0x1d17('0x1d')]?_0x32d8d0['options']['where']||null:null})[_0x1d17('0x11')](function(_0x25ee2c){if(_0x25ee2c){return _0x25ee2c[_0x1d17('0x21')](_0x32d8d0['body'][_0x1d17('0x22')],_[_0x1d17('0x23')](_0x32d8d0[_0x1d17('0x1c')],[_0x1d17('0x22'),'id'])||{});}})['spread'](function(_0x4bf240){logger[_0x1d17('0x1a')]('AddTags',_0x32d8d0);logger['debug']('AddTags',_0x32d8d0,JSON['stringify'](_0x4bf240));_0x135b1c(_0x4bf240);})['catch'](function(_0x5907aa){logger[_0x1d17('0x17')](_0x1d17('0x24'),_0x5907aa['message'],_0x32d8d0);_0x242387(_this['error'](0x1f4,_0x5907aa[_0x1d17('0x19')]));});});};