Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Truncate event_bus data to 32 chars #89

Merged
merged 1 commit into from Feb 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions alexa_media/__init__.py
Expand Up @@ -50,7 +50,7 @@


def hide_email(email):
"""Helper file to obfuscate emails."""
"""Obfuscate email."""
m = email.split('@')
return "{}{}{}@{}".format(m[0][0], "*"*(len(m[0])-2), m[0][-1], m[1])

Expand Down Expand Up @@ -281,7 +281,7 @@ def update_devices():
last_called != stored_data['last_called']) or
('last_called' not in stored_data and
last_called is not None)):
hass.bus.fire('{}_{}'.format(DOMAIN, email),
hass.bus.fire(('{}_{}'.format(DOMAIN, hide_email(email)))[0:32],
{'last_called_change': last_called})
(hass.data[DATA_ALEXAMEDIA]
['accounts']
Expand Down
8 changes: 4 additions & 4 deletions alexa_media/media_player.py
Expand Up @@ -28,12 +28,12 @@
from homeassistant.components.alexa_media import (
DOMAIN as ALEXA_DOMAIN,
DATA_ALEXAMEDIA,
MIN_TIME_BETWEEN_SCANS, MIN_TIME_BETWEEN_FORCED_SCANS)
MIN_TIME_BETWEEN_SCANS, MIN_TIME_BETWEEN_FORCED_SCANS, hide_email)
except ImportError:
from custom_components.alexa_media import (
DOMAIN as ALEXA_DOMAIN,
DATA_ALEXAMEDIA,
MIN_TIME_BETWEEN_SCANS, MIN_TIME_BETWEEN_FORCED_SCANS)
MIN_TIME_BETWEEN_SCANS, MIN_TIME_BETWEEN_FORCED_SCANS, hide_email)
from .const import (
ATTR_MESSAGE, SERVICE_ALEXA_TTS, PLAY_SCAN_INTERVAL
)
Expand Down Expand Up @@ -140,8 +140,8 @@ def __init__(self, device, login, update_devices, hass):
self._last_update = 0
self.refresh(device)
# Register event handler on bus
hass.bus.listen('{}_{}'.format(ALEXA_DOMAIN,
login.get_email()),
hass.bus.listen(('{}_{}'.format(ALEXA_DOMAIN,
hide_email(login.get_email())))[0:32],
self._handle_event)

def _handle_event(self, event):
Expand Down