From 6b8120dc517a1b41c9fc951d989b53746c8fadb0 Mon Sep 17 00:00:00 2001 From: jesopo Date: Mon, 24 Jun 2019 17:13:51 +0100 Subject: Add gitea.py, fix some consts being in the wrong file --- modules/git_webhooks/__init__.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'modules/git_webhooks/__init__.py') diff --git a/modules/git_webhooks/__init__.py b/modules/git_webhooks/__init__.py index d861e5bb..e140d33d 100644 --- a/modules/git_webhooks/__init__.py +++ b/modules/git_webhooks/__init__.py @@ -1,9 +1,13 @@ import itertools, json, urllib.parse from src import ModuleManager, utils -from . import colors, github +from . import colors, gitea, github FORM_ENCODED = "application/x-www-form-urlencoded" +DEFAULT_EVENT_CATEGORIES = [ + "ping", "code", "pr", "issue", "repo" +] + @utils.export("channelset", {"setting": "git-prevent-highlight", "help": "Enable/disable preventing highlights", "validate": utils.bool_or_none, "example": "on"}) @@ -16,12 +20,18 @@ FORM_ENCODED = "application/x-www-form-urlencoded" class Module(ModuleManager.BaseModule): def on_load(self): self._github = github.GitHub() + self._gitea = gitea.Gitea() @utils.hook("api.post.github") def _api_github_webhook(self, event): return self._webhook("github", "GitHub", self._github, event["data"], event["headers"]) + @utils.hook("api.post.gitea") + def _api_gitea_webhook(self, event): + return self._webhook("gitea", "Gitea", self._github, + event["data"], event["headers"]) + def _webhook(self, webhook_type, webhook_name, handler, payload_str, headers): payload = payload_str.decode("utf8") -- cgit v1.3.1-10-gc9f91