aboutsummaryrefslogtreecommitdiff
path: root/modules/git_webhooks/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'modules/git_webhooks/__init__.py')
-rw-r--r--modules/git_webhooks/__init__.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/modules/git_webhooks/__init__.py b/modules/git_webhooks/__init__.py
index 0dc03310..b87f0665 100644
--- a/modules/git_webhooks/__init__.py
+++ b/modules/git_webhooks/__init__.py
@@ -13,6 +13,10 @@ DEFAULT_EVENT_CATEGORIES = [
"ping", "code", "pr", "issue", "repo"
]
+PRIVATE_SETTING_NAME = "git-show-private"
+PRIVATE_SETTING = utils.BoolSetting(PRIVATE_SETTING_NAME,
+ "Whether or not to show git activity for private repositories")
+
@utils.export("channelset", utils.BoolSetting("git-prevent-highlight",
"Enable/disable preventing highlights"))
@utils.export("channelset", utils.BoolSetting("git-hide-organisation",
@@ -21,8 +25,8 @@ DEFAULT_EVENT_CATEGORIES = [
"Hide/show command-like prefix on git webhook outputs"))
@utils.export("channelset", utils.BoolSetting("git-shorten-urls",
"Weather or not git webhook URLs should be shortened"))
-@utils.export("botset", utils.BoolSetting("git-show-private",
- "Whether or not to show git activity for private repositories"))
+@utils.export("botset", PRIVATE_SETTING)
+@utils.export("channelset", PRIVATE_SETTING)
class Module(ModuleManager.BaseModule):
_name = "Webhooks"
@@ -54,8 +58,8 @@ class Module(ModuleManager.BaseModule):
"payload"][0])
data = json.loads(payload)
- if handler.is_private(data, headers) and not self.bot.get_setting(
- "git-show-private", False):
+ is_private = handler.is_private(data, headers)
+ if is_private and not self.bot.get_setting(PRIVATE_SETTING_NAME, True):
return {"state": "success", "deliveries": 0}
full_name, repo_username, repo_name, organisation = handler.names(
@@ -96,6 +100,10 @@ class Module(ModuleManager.BaseModule):
repo_hooked = bool(unfiltered_targets)
targets = []
for server, channel, hook in unfiltered_targets:
+ if is_private and not channel.get_setting(
+ PRIVATE_SETTING_NAME, False):
+ continue
+
if (branch and
hook["branches"] and
not branch in hook["branches"]):
@@ -192,7 +200,7 @@ class Module(ModuleManager.BaseModule):
"""
:help: Add/remove/modify a git webhook
:require_mode: high
- :require_access: git-webhook
+ :require_access: admin,git-webhook
:permission: gitoverride
:usage: list
:usage: add <hook>