Skip to content

Commit

Permalink
Set webhook local_only to True by default (#107670)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbede committed Jan 15, 2024
1 parent 52acc4b commit bd37d37
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 41 deletions.
8 changes: 0 additions & 8 deletions homeassistant/components/webhook/strings.json

This file was deleted.

33 changes: 1 addition & 32 deletions homeassistant/components/webhook/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
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

Expand Down Expand Up @@ -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)

Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/components/webhook/test_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def store_event(event):
"platform": "webhook",
"webhook_id": "post_webhook",
"allowed_methods": "PUT",
# Enable after 2023.11.0: "local_only": False,
"local_only": False,
},
"action": {
"event": "test_success",
Expand Down

0 comments on commit bd37d37

Please sign in to comment.