Fediverse: Hide channel actor on PeerTube

This commit is contained in:
Valentin Lorentz 2022-07-20 18:15:51 +02:00
parent 34f8842273
commit 461c091b94
2 changed files with 6 additions and 4 deletions

View File

@ -237,11 +237,15 @@ class Fediverse(callbacks.PluginRegexp):
else:
return self._format_actor_fullname(author)
elif isinstance(author, dict):
if author.get("type") == "Group":
# Typically, there is an actor named "Default <username> channel"
# on PeerTube, which we do not want to show.
return None
if author.get("id"):
return self._format_author(irc, author["id"])
elif isinstance(author, list):
return format(
"%L", [self._format_author(irc, item) for item in author]
"%L", filter(bool, [self._format_author(irc, item) for item in author])
)
else:
return "<unknown>"

View File

@ -438,15 +438,13 @@ class NetworklessFediverseTestCase(BaseFediverseTestCase):
expected_requests = [
(PEERTUBE_VIDEO_URL, PEERTUBE_VIDEO_DATA),
(PEERTUBE_ACTOR_URL, PEERTUBE_ACTOR_DATA),
(ACTOR_URL, ACTOR_DATA),
]
with self.mockRequests(expected_requests):
self.assertResponse(
"status https://example.org/w/gABde9e210FGHre",
"\x02name of video\x02 (1 hour, 26 minutes, and 0 seconds) "
"by \x02chocobozzz\x02 (@chocobozzz@peertube.cpy.re) "
"and \x02someuser\x02 (@someuser@example.org): "
"by \x02chocobozzz\x02 (@chocobozzz@peertube.cpy.re): "
"description of the video with a second line",
)