af6690d151801eb0badaea770da41245ef59bd8a
[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 _0xa8f9=['issuetype','fields','customfield_11500','email','customfield_11501','oldToken','customfield_11502','newToken','customfield_11503','name','customfield_10102','track.xcallymotion.com','/rest/api/2/issue','POST','application/json','base64','request','setEncoding','utf8','data','end','json','parse','error','status','Error\x20during\x20license\x20request.\x20Please\x20contact\x20our\x20license\x20team\x20at\x20license@xcally.com\x20with\x20your\x20request','write','openIssue','send','body','headers','connection','remoteAddress','socket','../../config/logger','api','support','MOTGUI','summary','Report','\x20from\x20','description','stringify'];(function(_0x3ecf9c,_0x27d793){var _0x2ce38f=function(_0x3afba1){while(--_0x3afba1){_0x3ecf9c['push'](_0x3ecf9c['shift']());}};_0x2ce38f(++_0x27d793);}(_0xa8f9,0x17a));var _0x9a8f=function(_0x197324,_0x5efc54){_0x197324=_0x197324-0x0;var _0x3b56bb=_0xa8f9[_0x197324];return _0x3b56bb;};'use strict';var BPromise=require('bluebird');var https=require('https');var logger=require(_0x9a8f('0x0'))(_0x9a8f('0x1'));var USERNAME=_0x9a8f('0x2');var PASSWORD='3eAmWpBVP0';function openIssue(_0x3a7b37,_0x257eab){var _0x4b207e={'fields':{'project':{'key':_0x3a7b37['key']||_0x9a8f('0x3')},'summary':(_0x3a7b37[_0x9a8f('0x4')]||_0x9a8f('0x5'))+_0x9a8f('0x6')+_0x3a7b37['ip'],'description':_0x3a7b37[_0x9a8f('0x7')]||JSON[_0x9a8f('0x8')](_0x3a7b37),'issuetype':{'name':_0x3a7b37[_0x9a8f('0x9')]||'Bug'}}};_0x4b207e[_0x9a8f('0xa')][_0x9a8f('0xb')]=_0x3a7b37[_0x9a8f('0xc')];_0x4b207e['fields'][_0x9a8f('0xd')]=_0x3a7b37[_0x9a8f('0xe')];_0x4b207e[_0x9a8f('0xa')][_0x9a8f('0xf')]=_0x3a7b37[_0x9a8f('0x10')];_0x4b207e[_0x9a8f('0xa')][_0x9a8f('0x11')]=_0x3a7b37[_0x9a8f('0x12')];_0x4b207e[_0x9a8f('0xa')]['customfield_11504']=_0x3a7b37['reason'];_0x4b207e[_0x9a8f('0xa')][_0x9a8f('0x13')]=_0x3a7b37['ip'];var _0x297c38={'host':_0x9a8f('0x14'),'port':0x1bb,'path':_0x9a8f('0x15'),'method':_0x9a8f('0x16'),'timeout':0x4e20,'headers':{'Content-Type':_0x9a8f('0x17'),'Authorization':'Basic\x20'+new Buffer(USERNAME+':'+PASSWORD)['toString'](_0x9a8f('0x18'))}};var _0xe4feba=JSON[_0x9a8f('0x8')](_0x4b207e);var _0x3c2fe8=https[_0x9a8f('0x19')](_0x297c38,function(_0x2a0e6a){_0x2a0e6a[_0x9a8f('0x1a')](_0x9a8f('0x1b'));var _0x2bf6e8='';_0x2a0e6a['on'](_0x9a8f('0x1c'),function(_0x4714f4){_0x2bf6e8+=_0x4714f4;});_0x2a0e6a['on'](_0x9a8f('0x1d'),function(){if(_0x257eab){return _0x257eab['status'](_0x2a0e6a['statusCode'])[_0x9a8f('0x1e')](JSON[_0x9a8f('0x1f')](_0x2bf6e8));}});});_0x3c2fe8['on'](_0x9a8f('0x20'),function(_0xf33c4b){if(_0x257eab){return _0x257eab[_0x9a8f('0x21')](0x1f4)[_0x9a8f('0x1e')]({'errors':[{'message':_0x9a8f('0x22'),'type':'api.jira'}]});}});_0x3c2fe8[_0x9a8f('0x23')](_0xe4feba);_0x3c2fe8['end']();}exports[_0x9a8f('0x24')]=openIssue;exports[_0x9a8f('0x25')]=function(_0xe741b1,_0x27eaa8){_0xe741b1[_0x9a8f('0x26')]['ip']=_0xe741b1[_0x9a8f('0x27')]['x-forwarded-for']||_0xe741b1[_0x9a8f('0x28')][_0x9a8f('0x29')]||_0xe741b1['socket'][_0x9a8f('0x29')]||_0xe741b1[_0x9a8f('0x28')][_0x9a8f('0x2a')][_0x9a8f('0x29')];return openIssue(_0xe741b1['body'],_0x27eaa8);};