916bbe6c1df3e72b9e4d6372f7af583973ef87e5
[motion2.git] / server / api / jira / jira.controller.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 _0xa299=['description','stringify','Bug','fields','email','customfield_11501','newToken','customfield_11503','name','customfield_11504','reason','customfield_10102','track.xcallymotion.com','/rest/api/2/issue','application/json','Basic\x20','toString','request','utf8','data','statusCode','parse','error','json','Error\x20during\x20license\x20request.\x20Please\x20contact\x20our\x20license\x20team\x20at\x20license@xcally.com\x20with\x20your\x20request','api.jira','write','end','openIssue','body','x-forwarded-for','connection','remoteAddress','socket','bluebird','api','3eAmWpBVP0','key','MOTGUI','summary','Report','\x20from\x20'];(function(_0x246354,_0x4b1a61){var _0x554ea3=function(_0x20c691){while(--_0x20c691){_0x246354['push'](_0x246354['shift']());}};_0x554ea3(++_0x4b1a61);}(_0xa299,0x11e));var _0x9a29=function(_0x46260a,_0x377e4a){_0x46260a=_0x46260a-0x0;var _0x347857=_0xa299[_0x46260a];return _0x347857;};'use strict';var BPromise=require(_0x9a29('0x0'));var https=require('https');var logger=require('../../config/logger')(_0x9a29('0x1'));var USERNAME='support';var PASSWORD=_0x9a29('0x2');function openIssue(_0x49e897,_0x2cdb08){var _0x48a7cf={'fields':{'project':{'key':_0x49e897[_0x9a29('0x3')]||_0x9a29('0x4')},'summary':(_0x49e897[_0x9a29('0x5')]||_0x9a29('0x6'))+_0x9a29('0x7')+_0x49e897['ip'],'description':_0x49e897[_0x9a29('0x8')]||JSON[_0x9a29('0x9')](_0x49e897),'issuetype':{'name':_0x49e897['issuetype']||_0x9a29('0xa')}}};_0x48a7cf[_0x9a29('0xb')]['customfield_11500']=_0x49e897[_0x9a29('0xc')];_0x48a7cf['fields'][_0x9a29('0xd')]=_0x49e897['oldToken'];_0x48a7cf[_0x9a29('0xb')]['customfield_11502']=_0x49e897[_0x9a29('0xe')];_0x48a7cf['fields'][_0x9a29('0xf')]=_0x49e897[_0x9a29('0x10')];_0x48a7cf['fields'][_0x9a29('0x11')]=_0x49e897[_0x9a29('0x12')];_0x48a7cf[_0x9a29('0xb')][_0x9a29('0x13')]=_0x49e897['ip'];var _0x37145b={'host':_0x9a29('0x14'),'port':0x1bb,'path':_0x9a29('0x15'),'method':'POST','timeout':0x4e20,'headers':{'Content-Type':_0x9a29('0x16'),'Authorization':_0x9a29('0x17')+new Buffer(USERNAME+':'+PASSWORD)[_0x9a29('0x18')]('base64')}};var _0x3ce30f=JSON[_0x9a29('0x9')](_0x48a7cf);var _0x363319=https[_0x9a29('0x19')](_0x37145b,function(_0x4f2ee1){_0x4f2ee1['setEncoding'](_0x9a29('0x1a'));var _0x11bde='';_0x4f2ee1['on'](_0x9a29('0x1b'),function(_0x197b19){_0x11bde+=_0x197b19;});_0x4f2ee1['on']('end',function(){if(_0x2cdb08){return _0x2cdb08['status'](_0x4f2ee1[_0x9a29('0x1c')])['json'](JSON[_0x9a29('0x1d')](_0x11bde));}});});_0x363319['on'](_0x9a29('0x1e'),function(_0x23027d){if(_0x2cdb08){return _0x2cdb08['status'](0x1f4)[_0x9a29('0x1f')]({'errors':[{'message':_0x9a29('0x20'),'type':_0x9a29('0x21')}]});}});_0x363319[_0x9a29('0x22')](_0x3ce30f);_0x363319[_0x9a29('0x23')]();}exports[_0x9a29('0x24')]=openIssue;exports['send']=function(_0x61fcf6,_0x3c64e8){_0x61fcf6[_0x9a29('0x25')]['ip']=_0x61fcf6['headers'][_0x9a29('0x26')]||_0x61fcf6[_0x9a29('0x27')]['remoteAddress']||_0x61fcf6['socket'][_0x9a29('0x28')]||_0x61fcf6['connection'][_0x9a29('0x29')]['remoteAddress'];return openIssue(_0x61fcf6[_0x9a29('0x25')],_0x3c64e8);};