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 _0xcc3e=['redis','localhost','socket.io-emitter','./openchannelInteraction.socket','register','then','info','OpenchannelInteraction,\x20%s,\x20%s','request\x20sent','debug','OpenchannelInteraction,\x20%s,\x20%s,\x20%s','stringify','error','message','result','OpenchannelInteraction','update','body','options','raw','where','UpdateOpenchannelInteraction','catch','find','addTags','ids','spread','AddTags','lodash','util','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','defaults'];(function(_0x3c9c00,_0x38904f){var _0xd9b3d=function(_0x5b681e){while(--_0x5b681e){_0x3c9c00['push'](_0x3c9c00['shift']());}};_0xd9b3d(++_0x38904f);}(_0xcc3e,0x14c));var _0xecc3=function(_0x5ab67b,_0x4842d9){_0x5ab67b=_0x5ab67b-0x0;var _0x31d050=_0xcc3e[_0x5ab67b];return _0x31d050;};'use strict';var _=require(_0xecc3('0x0'));var util=require(_0xecc3('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xecc3('0x2'));var db=require('../../mysqldb')['db'];var utils=require(_0xecc3('0x3'));var logger=require(_0xecc3('0x4'))(_0xecc3('0x5'));var config=require(_0xecc3('0x6'));var jayson=require(_0xecc3('0x7'));var client=jayson[_0xecc3('0x8')]['http']({'port':0x232a});config['redis']=_[_0xecc3('0x9')](config[_0xecc3('0xa')],{'host':_0xecc3('0xb'),'port':0x18eb});var socket=require(_0xecc3('0xc'))(new Redis(config[_0xecc3('0xa')]));require(_0xecc3('0xd'))[_0xecc3('0xe')](socket);function respondWithRpcPromise(_0x208720,_0x1a9475,_0x29d8ed){return new BPromise(function(_0x431c8a,_0x291cf5){return client['request'](_0x208720,_0x29d8ed)[_0xecc3('0xf')](function(_0x325ac4){logger[_0xecc3('0x10')](_0xecc3('0x11'),_0x1a9475,_0xecc3('0x12'));logger[_0xecc3('0x13')](_0xecc3('0x14'),_0x1a9475,_0xecc3('0x12'),JSON[_0xecc3('0x15')](_0x325ac4));if(_0x325ac4[_0xecc3('0x16')]){if(_0x325ac4[_0xecc3('0x16')]['code']===0x1f4){logger[_0xecc3('0x16')]('OpenchannelInteraction,\x20%s,\x20%s',_0x1a9475,_0x325ac4[_0xecc3('0x16')][_0xecc3('0x17')]);return _0x291cf5(_0x325ac4[_0xecc3('0x16')]['message']);}logger['error']('OpenchannelInteraction,\x20%s,\x20%s',_0x1a9475,_0x325ac4['error'][_0xecc3('0x17')]);return _0x431c8a(_0x325ac4[_0xecc3('0x16')][_0xecc3('0x17')]);}else{logger[_0xecc3('0x10')]('OpenchannelInteraction,\x20%s,\x20%s',_0x1a9475,_0xecc3('0x12'));_0x431c8a(_0x325ac4[_0xecc3('0x18')][_0xecc3('0x17')]);}})['catch'](function(_0x2afa53){logger[_0xecc3('0x16')]('OpenchannelInteraction,\x20%s,\x20%s',_0x1a9475,_0x2afa53);_0x291cf5(_0x2afa53);});});}exports['UpdateOpenchannelInteraction']=function(_0x3d79c1){var _0xe30d4a=this;return new Promise(function(_0x5da3fb,_0x3aaa10){return db[_0xecc3('0x19')][_0xecc3('0x1a')](_0x3d79c1[_0xecc3('0x1b')],{'raw':_0x3d79c1[_0xecc3('0x1c')]?_0x3d79c1[_0xecc3('0x1c')][_0xecc3('0x1d')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3d79c1[_0xecc3('0x1c')]?_0x3d79c1[_0xecc3('0x1c')][_0xecc3('0x1e')]||null:null,'attributes':_0x3d79c1['options']?_0x3d79c1[_0xecc3('0x1c')]['attributes']||null:null,'limit':_0x3d79c1[_0xecc3('0x1c')]?_0x3d79c1[_0xecc3('0x1c')]['limit']||null:null})[_0xecc3('0xf')](function(_0x395361){logger[_0xecc3('0x10')](_0xecc3('0x1f'),_0x3d79c1);logger[_0xecc3('0x13')]('UpdateOpenchannelInteraction',_0x3d79c1,JSON['stringify'](_0x395361));_0x5da3fb(_0x395361);})[_0xecc3('0x20')](function(_0x311e94){logger[_0xecc3('0x16')]('UpdateOpenchannelInteraction',_0x311e94[_0xecc3('0x17')],_0x3d79c1);_0x3aaa10(_0xe30d4a['error'](0x1f4,_0x311e94[_0xecc3('0x17')]));});});};exports['AddTagsToOpenchannelInteraction']=function(_0x35717b){return new Promise(function(_0x5a61c1,_0x3e4aec){return db[_0xecc3('0x19')][_0xecc3('0x21')]({'where':_0x35717b[_0xecc3('0x1c')]?_0x35717b[_0xecc3('0x1c')][_0xecc3('0x1e')]||null:null})['then'](function(_0x237865){if(_0x237865){return _0x237865[_0xecc3('0x22')](_0x35717b[_0xecc3('0x1b')][_0xecc3('0x23')],_['omit'](_0x35717b[_0xecc3('0x1b')],[_0xecc3('0x23'),'id'])||{});}})[_0xecc3('0x24')](function(_0xddb80c){logger[_0xecc3('0x10')](_0xecc3('0x25'),_0x35717b);logger[_0xecc3('0x13')]('AddTags',_0x35717b,JSON['stringify'](_0xddb80c));_0x5a61c1(_0xddb80c);})[_0xecc3('0x20')](function(_0x27b330){logger['error'](_0xecc3('0x25'),_0x27b330[_0xecc3('0x17')],_0x35717b);_0x3e4aec(_this[_0xecc3('0x16')](0x1f4,_0x27b330['message']));});});};