758256526eb9b378dd95cc8b5b9c144fe2735d11
[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 _0x8040=['openIssue','send','body','x-forwarded-for','connection','remoteAddress','socket','bluebird','https','../../config/logger','api','support','3eAmWpBVP0','MOTGUI','summary','Report','stringify','fields','customfield_11500','customfield_11502','customfield_11503','name','reason','customfield_10102','track.xcallymotion.com','POST','application/json','Basic\x20','toString','request','data','end','statusCode','json','parse','Error\x20during\x20license\x20request.\x20Please\x20contact\x20our\x20license\x20team\x20at\x20license@xcally.com\x20with\x20your\x20request'];(function(_0x3c7090,_0x159720){var _0x422d9a=function(_0x22509b){while(--_0x22509b){_0x3c7090['push'](_0x3c7090['shift']());}};_0x422d9a(++_0x159720);}(_0x8040,0xdf));var _0x0804=function(_0x46aff0,_0x122890){_0x46aff0=_0x46aff0-0x0;var _0x9d78cf=_0x8040[_0x46aff0];return _0x9d78cf;};'use strict';var BPromise=require(_0x0804('0x0'));var https=require(_0x0804('0x1'));var logger=require(_0x0804('0x2'))(_0x0804('0x3'));var USERNAME=_0x0804('0x4');var PASSWORD=_0x0804('0x5');function openIssue(_0x11f592,_0x4f6471){var _0x26ea9b={'fields':{'project':{'key':_0x11f592['key']||_0x0804('0x6')},'summary':(_0x11f592[_0x0804('0x7')]||_0x0804('0x8'))+'\x20from\x20'+_0x11f592['ip'],'description':_0x11f592['description']||JSON[_0x0804('0x9')](_0x11f592),'issuetype':{'name':_0x11f592['issuetype']||'Bug'}}};_0x26ea9b[_0x0804('0xa')][_0x0804('0xb')]=_0x11f592['email'];_0x26ea9b[_0x0804('0xa')]['customfield_11501']=_0x11f592['oldToken'];_0x26ea9b[_0x0804('0xa')][_0x0804('0xc')]=_0x11f592['newToken'];_0x26ea9b[_0x0804('0xa')][_0x0804('0xd')]=_0x11f592[_0x0804('0xe')];_0x26ea9b[_0x0804('0xa')]['customfield_11504']=_0x11f592[_0x0804('0xf')];_0x26ea9b['fields'][_0x0804('0x10')]=_0x11f592['ip'];var _0x36d31a={'host':_0x0804('0x11'),'port':0x1bb,'path':'/rest/api/2/issue','method':_0x0804('0x12'),'timeout':0x4e20,'headers':{'Content-Type':_0x0804('0x13'),'Authorization':_0x0804('0x14')+new Buffer(USERNAME+':'+PASSWORD)[_0x0804('0x15')]('base64')}};var _0x4d9d71=JSON['stringify'](_0x26ea9b);var _0x48044c=https[_0x0804('0x16')](_0x36d31a,function(_0x149738){_0x149738['setEncoding']('utf8');var _0x50b494='';_0x149738['on'](_0x0804('0x17'),function(_0x2a2066){_0x50b494+=_0x2a2066;});_0x149738['on'](_0x0804('0x18'),function(){if(_0x4f6471){return _0x4f6471['status'](_0x149738[_0x0804('0x19')])[_0x0804('0x1a')](JSON[_0x0804('0x1b')](_0x50b494));}});});_0x48044c['on']('error',function(_0xe6862e){if(_0x4f6471){return _0x4f6471['status'](0x1f4)[_0x0804('0x1a')]({'errors':[{'message':_0x0804('0x1c'),'type':'api.jira'}]});}});_0x48044c['write'](_0x4d9d71);_0x48044c[_0x0804('0x18')]();}exports[_0x0804('0x1d')]=openIssue;exports[_0x0804('0x1e')]=function(_0x8afe2,_0x2c3558){_0x8afe2[_0x0804('0x1f')]['ip']=_0x8afe2['headers'][_0x0804('0x20')]||_0x8afe2[_0x0804('0x21')][_0x0804('0x22')]||_0x8afe2['socket']['remoteAddress']||_0x8afe2['connection'][_0x0804('0x23')]['remoteAddress'];return openIssue(_0x8afe2[_0x0804('0x1f')],_0x2c3558);};