From 461c091b94c6258024918525a6c9c7ab40d9b217 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Wed, 20 Jul 2022 18:15:51 +0200 Subject: [PATCH] Fediverse: Hide channel actor on PeerTube --- plugins/Fediverse/plugin.py | 6 +++++- plugins/Fediverse/test.py | 4 +--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/Fediverse/plugin.py b/plugins/Fediverse/plugin.py index a82cfb15e..13d30d14b 100644 --- a/plugins/Fediverse/plugin.py +++ b/plugins/Fediverse/plugin.py @@ -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 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 "" diff --git a/plugins/Fediverse/test.py b/plugins/Fediverse/test.py index 5c0b2f88b..d06c0ead7 100644 --- a/plugins/Fediverse/test.py +++ b/plugins/Fediverse/test.py @@ -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", )