mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-26 04:32:51 +01:00
Fediverse: Fix compatibility with Python 3.4 and 3.5.
This commit is contained in:
parent
27219409b4
commit
7511984a60
@ -140,7 +140,7 @@ def webfinger(hostname, uri):
|
|||||||
)
|
)
|
||||||
|
|
||||||
with convert_exceptions(WebfingerError, "Invalid JSON: ", True):
|
with convert_exceptions(WebfingerError, "Invalid JSON: ", True):
|
||||||
return json.loads(content)
|
return json.loads(content.decode())
|
||||||
|
|
||||||
|
|
||||||
def get_instance_actor_url():
|
def get_instance_actor_url():
|
||||||
@ -241,4 +241,4 @@ def get_actor_from_url(url):
|
|||||||
assert content is not None
|
assert content is not None
|
||||||
|
|
||||||
with convert_exceptions(ActivityPubProtocolError, "Invalid JSON: ", True):
|
with convert_exceptions(ActivityPubProtocolError, "Invalid JSON: ", True):
|
||||||
return json.loads(content)
|
return json.loads(content.decode())
|
||||||
|
@ -183,7 +183,7 @@ class Fediverse(callbacks.PluginRegexp):
|
|||||||
content = ap.signed_request(
|
content = ap.signed_request(
|
||||||
status["object"], headers={"Accept": ap.ACTIVITY_MIMETYPE}
|
status["object"], headers={"Accept": ap.ACTIVITY_MIMETYPE}
|
||||||
)
|
)
|
||||||
status = json.loads(content)
|
status = json.loads(content.decode())
|
||||||
return self._format_status(irc, status)
|
return self._format_status(irc, status)
|
||||||
except ap.ActivityPubProtocolError as e:
|
except ap.ActivityPubProtocolError as e:
|
||||||
return "<Could not fetch status: %s>" % e.args[0]
|
return "<Could not fetch status: %s>" % e.args[0]
|
||||||
@ -239,9 +239,9 @@ class Fediverse(callbacks.PluginRegexp):
|
|||||||
if "featured" not in actor:
|
if "featured" not in actor:
|
||||||
irc.reply(_("No featured statuses."))
|
irc.reply(_("No featured statuses."))
|
||||||
return
|
return
|
||||||
statuses = json.loads(ap.signed_request(actor["featured"])).get(
|
statuses = json.loads(
|
||||||
"orderedItems", []
|
ap.signed_request(actor["featured"]).decode()
|
||||||
)
|
).get("orderedItems", [])
|
||||||
if not statuses:
|
if not statuses:
|
||||||
irc.reply(_("No featured statuses."))
|
irc.reply(_("No featured statuses."))
|
||||||
return
|
return
|
||||||
@ -260,11 +260,11 @@ class Fediverse(callbacks.PluginRegexp):
|
|||||||
actor = self._get_actor(irc, username)
|
actor = self._get_actor(irc, username)
|
||||||
if "outbox" not in actor:
|
if "outbox" not in actor:
|
||||||
irc.error(_("No status."), Raise=True)
|
irc.error(_("No status."), Raise=True)
|
||||||
outbox = json.loads(ap.signed_request(actor["outbox"]))
|
outbox = json.loads(ap.signed_request(actor["outbox"]).decode())
|
||||||
|
|
||||||
# Fetches the first page of the outbox. This should be a good-enough
|
# Fetches the first page of the outbox. This should be a good-enough
|
||||||
# approximation of the number of statuses to show.
|
# approximation of the number of statuses to show.
|
||||||
statuses = json.loads(ap.signed_request(outbox["first"])).get(
|
statuses = json.loads(ap.signed_request(outbox["first"]).decode()).get(
|
||||||
"orderedItems", []
|
"orderedItems", []
|
||||||
)
|
)
|
||||||
irc.replies(
|
irc.replies(
|
||||||
|
@ -256,9 +256,7 @@ OUTBOX_FIRSTPAGE_VALUE = {
|
|||||||
}
|
}
|
||||||
OUTBOX_FIRSTPAGE_DATA = json.dumps(OUTBOX_FIRSTPAGE_VALUE).encode()
|
OUTBOX_FIRSTPAGE_DATA = json.dumps(OUTBOX_FIRSTPAGE_VALUE).encode()
|
||||||
|
|
||||||
BOOSTED_URL = (
|
BOOSTED_URL = "https://example.net/users/BoostedUser/statuses/123456"
|
||||||
"https://example.net/users/BoostedUser/statuses/123456"
|
|
||||||
)
|
|
||||||
BOOSTED_VALUE = {
|
BOOSTED_VALUE = {
|
||||||
"@context": [
|
"@context": [
|
||||||
"https://www.w3.org/ns/activitystreams",
|
"https://www.w3.org/ns/activitystreams",
|
||||||
|
Loading…
Reference in New Issue
Block a user