mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 18:27:51 +00:00
Only include agent user ID in SYNC responses (#23497)
This commit is contained in:
parent
300d1f44a6
commit
b09f5b6743
@ -100,10 +100,13 @@ class CloudClient(Interface):
|
|||||||
|
|
||||||
return google_conf['filter'](entity.entity_id)
|
return google_conf['filter'](entity.entity_id)
|
||||||
|
|
||||||
|
username = self._hass.data[DOMAIN].claims["cognito:username"]
|
||||||
|
|
||||||
self._google_config = ga_h.Config(
|
self._google_config = ga_h.Config(
|
||||||
should_expose=should_expose,
|
should_expose=should_expose,
|
||||||
secure_devices_pin=self._prefs.google_secure_devices_pin,
|
secure_devices_pin=self._prefs.google_secure_devices_pin,
|
||||||
entity_config=google_conf.get(CONF_ENTITY_CONFIG),
|
entity_config=google_conf.get(CONF_ENTITY_CONFIG),
|
||||||
|
agent_user_id=username,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Set it to the latest.
|
# Set it to the latest.
|
||||||
@ -149,19 +152,10 @@ class CloudClient(Interface):
|
|||||||
if not self._prefs.google_enabled:
|
if not self._prefs.google_enabled:
|
||||||
return ga.turned_off_response(payload)
|
return ga.turned_off_response(payload)
|
||||||
|
|
||||||
answer = await ga.async_handle_message(
|
return await ga.async_handle_message(
|
||||||
self._hass, self.google_config, self.prefs.cloud_user, payload
|
self._hass, self.google_config, self.prefs.cloud_user, payload
|
||||||
)
|
)
|
||||||
|
|
||||||
# Fix AgentUserId
|
|
||||||
try:
|
|
||||||
cloud = self._hass.data[DOMAIN]
|
|
||||||
answer['payload']['agentUserId'] = cloud.claims['cognito:username']
|
|
||||||
except (TypeError, KeyError):
|
|
||||||
return ga.turned_off_response(payload)
|
|
||||||
|
|
||||||
return answer
|
|
||||||
|
|
||||||
async def async_webhook_message(
|
async def async_webhook_message(
|
||||||
self, payload: Dict[Any, Any]) -> Dict[Any, Any]:
|
self, payload: Dict[Any, Any]) -> Dict[Any, Any]:
|
||||||
"""Process cloud webhook message to client."""
|
"""Process cloud webhook message to client."""
|
||||||
|
@ -20,12 +20,16 @@ class Config:
|
|||||||
"""Hold the configuration for Google Assistant."""
|
"""Hold the configuration for Google Assistant."""
|
||||||
|
|
||||||
def __init__(self, should_expose,
|
def __init__(self, should_expose,
|
||||||
entity_config=None, secure_devices_pin=None):
|
entity_config=None, secure_devices_pin=None,
|
||||||
|
agent_user_id=None):
|
||||||
"""Initialize the configuration."""
|
"""Initialize the configuration."""
|
||||||
self.should_expose = should_expose
|
self.should_expose = should_expose
|
||||||
self.entity_config = entity_config or {}
|
self.entity_config = entity_config or {}
|
||||||
self.secure_devices_pin = secure_devices_pin
|
self.secure_devices_pin = secure_devices_pin
|
||||||
|
|
||||||
|
# Agent User Id to use for query responses
|
||||||
|
self.agent_user_id = agent_user_id
|
||||||
|
|
||||||
|
|
||||||
class RequestData:
|
class RequestData:
|
||||||
"""Hold data associated with a particular request."""
|
"""Hold data associated with a particular request."""
|
||||||
|
@ -99,7 +99,7 @@ async def async_devices_sync(hass, data, payload):
|
|||||||
devices.append(serialized)
|
devices.append(serialized)
|
||||||
|
|
||||||
response = {
|
response = {
|
||||||
'agentUserId': data.context.user_id,
|
'agentUserId': data.config.agent_user_id or data.context.user_id,
|
||||||
'devices': devices,
|
'devices': devices,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user