Built motion from commit (unavailable).|2.4.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 _0xb138=['update','options','raw','where','attributes','limit','stringify','catch','find','then','addTags','body','ids','omit','AddTags','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','client','http','defaults','redis','localhost','./openchannelInteraction.socket','request','info','OpenchannelInteraction,\x20%s,\x20%s','request\x20sent','debug','OpenchannelInteraction,\x20%s,\x20%s,\x20%s','error','message','result','UpdateOpenchannelInteraction','OpenchannelInteraction'];(function(_0x162246,_0x4e5038){var _0x32ac95=function(_0x22270b){while(--_0x22270b){_0x162246['push'](_0x162246['shift']());}};_0x32ac95(++_0x4e5038);}(_0xb138,0x1dd));var _0x8b13=function(_0x1224d6,_0x1edbb0){_0x1224d6=_0x1224d6-0x0;var _0x440f09=_0xb138[_0x1224d6];return _0x440f09;};'use strict';var _=require(_0x8b13('0x0'));var util=require(_0x8b13('0x1'));var moment=require(_0x8b13('0x2'));var BPromise=require(_0x8b13('0x3'));var rs=require(_0x8b13('0x4'));var fs=require('fs');var Redis=require(_0x8b13('0x5'));var db=require(_0x8b13('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0x8b13('0x7'))(_0x8b13('0x8'));var config=require(_0x8b13('0x9'));var jayson=require('jayson/promise');var client=jayson[_0x8b13('0xa')][_0x8b13('0xb')]({'port':0x232a});config['redis']=_[_0x8b13('0xc')](config[_0x8b13('0xd')],{'host':_0x8b13('0xe'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x8b13('0xd')]));require(_0x8b13('0xf'))['register'](socket);function respondWithRpcPromise(_0x53ae50,_0x1f2528,_0x21fcd9){return new BPromise(function(_0x13fbd1,_0x439451){return client[_0x8b13('0x10')](_0x53ae50,_0x21fcd9)['then'](function(_0x11bc89){logger[_0x8b13('0x11')](_0x8b13('0x12'),_0x1f2528,_0x8b13('0x13'));logger[_0x8b13('0x14')](_0x8b13('0x15'),_0x1f2528,'request\x20sent',JSON['stringify'](_0x11bc89));if(_0x11bc89[_0x8b13('0x16')]){if(_0x11bc89[_0x8b13('0x16')]['code']===0x1f4){logger['error']('OpenchannelInteraction,\x20%s,\x20%s',_0x1f2528,_0x11bc89[_0x8b13('0x16')][_0x8b13('0x17')]);return _0x439451(_0x11bc89[_0x8b13('0x16')][_0x8b13('0x17')]);}logger[_0x8b13('0x16')]('OpenchannelInteraction,\x20%s,\x20%s',_0x1f2528,_0x11bc89[_0x8b13('0x16')][_0x8b13('0x17')]);return _0x13fbd1(_0x11bc89[_0x8b13('0x16')][_0x8b13('0x17')]);}else{logger[_0x8b13('0x11')](_0x8b13('0x12'),_0x1f2528,_0x8b13('0x13'));_0x13fbd1(_0x11bc89[_0x8b13('0x18')]['message']);}})['catch'](function(_0xae4966){logger[_0x8b13('0x16')](_0x8b13('0x12'),_0x1f2528,_0xae4966);_0x439451(_0xae4966);});});}exports[_0x8b13('0x19')]=function(_0x1e0fe3){var _0x3cc9a0=this;return new Promise(function(_0x559442,_0x1e8a48){return db[_0x8b13('0x1a')][_0x8b13('0x1b')](_0x1e0fe3['body'],{'raw':_0x1e0fe3['options']?_0x1e0fe3[_0x8b13('0x1c')][_0x8b13('0x1d')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1e0fe3['options']?_0x1e0fe3[_0x8b13('0x1c')][_0x8b13('0x1e')]||null:null,'attributes':_0x1e0fe3[_0x8b13('0x1c')]?_0x1e0fe3[_0x8b13('0x1c')][_0x8b13('0x1f')]||null:null,'limit':_0x1e0fe3['options']?_0x1e0fe3[_0x8b13('0x1c')][_0x8b13('0x20')]||null:null})['then'](function(_0x33422f){logger['info'](_0x8b13('0x19'),_0x1e0fe3);logger[_0x8b13('0x14')]('UpdateOpenchannelInteraction',_0x1e0fe3,JSON[_0x8b13('0x21')](_0x33422f));_0x559442(_0x33422f);})[_0x8b13('0x22')](function(_0x4f8e58){logger[_0x8b13('0x16')](_0x8b13('0x19'),_0x4f8e58[_0x8b13('0x17')],_0x1e0fe3);_0x1e8a48(_0x3cc9a0[_0x8b13('0x16')](0x1f4,_0x4f8e58[_0x8b13('0x17')]));});});};exports['AddTagsToOpenchannelInteraction']=function(_0x6023f5){return new Promise(function(_0x1b09e2,_0x3475d8){return db[_0x8b13('0x1a')][_0x8b13('0x23')]({'where':_0x6023f5[_0x8b13('0x1c')]?_0x6023f5['options'][_0x8b13('0x1e')]||null:null})[_0x8b13('0x24')](function(_0x109f0e){if(_0x109f0e){return _0x109f0e[_0x8b13('0x25')](_0x6023f5[_0x8b13('0x26')][_0x8b13('0x27')],_[_0x8b13('0x28')](_0x6023f5[_0x8b13('0x26')],[_0x8b13('0x27'),'id'])||{});}})['spread'](function(_0x14cc2e){logger[_0x8b13('0x11')](_0x8b13('0x29'),_0x6023f5);logger[_0x8b13('0x14')]('AddTags',_0x6023f5,JSON['stringify'](_0x14cc2e));_0x1b09e2(_0x14cc2e);})[_0x8b13('0x22')](function(_0x5cedea){logger['error'](_0x8b13('0x29'),_0x5cedea['message'],_0x6023f5);_0x3475d8(_this[_0x8b13('0x16')](0x1f4,_0x5cedea[_0x8b13('0x17')]));});});};