Add the project to GithubUser

The data of the GithubUser object is queried lazy in order to save
requests. In the case of Github apps on GHE we need to supply the
related project in order to do the lazy requests authenticated as the
correct installation.

Change-Id: Ic35d870be17eaf99bfe398fadfc122375be0f963
This commit is contained in:
Tobias Henkel 2017-12-15 16:34:19 +01:00
parent 6619d64269
commit fc16eb73b3
1 changed files with 5 additions and 3 deletions

View File

@ -349,7 +349,9 @@ class GithubEventConnector(threading.Thread):
def _get_sender(self, body):
login = body.get('sender').get('login')
if login:
return self.connection.getUser(login)
# TODO(tobiash): it might be better to plumb in the installation id
project = body.get('repository', {}).get('full_name')
return self.connection.getUser(login, project=project)
def run(self):
while True:
@ -972,8 +974,8 @@ class GithubConnection(BaseConnection):
log_rate_limit(self.log, github)
return reviews
def getUser(self, login):
return GithubUser(self.getGithubClient(), login)
def getUser(self, login, project=None):
return GithubUser(self.getGithubClient(project), login)
def getUserUri(self, login):
return 'https://%s/%s' % (self.server, login)