pass full Response from ap_utils.activity_request, use it for Actor 404
This commit is contained in:
parent
ee6360be22
commit
f84b48adbe
2 changed files with 15 additions and 13 deletions
|
@ -11,10 +11,13 @@ class Actor(object):
|
|||
self.outbox = None
|
||||
|
||||
def load(self):
|
||||
data = ap_utils.activity_request(self.url)
|
||||
self.username = data["preferredUsername"]
|
||||
self.inbox = Inbox(data["inbox"])
|
||||
self.outbox = Outbox(data["outbox"])
|
||||
response = ap_utils.activity_request(self.url)
|
||||
if response.code == 200:
|
||||
self.username = response.data["preferredUsername"]
|
||||
self.inbox = Inbox(response.data["inbox"])
|
||||
self.outbox = Outbox(responsedata["outbox"])
|
||||
return True
|
||||
return False
|
||||
|
||||
class Outbox(object):
|
||||
def __init__(self, url):
|
||||
|
@ -24,16 +27,16 @@ class Outbox(object):
|
|||
outbox = ap_utils.activity_request(self._url)
|
||||
|
||||
items = None
|
||||
if "first" in outbox:
|
||||
if type(outbox["first"]) == dict:
|
||||
if "first" in outbox.data:
|
||||
if type(outbox.data["first"]) == dict:
|
||||
# pleroma
|
||||
items = outbox["first"]["orderedItems"]
|
||||
items = outbox.data["first"]["orderedItems"]
|
||||
else:
|
||||
# mastodon
|
||||
first = ap_utils.activity_request(outbox["first"])
|
||||
first = ap_utils.activity_request(outbox.data["first"])
|
||||
items = first["orderedItems"]
|
||||
else:
|
||||
items = outbox["orderedItems"]
|
||||
items = outbox.data["orderedItems"]
|
||||
return items
|
||||
|
||||
class Inbox(object):
|
||||
|
@ -53,5 +56,5 @@ class Inbox(object):
|
|||
headers.append(["signature", signature])
|
||||
|
||||
return ap_utils.activity_request(self._url, activity.format(sender),
|
||||
method="POST", headers=dict(headers))
|
||||
method="POST", headers=dict(headers)).data
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ def activity_request(url, data=None, method="GET", type=ACTIVITY_TYPE,
|
|||
request = utils.http.Request(url, headers=headers, useragent=USERAGENT,
|
||||
content_type=content_type, post_data=data, method=method, json=True,
|
||||
json_body=True)
|
||||
return utils.http.request(request).data
|
||||
return utils.http.request(request)
|
||||
|
||||
HOSTMETA_TEMPLATE = "https://%s/.well-known/host-meta"
|
||||
WEBFINGER_TEMPLATE = "https://%s/.well-known/webfinger?resource={uri}"
|
||||
|
@ -51,7 +51,7 @@ def find_actor(username, instance):
|
|||
webfinger = activity_request(webfinger_url, type=JRD_TYPE)
|
||||
|
||||
actor_url = None
|
||||
for link in webfinger["links"]:
|
||||
for link in webfinger.data["links"]:
|
||||
if link["type"] == ACTIVITY_TYPE:
|
||||
return link["href"]
|
||||
|
||||
|
@ -63,7 +63,6 @@ def format_note(actor, note):
|
|||
|
||||
original_tooter = ap_actor.Actor(retoot.data["attributedTo"])
|
||||
original_tooter.load()
|
||||
original_tooter = activity_request(original_tooter_url)
|
||||
retooted_user = "@%s@%s" % (original_tooter.username, retoot_instance)
|
||||
retoot_content = utils.http.strip_html(retoot.data["content"])
|
||||
|
||||
|
|
Loading…
Reference in a new issue