use fediverse display names when available

This commit is contained in:
jesopo 2019-12-10 11:45:29 +00:00
parent cffbcad430
commit 3848d878a4
2 changed files with 6 additions and 3 deletions

View file

@ -7,6 +7,7 @@ class Actor(object):
self.url = url self.url = url
self.username = None self.username = None
self.display_name = None
self.inbox = None self.inbox = None
self.outbox = None self.outbox = None
self.followers = None self.followers = None
@ -16,6 +17,7 @@ class Actor(object):
if response.code == 200: if response.code == 200:
response = response.json() response = response.json()
self.username = response["preferredUsername"] self.username = response["preferredUsername"]
self.display_name = response.get("name", self.username)
self.inbox = Inbox(response["inbox"]) self.inbox = Inbox(response["inbox"])
self.outbox = Outbox(response["outbox"]) self.outbox = Outbox(response["outbox"])
self.followers = response["followers"] self.followers = response["followers"]

View file

@ -132,10 +132,11 @@ def parse_note(actor, note, type="Create"):
original_tooter = ap_actor.Actor(retoot["attributedTo"]) original_tooter = ap_actor.Actor(retoot["attributedTo"])
original_tooter.load() original_tooter.load()
retooted_user = "@%s@%s" % (original_tooter.username, retoot_instance) retooted_user = "@%s@%s" % (original_tooter.display_name,
retoot_instance)
retoot_content = _content(retoot) retoot_content = _content(retoot)
author = "%s (boost %s)" % (actor.username, retooted_user) author = "%s (boost %s)" % (actor.display_name, retooted_user)
return (retoot.get("summary", None), author, retoot_content, retoot_url) return (retoot.get("summary", None), author, retoot_content, retoot_url)
@ -144,6 +145,6 @@ def parse_note(actor, note, type="Create"):
content = _content(note) content = _content(note)
url = note.get("url", note["id"]) url = note.get("url", note["id"])
return note.get("summary", None), actor.username, content, url return note.get("summary", None), actor.display_name, content, url
return None return None