From 1c732f5d705b5203a11beb77e0b7a4bcfe1a0a00 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 3 Jun 2021 19:49:09 +0100 Subject: [PATCH] Resolving smithereen actors --- person.py | 5 +++-- utils.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/person.py b/person.py index d0927ba7a..f3386a658 100644 --- a/person.py +++ b/person.py @@ -1332,7 +1332,7 @@ def getActorJson(handle: str, http: bool, gnunet: bool, personUrl = personUrl.replace('/u/', '/actor/') if not personUrl: # try single user instance - personUrl = httpPrefix + '://' + domain + personUrl = httpPrefix + '://' + domain + '/' + nickname headersList = ( "ld+json", "jrd+json", "activity+json" ) @@ -1340,7 +1340,8 @@ def getActorJson(handle: str, http: bool, gnunet: bool, headersList = ( "ld+json", "jrd+json", "activity+json" ) - + if debug: + print('personUrl: ' + personUrl) for headerType in headersList: headerMimeType = 'application/' + headerType asHeader = { diff --git a/utils.py b/utils.py index 98e0dd309..428a6c5f3 100644 --- a/utils.py +++ b/utils.py @@ -851,6 +851,16 @@ def getNicknameFromActor(actor: str) -> str: elif '@' in actor: nickStr = actor.split('@')[0] return nickStr + elif '://' in actor: + domain = actor.split('://')[1] + if '/' in domain: + domain = domain.split('/')[0] + if '://' + domain + '/' not in actor: + return None + nickStr = actor.split('://' + domain + '/')[1] + if '/' in nickStr or '.' in nickStr: + return None + return nickStr return None nickStr = actor.split('/users/')[1].replace('@', '') if '/' not in nickStr: