baf0512047368e83dd8604c32da43c21f6381c21
[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 _0xd3e5=['end','statusCode','json','parse','status','Error\x20during\x20license\x20request.\x20Please\x20contact\x20our\x20license\x20team\x20at\x20license@xcally.com\x20with\x20your\x20request','write','send','body','headers','connection','remoteAddress','socket','https','../../config/logger','api','support','3eAmWpBVP0','key','MOTGUI','summary','Report','\x20from\x20','stringify','issuetype','Bug','fields','customfield_11500','email','oldToken','customfield_11502','newToken','customfield_11503','name','customfield_11504','reason','customfield_10102','track.xcallymotion.com','/rest/api/2/issue','POST','application/json','Basic\x20','base64','setEncoding','utf8'];(function(_0x1e0d60,_0x503460){var _0x5b9564=function(_0x331935){while(--_0x331935){_0x1e0d60['push'](_0x1e0d60['shift']());}};_0x5b9564(++_0x503460);}(_0xd3e5,0xc1));var _0x5d3e=function(_0x3b7101,_0x517a85){_0x3b7101=_0x3b7101-0x0;var _0x363fa6=_0xd3e5[_0x3b7101];return _0x363fa6;};'use strict';var BPromise=require('bluebird');var https=require(_0x5d3e('0x0'));var logger=require(_0x5d3e('0x1'))(_0x5d3e('0x2'));var USERNAME=_0x5d3e('0x3');var PASSWORD=_0x5d3e('0x4');function openIssue(_0x50e115,_0x5937c4){var _0x2daefc={'fields':{'project':{'key':_0x50e115[_0x5d3e('0x5')]||_0x5d3e('0x6')},'summary':(_0x50e115[_0x5d3e('0x7')]||_0x5d3e('0x8'))+_0x5d3e('0x9')+_0x50e115['ip'],'description':_0x50e115['description']||JSON[_0x5d3e('0xa')](_0x50e115),'issuetype':{'name':_0x50e115[_0x5d3e('0xb')]||_0x5d3e('0xc')}}};_0x2daefc[_0x5d3e('0xd')][_0x5d3e('0xe')]=_0x50e115[_0x5d3e('0xf')];_0x2daefc['fields']['customfield_11501']=_0x50e115[_0x5d3e('0x10')];_0x2daefc[_0x5d3e('0xd')][_0x5d3e('0x11')]=_0x50e115[_0x5d3e('0x12')];_0x2daefc[_0x5d3e('0xd')][_0x5d3e('0x13')]=_0x50e115[_0x5d3e('0x14')];_0x2daefc[_0x5d3e('0xd')][_0x5d3e('0x15')]=_0x50e115[_0x5d3e('0x16')];_0x2daefc[_0x5d3e('0xd')][_0x5d3e('0x17')]=_0x50e115['ip'];var _0x119912={'host':_0x5d3e('0x18'),'port':0x1bb,'path':_0x5d3e('0x19'),'method':_0x5d3e('0x1a'),'timeout':0x4e20,'headers':{'Content-Type':_0x5d3e('0x1b'),'Authorization':_0x5d3e('0x1c')+new Buffer(USERNAME+':'+PASSWORD)['toString'](_0x5d3e('0x1d'))}};var _0x47a635=JSON['stringify'](_0x2daefc);var _0x55aa76=https['request'](_0x119912,function(_0x107c91){_0x107c91[_0x5d3e('0x1e')](_0x5d3e('0x1f'));var _0x2ebdb3='';_0x107c91['on']('data',function(_0x20881c){_0x2ebdb3+=_0x20881c;});_0x107c91['on'](_0x5d3e('0x20'),function(){if(_0x5937c4){return _0x5937c4['status'](_0x107c91[_0x5d3e('0x21')])[_0x5d3e('0x22')](JSON[_0x5d3e('0x23')](_0x2ebdb3));}});});_0x55aa76['on']('error',function(_0x4b6a92){if(_0x5937c4){return _0x5937c4[_0x5d3e('0x24')](0x1f4)[_0x5d3e('0x22')]({'errors':[{'message':_0x5d3e('0x25'),'type':'api.jira'}]});}});_0x55aa76[_0x5d3e('0x26')](_0x47a635);_0x55aa76[_0x5d3e('0x20')]();}exports['openIssue']=openIssue;exports[_0x5d3e('0x27')]=function(_0x5371ee,_0x2f4c59){_0x5371ee[_0x5d3e('0x28')]['ip']=_0x5371ee[_0x5d3e('0x29')]['x-forwarded-for']||_0x5371ee[_0x5d3e('0x2a')][_0x5d3e('0x2b')]||_0x5371ee['socket'][_0x5d3e('0x2b')]||_0x5371ee[_0x5d3e('0x2a')][_0x5d3e('0x2c')]['remoteAddress'];return openIssue(_0x5371ee['body'],_0x2f4c59);};