Don't show webhook notifications for private repos

This commit is contained in:
jesopo 2019-06-24 18:32:20 +01:00
parent 9f71bad472
commit 622eda5a99
3 changed files with 13 additions and 0 deletions

View file

@ -42,6 +42,9 @@ class Module(ModuleManager.BaseModule):
"payload"][0]) "payload"][0])
data = json.loads(payload) data = json.loads(payload)
if handler.is_private(data, headers):
return {"state": "success", "deliveries": 0}
full_name, repo_username, repo_name, organisation = handler.names( full_name, repo_username, repo_name, organisation = handler.names(
data, headers) data, headers)
branch = handler.branch(data, headers) branch = handler.branch(data, headers)

View file

@ -44,6 +44,11 @@ COMMENT_ACTIONS = {
} }
class Gitea(object): class Gitea(object):
def is_private(self, data, headers):
if "repository" in data:
return data["repository"]["private"]
return False
def names(self, data, headers): def names(self, data, headers):
full_name = None full_name = None
repo_username = None repo_username = None

View file

@ -80,6 +80,11 @@ CHECK_RUN_CONCLUSION = {
CHECK_RUN_FAILURES = ["failure", "cancelled", "timed_out", "action_required"] CHECK_RUN_FAILURES = ["failure", "cancelled", "timed_out", "action_required"]
class GitHub(object): class GitHub(object):
def is_private(self, data, headers):
if "repository" in data:
return data["repository"]["private"]
return False
def names(self, data, headers): def names(self, data, headers):
full_name = None full_name = None
repo_username = None repo_username = None