mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Fix target service attribute on Mastodon integration (#122546)
* Fix target * Fix
This commit is contained in:
parent
3e8d3083ac
commit
943b1afb55
@ -3,7 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import mimetypes
|
import mimetypes
|
||||||
from typing import Any
|
from typing import Any, cast
|
||||||
|
|
||||||
from mastodon import Mastodon
|
from mastodon import Mastodon
|
||||||
from mastodon.Mastodon import MastodonAPIError, MastodonUnauthorizedError
|
from mastodon.Mastodon import MastodonAPIError, MastodonUnauthorizedError
|
||||||
@ -71,11 +71,15 @@ class MastodonNotificationService(BaseNotificationService):
|
|||||||
|
|
||||||
def send_message(self, message: str = "", **kwargs: Any) -> None:
|
def send_message(self, message: str = "", **kwargs: Any) -> None:
|
||||||
"""Toot a message, with media perhaps."""
|
"""Toot a message, with media perhaps."""
|
||||||
|
|
||||||
|
target = None
|
||||||
|
if (target_list := kwargs.get(ATTR_TARGET)) is not None:
|
||||||
|
target = cast(list[str], target_list)[0]
|
||||||
|
|
||||||
data = kwargs.get(ATTR_DATA)
|
data = kwargs.get(ATTR_DATA)
|
||||||
|
|
||||||
media = None
|
media = None
|
||||||
mediadata = None
|
mediadata = None
|
||||||
target = None
|
|
||||||
sensitive = False
|
sensitive = False
|
||||||
content_warning = None
|
content_warning = None
|
||||||
|
|
||||||
@ -87,7 +91,6 @@ class MastodonNotificationService(BaseNotificationService):
|
|||||||
return
|
return
|
||||||
mediadata = self._upload_media(media)
|
mediadata = self._upload_media(media)
|
||||||
|
|
||||||
target = data.get(ATTR_TARGET)
|
|
||||||
sensitive = data.get(ATTR_MEDIA_WARNING)
|
sensitive = data.get(ATTR_MEDIA_WARNING)
|
||||||
content_warning = data.get(ATTR_CONTENT_WARNING)
|
content_warning = data.get(ATTR_CONTENT_WARNING)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user