mirror of https://gitlab.com/bashrc2/epicyon
Support resolving group handles
parent
9f58bb4b6f
commit
2e4832fc52
63
person.py
63
person.py
|
@ -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,32 +1288,38 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
|
|||
nickname = domain
|
||||
|
||||
handle = nickname + '@' + domain
|
||||
wfRequest = webfingerHandle(session, handle,
|
||||
httpPrefix, cachedWebfingers,
|
||||
None, __version__, debug)
|
||||
if not wfRequest:
|
||||
if not quiet:
|
||||
print('getActorJson Unable to webfinger ' + handle)
|
||||
return None, None
|
||||
if not isinstance(wfRequest, dict):
|
||||
if not quiet:
|
||||
print('getActorJson Webfinger for ' + handle +
|
||||
' did not return a dict. ' + str(wfRequest))
|
||||
return None, None
|
||||
|
||||
if not quiet:
|
||||
pprint(wfRequest)
|
||||
|
||||
personUrl = None
|
||||
if wfRequest.get('errors'):
|
||||
if not quiet or debug:
|
||||
print('getActorJson wfRequest error: ' + str(wfRequest['errors']))
|
||||
if hasUsersPath(handle):
|
||||
personUrl = originalActor
|
||||
else:
|
||||
if debug:
|
||||
print('No users path in ' + handle)
|
||||
if requiresWebfinger:
|
||||
# person actor requires webfinger
|
||||
wfRequest = webfingerHandle(session, handle,
|
||||
httpPrefix, cachedWebfingers,
|
||||
None, __version__, debug)
|
||||
if not wfRequest:
|
||||
if not quiet:
|
||||
print('getActorJson Unable to webfinger ' + handle)
|
||||
return None, None
|
||||
if not isinstance(wfRequest, dict):
|
||||
if not quiet:
|
||||
print('getActorJson Webfinger for ' + handle +
|
||||
' did not return a dict. ' + str(wfRequest))
|
||||
return None, None
|
||||
|
||||
if not quiet:
|
||||
pprint(wfRequest)
|
||||
|
||||
personUrl = None
|
||||
if wfRequest.get('errors'):
|
||||
if not quiet or debug:
|
||||
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 = (
|
||||
|
|
Loading…
Reference in New Issue