Fixes
This commit is contained in:
parent
7346fe600c
commit
0cd372f6c6
|
@ -15,11 +15,11 @@ GITEA_REPO_URL="https://git.bitmessage.org/api/v1"
|
|||
|
||||
combined = {}
|
||||
|
||||
def retrieve(token, relationship):
|
||||
if relationship not in ("review_requested", "assigned"):
|
||||
def retrieve(token, kind):
|
||||
if kind not in ("review_requested", "assigned"):
|
||||
raise cherrypy.HTTPError(401, 'Unauthorized')
|
||||
req = urllib.request.Request(GITEA_REPO_URL
|
||||
+ f"/repos/issues/search?state=open&{relationship}=true")
|
||||
+ f"/repos/issues/search?state=open&{kind}=true")
|
||||
req.add_header("Accept", "application/json")
|
||||
req.add_header("Authorization", "token " + token)
|
||||
|
||||
|
@ -30,7 +30,7 @@ def retrieve(token, relationship):
|
|||
for issue in issues:
|
||||
_id = issue['id']
|
||||
retval[_id] = issue
|
||||
retval[_id]['categories'] = [relationship]
|
||||
retval[_id]['categories'] = [kind]
|
||||
return retval
|
||||
|
||||
def process(retrieved):
|
||||
|
@ -55,13 +55,13 @@ def get_token(input_token):
|
|||
return token
|
||||
|
||||
class Root:
|
||||
def _authenticate(self):
|
||||
def _authenticate(self, kind):
|
||||
cherrypy.response.headers['WWW-Authenticate'] = \
|
||||
'Basic realm="ICS access"'
|
||||
cherrypy.response.headers['Content-Type'] = \
|
||||
'text/calendar'
|
||||
cherrypy.response.headers['Content-Disposition'] = \
|
||||
'attachment; filename="Gitea TODO.ics"'
|
||||
f'attachment; filename="Gitea {kind}.ics"'
|
||||
authorization = cherrypy.request.headers.get('Authorization', ':')
|
||||
if not authorization:
|
||||
raise cherrypy.HTTPError(401, 'Unauthorized')
|
||||
|
@ -72,7 +72,7 @@ class Root:
|
|||
|
||||
@cherrypy.expose
|
||||
def assigned(self):
|
||||
token = self._authenticate()
|
||||
token = self._authenticate("assigned")
|
||||
retrieved = retrieve(token, "assigned")
|
||||
if not retrieved:
|
||||
raise cherrypy.HTTPError(401, 'Unauthorized')
|
||||
|
@ -80,8 +80,8 @@ class Root:
|
|||
|
||||
@cherrypy.expose
|
||||
def review_requested(self):
|
||||
token = self._authenticate()
|
||||
retrieved = retrieve(token, "assigned")
|
||||
token = self._authenticate("review_requested")
|
||||
retrieved = retrieve(token, "review_requested")
|
||||
if not retrieved:
|
||||
raise cherrypy.HTTPError(401, 'Unauthorized')
|
||||
return(process(retrieved))
|
||||
|
|
Loading…
Reference in New Issue
Block a user