6fab6329a7689f4e6288fc0ca5ff28d641bfb74d
[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 _0x4df4=['application/json','Basic\x20','toString','request','setEncoding','utf8','status','statusCode','parse','error','Error\x20during\x20license\x20request.\x20Please\x20contact\x20our\x20license\x20team\x20at\x20license@xcally.com\x20with\x20your\x20request','api.jira','write','openIssue','send','headers','x-forwarded-for','remoteAddress','connection','bluebird','../../config/logger','api','3eAmWpBVP0','MOTGUI','summary','\x20from\x20','description','stringify','issuetype','Bug','fields','customfield_11500','email','customfield_11501','oldToken','newToken','customfield_11503','name','customfield_11504','reason','customfield_10102','track.xcallymotion.com','/rest/api/2/issue'];(function(_0xd8658f,_0x21b8b5){var _0x464b5a=function(_0x413ed1){while(--_0x413ed1){_0xd8658f['push'](_0xd8658f['shift']());}};_0x464b5a(++_0x21b8b5);}(_0x4df4,0xbf));var _0x44df=function(_0x12e073,_0x4d43db){_0x12e073=_0x12e073-0x0;var _0x267748=_0x4df4[_0x12e073];return _0x267748;};'use strict';var BPromise=require(_0x44df('0x0'));var https=require('https');var logger=require(_0x44df('0x1'))(_0x44df('0x2'));var USERNAME='support';var PASSWORD=_0x44df('0x3');function openIssue(_0xcbbb1a,_0x147a78){var _0x446f87={'fields':{'project':{'key':_0xcbbb1a['key']||_0x44df('0x4')},'summary':(_0xcbbb1a[_0x44df('0x5')]||'Report')+_0x44df('0x6')+_0xcbbb1a['ip'],'description':_0xcbbb1a[_0x44df('0x7')]||JSON[_0x44df('0x8')](_0xcbbb1a),'issuetype':{'name':_0xcbbb1a[_0x44df('0x9')]||_0x44df('0xa')}}};_0x446f87[_0x44df('0xb')][_0x44df('0xc')]=_0xcbbb1a[_0x44df('0xd')];_0x446f87[_0x44df('0xb')][_0x44df('0xe')]=_0xcbbb1a[_0x44df('0xf')];_0x446f87[_0x44df('0xb')]['customfield_11502']=_0xcbbb1a[_0x44df('0x10')];_0x446f87[_0x44df('0xb')][_0x44df('0x11')]=_0xcbbb1a[_0x44df('0x12')];_0x446f87[_0x44df('0xb')][_0x44df('0x13')]=_0xcbbb1a[_0x44df('0x14')];_0x446f87[_0x44df('0xb')][_0x44df('0x15')]=_0xcbbb1a['ip'];var _0x10c8de={'host':_0x44df('0x16'),'port':0x1bb,'path':_0x44df('0x17'),'method':'POST','timeout':0x4e20,'headers':{'Content-Type':_0x44df('0x18'),'Authorization':_0x44df('0x19')+new Buffer(USERNAME+':'+PASSWORD)[_0x44df('0x1a')]('base64')}};var _0x5a51b5=JSON['stringify'](_0x446f87);var _0x10fe18=https[_0x44df('0x1b')](_0x10c8de,function(_0x378e6e){_0x378e6e[_0x44df('0x1c')](_0x44df('0x1d'));var _0x504be5='';_0x378e6e['on']('data',function(_0x217194){_0x504be5+=_0x217194;});_0x378e6e['on']('end',function(){if(_0x147a78){return _0x147a78[_0x44df('0x1e')](_0x378e6e[_0x44df('0x1f')])['json'](JSON[_0x44df('0x20')](_0x504be5));}});});_0x10fe18['on'](_0x44df('0x21'),function(_0x2e6f9c){if(_0x147a78){return _0x147a78[_0x44df('0x1e')](0x1f4)['json']({'errors':[{'message':_0x44df('0x22'),'type':_0x44df('0x23')}]});}});_0x10fe18[_0x44df('0x24')](_0x5a51b5);_0x10fe18['end']();}exports[_0x44df('0x25')]=openIssue;exports[_0x44df('0x26')]=function(_0xa5fcc2,_0x442831){_0xa5fcc2['body']['ip']=_0xa5fcc2[_0x44df('0x27')][_0x44df('0x28')]||_0xa5fcc2['connection']['remoteAddress']||_0xa5fcc2['socket'][_0x44df('0x29')]||_0xa5fcc2[_0x44df('0x2a')]['socket']['remoteAddress'];return openIssue(_0xa5fcc2['body'],_0x442831);};