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