diff options
| author | 2020-01-22 07:10:32 +0000 | |
|---|---|---|
| committer | 2020-01-22 07:10:32 +0000 | |
| commit | 10676d70a6da4ba8f3aa8c4062037ed25db3e0a3 (patch) | |
| tree | 1a1ecba2f21441cc998a12224b5695bd22a2d5c8 /modules/git_webhooks/__init__.py | |
| parent | ignore gitlab issues events that have no action (diff) | |
| signature | ||
default bot-wide private webhooks to enabled but per-channel disabled
Diffstat (limited to 'modules/git_webhooks/__init__.py')
| -rw-r--r-- | modules/git_webhooks/__init__.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/modules/git_webhooks/__init__.py b/modules/git_webhooks/__init__.py index 0dc03310..aa4572cd 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( @@ -81,6 +85,10 @@ class Module(ModuleManager.BaseModule): channel = server.channels.get(channel_name) hooks = channel.get_setting("git-webhooks", {}) + if is_private and not channel.get_setting( + PRIVATE_SETTING_NAME, False): + continue + if hooks: found_hook = self._find_hook( full_name_lower, repo_username_lower, |
