default bot-wide private webhooks to enabled but per-channel disabled
This commit is contained in:
parent
4346375a48
commit
10676d70a6
1 changed files with 12 additions and 4 deletions
|
@ -13,6 +13,10 @@ DEFAULT_EVENT_CATEGORIES = [
|
||||||
"ping", "code", "pr", "issue", "repo"
|
"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",
|
@utils.export("channelset", utils.BoolSetting("git-prevent-highlight",
|
||||||
"Enable/disable preventing highlights"))
|
"Enable/disable preventing highlights"))
|
||||||
@utils.export("channelset", utils.BoolSetting("git-hide-organisation",
|
@utils.export("channelset", utils.BoolSetting("git-hide-organisation",
|
||||||
|
@ -21,8 +25,8 @@ DEFAULT_EVENT_CATEGORIES = [
|
||||||
"Hide/show command-like prefix on git webhook outputs"))
|
"Hide/show command-like prefix on git webhook outputs"))
|
||||||
@utils.export("channelset", utils.BoolSetting("git-shorten-urls",
|
@utils.export("channelset", utils.BoolSetting("git-shorten-urls",
|
||||||
"Weather or not git webhook URLs should be shortened"))
|
"Weather or not git webhook URLs should be shortened"))
|
||||||
@utils.export("botset", utils.BoolSetting("git-show-private",
|
@utils.export("botset", PRIVATE_SETTING)
|
||||||
"Whether or not to show git activity for private repositories"))
|
@utils.export("channelset", PRIVATE_SETTING)
|
||||||
class Module(ModuleManager.BaseModule):
|
class Module(ModuleManager.BaseModule):
|
||||||
_name = "Webhooks"
|
_name = "Webhooks"
|
||||||
|
|
||||||
|
@ -54,8 +58,8 @@ class Module(ModuleManager.BaseModule):
|
||||||
"payload"][0])
|
"payload"][0])
|
||||||
data = json.loads(payload)
|
data = json.loads(payload)
|
||||||
|
|
||||||
if handler.is_private(data, headers) and not self.bot.get_setting(
|
is_private = handler.is_private(data, headers)
|
||||||
"git-show-private", False):
|
if is_private and not self.bot.get_setting(PRIVATE_SETTING_NAME, True):
|
||||||
return {"state": "success", "deliveries": 0}
|
return {"state": "success", "deliveries": 0}
|
||||||
|
|
||||||
full_name, repo_username, repo_name, organisation = handler.names(
|
full_name, repo_username, repo_name, organisation = handler.names(
|
||||||
|
@ -81,6 +85,10 @@ class Module(ModuleManager.BaseModule):
|
||||||
channel = server.channels.get(channel_name)
|
channel = server.channels.get(channel_name)
|
||||||
hooks = channel.get_setting("git-webhooks", {})
|
hooks = channel.get_setting("git-webhooks", {})
|
||||||
|
|
||||||
|
if is_private and not channel.get_setting(
|
||||||
|
PRIVATE_SETTING_NAME, False):
|
||||||
|
continue
|
||||||
|
|
||||||
if hooks:
|
if hooks:
|
||||||
found_hook = self._find_hook(
|
found_hook = self._find_hook(
|
||||||
full_name_lower, repo_username_lower,
|
full_name_lower, repo_username_lower,
|
||||||
|
|
Loading…
Reference in a new issue