Fediverse: Add @status.

This commit is contained in:
Valentin Lorentz 2020-05-10 21:12:05 +02:00
parent 4e74c6dbb3
commit 2c9e6544f5
2 changed files with 35 additions and 0 deletions

View File

@ -337,6 +337,19 @@ class Fediverse(callbacks.PluginRegexp):
)
)
@wrap(["url"])
def status(self, irc, msg, args, url):
"""<url>
Shows the content of the status at <url>.
"""
try:
status = ap.get_resource_from_url(url)
except ap.ActivityPubError as e:
irc.error(_("Could not get status: %s") % e.args[0], Raise=True)
irc.reply(self._format_status(irc, msg, status))
Class = Fediverse

View File

@ -277,6 +277,28 @@ class FediverseTestCase(ChannelPluginTestCase):
"Error: Unknown user @nonexistinguser@example.org.",
)
def testStatus(self):
expected_requests = [
(STATUS_URL, STATUS_DATA),
(ACTOR_URL, ACTOR_DATA),
]
with self.mockRequests(expected_requests):
self.assertResponse(
"status https://example.org/users/someuser/statuses/1234",
"\x02someuser (@someuser@example.org)\x02: "
+ "@ FirstAuthor I am replying to you",
)
def testStatusError(self):
expected_requests = [(STATUS_URL, utils.web.Error("blah"))]
with self.mockRequests(expected_requests):
self.assertResponse(
"status https://example.org/users/someuser/statuses/1234",
"Error: Could not get status: blah",
)
def testStatuses(self):
expected_requests = [
(HOSTMETA_URL, HOSTMETA_DATA),