mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 02:17:19 +00:00
integrations: Add IGNORE_PRIVATE_REPOSITORIES preset WebhookUrlOption.
This refactors the `ignore_private_repositories` URL option to be a preset because it can be used by other "version-control" integrations.
This commit is contained in:
@@ -297,6 +297,13 @@ Currently configured preset URL options:
|
|||||||
input `main` and `dev` for the branches of their repository, then
|
input `main` and `dev` for the branches of their repository, then
|
||||||
`&branches=main%2Cdev` would be appended to the generated integration URL.
|
`&branches=main%2Cdev` would be appended to the generated integration URL.
|
||||||
|
|
||||||
|
- **`IGNORE_PRIVATE_REPOSITORIES`**: This preset is intended to be used for
|
||||||
|
[version control integrations](/integrations/version-control), and adds UI
|
||||||
|
for the user exclude private repositories from triggering Zulip
|
||||||
|
notification messages. When the user selects this option, the
|
||||||
|
`ignore_private_repositories` boolean parameter will be added to the
|
||||||
|
[generated integration URL](/help/generate-integration-url).
|
||||||
|
|
||||||
## Step 4: Manually testing the webhook
|
## Step 4: Manually testing the webhook
|
||||||
|
|
||||||
For either one of the command line tools, first, you'll need to get an
|
For either one of the command line tools, first, you'll need to get an
|
||||||
|
|||||||
@@ -472,11 +472,7 @@ WEBHOOK_INTEGRATIONS: list[WebhookIntegration] = [
|
|||||||
stream_name="github",
|
stream_name="github",
|
||||||
url_options=[
|
url_options=[
|
||||||
WebhookUrlOption.build_preset_config(PresetUrlOption.BRANCHES),
|
WebhookUrlOption.build_preset_config(PresetUrlOption.BRANCHES),
|
||||||
WebhookUrlOption(
|
WebhookUrlOption.build_preset_config(PresetUrlOption.IGNORE_PRIVATE_REPOSITORIES),
|
||||||
name="ignore_private_repositories",
|
|
||||||
label="Exclude notifications from private repositories",
|
|
||||||
validator=check_bool,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
WebhookIntegration(
|
WebhookIntegration(
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ from zerver.lib.request import RequestNotes
|
|||||||
from zerver.lib.send_email import FromAddress
|
from zerver.lib.send_email import FromAddress
|
||||||
from zerver.lib.timestamp import timestamp_to_datetime
|
from zerver.lib.timestamp import timestamp_to_datetime
|
||||||
from zerver.lib.typed_endpoint import ApiParamConfig, typed_endpoint
|
from zerver.lib.typed_endpoint import ApiParamConfig, typed_endpoint
|
||||||
from zerver.lib.validator import check_string
|
from zerver.lib.validator import check_bool, check_string
|
||||||
from zerver.models import UserProfile
|
from zerver.models import UserProfile
|
||||||
|
|
||||||
MISSING_EVENT_HEADER_MESSAGE = """\
|
MISSING_EVENT_HEADER_MESSAGE = """\
|
||||||
@@ -58,6 +58,7 @@ OptionalUserSpecifiedTopicStr: TypeAlias = Annotated[str | None, ApiParamConfig(
|
|||||||
|
|
||||||
class PresetUrlOption(str, Enum):
|
class PresetUrlOption(str, Enum):
|
||||||
BRANCHES = "branches"
|
BRANCHES = "branches"
|
||||||
|
IGNORE_PRIVATE_REPOSITORIES = "ignore_private_repositories"
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@@ -89,6 +90,12 @@ class WebhookUrlOption:
|
|||||||
label="",
|
label="",
|
||||||
validator=check_string,
|
validator=check_string,
|
||||||
)
|
)
|
||||||
|
case PresetUrlOption.IGNORE_PRIVATE_REPOSITORIES:
|
||||||
|
return cls(
|
||||||
|
name=config.value,
|
||||||
|
label="Exclude notifications from private repositories",
|
||||||
|
validator=check_bool,
|
||||||
|
)
|
||||||
|
|
||||||
raise AssertionError(_("Unknown 'PresetUrlOption': {config}").format(config=config))
|
raise AssertionError(_("Unknown 'PresetUrlOption': {config}").format(config=config))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user