Support resolving group handles

merge-requests/30/head
Bob Mottram 2021-07-29 12:25:01 +01:00
parent 9f58bb4b6f
commit 2e4832fc52
1 changed files with 38 additions and 25 deletions

View File

@ -1207,6 +1207,7 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
if debug:
print('getActorJson for ' + handle)
originalActor = handle
requiresWebfinger = True
# try to determine the users path
detectedUsersPath = _detectUsersPath(handle)
@ -1214,6 +1215,8 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
detectedUsersPath in handle or \
handle.startswith('http') or \
handle.startswith('hyper'):
if detectedUsersPath == '/c/':
requiresWebfinger = False
# format: https://domain/@nick
originalHandle = handle
if not hasUsersPath(originalHandle):
@ -1252,6 +1255,10 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
return None, None
if handle.startswith('@'):
handle = handle[1:]
elif handle.startswith('!'):
# handle for a group
handle = handle[1:]
requiresWebfinger = False
if '@' not in handle:
if not quiet:
print('getActorJsonSyntax: --actor nickname@domain')
@ -1281,6 +1288,8 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
nickname = domain
handle = nickname + '@' + domain
if requiresWebfinger:
# person actor requires webfinger
wfRequest = webfingerHandle(session, handle,
httpPrefix, cachedWebfingers,
None, __version__, debug)
@ -1300,13 +1309,17 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
personUrl = None
if wfRequest.get('errors'):
if not quiet or debug:
print('getActorJson wfRequest error: ' + str(wfRequest['errors']))
print('getActorJson wfRequest error: ' +
str(wfRequest['errors']))
if hasUsersPath(handle):
personUrl = originalActor
else:
if debug:
print('No users path in ' + handle)
return None, None
else:
# group actor only needs a json http GET
personUrl = originalActor
profileStr = 'https://www.w3.org/ns/activitystreams'
headersList = (