component AP gateway: getAPAccountFromId now works with local IDs:
rel 370
This commit is contained in:
parent
fe4dc35f5c
commit
575c3fe768
1 changed files with 21 additions and 0 deletions
|
|
@ -1051,8 +1051,29 @@ class APGateway:
|
|||
async def getAPAccountFromId(self, actor_id: str) -> str:
|
||||
"""Retrieve AP account from the ID URL
|
||||
|
||||
Works with external or local actor IDs.
|
||||
@param actor_id: AP ID of the actor (URL to the actor data)
|
||||
@return: AP handle
|
||||
"""
|
||||
if self.isLocalURL(actor_id):
|
||||
url_type, url_args = self.parseAPURL(actor_id)
|
||||
if url_type != "actor" or not url_args:
|
||||
raise exceptions.DataError(
|
||||
f"invalid local actor ID: {actor_id}"
|
||||
)
|
||||
account = url_args[0]
|
||||
try:
|
||||
account_user, account_host = account.split('@')
|
||||
except ValueError:
|
||||
raise exceptions.DataError(
|
||||
f"invalid account from url: {actor_id}"
|
||||
)
|
||||
if not account_user or account_host != self.public_url:
|
||||
raise exceptions.DataError(
|
||||
f"{account!r} is not a valid local account (from {actor_id})"
|
||||
)
|
||||
return account
|
||||
|
||||
url_parsed = parse.urlparse(actor_id)
|
||||
actor_data = await self.getActorData(actor_id)
|
||||
username = actor_data.get("preferredUsername")
|
||||
|
|
|
|||
Loading…
Reference in a new issue