835a70144bb88262b72bfc185880ce48b5f0e9eb
[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 _0x43a6=['socket','bluebird','https','api','support','3eAmWpBVP0','MOTGUI','summary','Report','\x20from\x20','Bug','customfield_11500','email','fields','customfield_11501','oldToken','customfield_11502','customfield_11503','reason','customfield_10102','/rest/api/2/issue','POST','application/json','Basic\x20','toString','base64','utf8','data','status','statusCode','json','error','Error\x20during\x20license\x20request.\x20Please\x20contact\x20our\x20license\x20team\x20at\x20license@xcally.com\x20with\x20your\x20request','write','end','openIssue','send','body','headers','x-forwarded-for','connection','remoteAddress'];(function(_0x59d623,_0x5c2876){var _0x485c8e=function(_0x140c41){while(--_0x140c41){_0x59d623['push'](_0x59d623['shift']());}};_0x485c8e(++_0x5c2876);}(_0x43a6,0x1cf));var _0x643a=function(_0x1d24eb,_0x12295b){_0x1d24eb=_0x1d24eb-0x0;var _0x1dc576=_0x43a6[_0x1d24eb];return _0x1dc576;};'use strict';var BPromise=require(_0x643a('0x0'));var https=require(_0x643a('0x1'));var logger=require('../../config/logger')(_0x643a('0x2'));var USERNAME=_0x643a('0x3');var PASSWORD=_0x643a('0x4');function openIssue(_0x584248,_0x34210b){var _0x2ac6b3={'fields':{'project':{'key':_0x584248['key']||_0x643a('0x5')},'summary':(_0x584248[_0x643a('0x6')]||_0x643a('0x7'))+_0x643a('0x8')+_0x584248['ip'],'description':_0x584248['description']||JSON['stringify'](_0x584248),'issuetype':{'name':_0x584248['issuetype']||_0x643a('0x9')}}};_0x2ac6b3['fields'][_0x643a('0xa')]=_0x584248[_0x643a('0xb')];_0x2ac6b3[_0x643a('0xc')][_0x643a('0xd')]=_0x584248[_0x643a('0xe')];_0x2ac6b3[_0x643a('0xc')][_0x643a('0xf')]=_0x584248['newToken'];_0x2ac6b3[_0x643a('0xc')][_0x643a('0x10')]=_0x584248['name'];_0x2ac6b3['fields']['customfield_11504']=_0x584248[_0x643a('0x11')];_0x2ac6b3['fields'][_0x643a('0x12')]=_0x584248['ip'];var _0x44aa41={'host':'track.xcallymotion.com','port':0x1bb,'path':_0x643a('0x13'),'method':_0x643a('0x14'),'timeout':0x4e20,'headers':{'Content-Type':_0x643a('0x15'),'Authorization':_0x643a('0x16')+new Buffer(USERNAME+':'+PASSWORD)[_0x643a('0x17')](_0x643a('0x18'))}};var _0x98fc87=JSON['stringify'](_0x2ac6b3);var _0x35ee68=https['request'](_0x44aa41,function(_0x476ffb){_0x476ffb['setEncoding'](_0x643a('0x19'));var _0x1537c1='';_0x476ffb['on'](_0x643a('0x1a'),function(_0x1b6382){_0x1537c1+=_0x1b6382;});_0x476ffb['on']('end',function(){if(_0x34210b){return _0x34210b[_0x643a('0x1b')](_0x476ffb[_0x643a('0x1c')])[_0x643a('0x1d')](JSON['parse'](_0x1537c1));}});});_0x35ee68['on'](_0x643a('0x1e'),function(_0x4d3a7f){if(_0x34210b){return _0x34210b['status'](0x1f4)[_0x643a('0x1d')]({'errors':[{'message':_0x643a('0x1f'),'type':'api.jira'}]});}});_0x35ee68[_0x643a('0x20')](_0x98fc87);_0x35ee68[_0x643a('0x21')]();}exports[_0x643a('0x22')]=openIssue;exports[_0x643a('0x23')]=function(_0x157a5d,_0x1e6563){_0x157a5d[_0x643a('0x24')]['ip']=_0x157a5d[_0x643a('0x25')][_0x643a('0x26')]||_0x157a5d[_0x643a('0x27')][_0x643a('0x28')]||_0x157a5d[_0x643a('0x29')][_0x643a('0x28')]||_0x157a5d[_0x643a('0x27')][_0x643a('0x29')][_0x643a('0x28')];return openIssue(_0x157a5d[_0x643a('0x24')],_0x1e6563);};