From bd37d3776b48c6fabd40528473f9c6d17027fa4c Mon Sep 17 00:00:00 2001 From: Jan-Philipp Benecke Date: Mon, 15 Jan 2024 11:09:40 +0100 Subject: [PATCH] Set webhook `local_only` to True by default (#107670) --- homeassistant/components/webhook/strings.json | 8 ----- homeassistant/components/webhook/trigger.py | 33 +------------------ tests/components/webhook/test_trigger.py | 2 +- 3 files changed, 2 insertions(+), 41 deletions(-) delete mode 100644 homeassistant/components/webhook/strings.json diff --git a/homeassistant/components/webhook/strings.json b/homeassistant/components/webhook/strings.json deleted file mode 100644 index 53b932727d0..00000000000 --- a/homeassistant/components/webhook/strings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "issues": { - "trigger_missing_local_only": { - "title": "Update webhook trigger: {webhook_id}", - "description": "A choice needs to be made about whether the {webhook_id} webhook automation trigger is accessible from the internet. [Edit the automation]({edit}) \"{automation_name}\", (`{entity_id}`) and click the gear icon beside the Webhook ID to choose a value for 'Only accessible from the local network'" - } - } -} diff --git a/homeassistant/components/webhook/trigger.py b/homeassistant/components/webhook/trigger.py index e0f3412a562..05bb53564bd 100644 --- a/homeassistant/components/webhook/trigger.py +++ b/homeassistant/components/webhook/trigger.py @@ -11,11 +11,6 @@ import voluptuous as vol from homeassistant.const import CONF_PLATFORM, CONF_WEBHOOK_ID from homeassistant.core import CALLBACK_TYPE, HassJob, HomeAssistant, callback import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.issue_registry import ( - IssueSeverity, - async_create_issue, - async_delete_issue, -) from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.typing import ConfigType @@ -88,31 +83,7 @@ async def async_attach_trigger( ) -> CALLBACK_TYPE: """Trigger based on incoming webhooks.""" webhook_id: str = config[CONF_WEBHOOK_ID] - local_only = config.get(CONF_LOCAL_ONLY) - issue_id: str | None = None - if local_only is None: - issue_id = f"trigger_missing_local_only_{webhook_id}" - variables = trigger_info["variables"] or {} - automation_info = variables.get("this", {}) - automation_id = automation_info.get("attributes", {}).get("id") - automation_entity_id = automation_info.get("entity_id") - automation_name = trigger_info.get("name") or automation_entity_id - async_create_issue( - hass, - DOMAIN, - issue_id, - breaks_in_ha_version="2023.11.0", - is_fixable=False, - severity=IssueSeverity.WARNING, - learn_more_url="https://www.home-assistant.io/docs/automation/trigger/#webhook-trigger", - translation_key="trigger_missing_local_only", - translation_placeholders={ - "webhook_id": webhook_id, - "automation_name": automation_name, - "entity_id": automation_entity_id, - "edit": f"/config/automation/edit/{automation_id}", - }, - ) + local_only = config.get(CONF_LOCAL_ONLY, True) allowed_methods = config.get(CONF_ALLOWED_METHODS, DEFAULT_METHODS) job = HassJob(action) @@ -138,8 +109,6 @@ async def async_attach_trigger( @callback def unregister() -> None: """Unregister webhook.""" - if issue_id: - async_delete_issue(hass, DOMAIN, issue_id) triggers[webhook_id].remove(trigger_instance) if not triggers[webhook_id]: async_unregister(hass, webhook_id) diff --git a/tests/components/webhook/test_trigger.py b/tests/components/webhook/test_trigger.py index 990482c500e..713130b6fb6 100644 --- a/tests/components/webhook/test_trigger.py +++ b/tests/components/webhook/test_trigger.py @@ -150,7 +150,7 @@ async def test_webhook_allowed_methods_internet( "platform": "webhook", "webhook_id": "post_webhook", "allowed_methods": "PUT", - # Enable after 2023.11.0: "local_only": False, + "local_only": False, }, "action": { "event": "test_success",