mirror of https://gitlab.com/bashrc2/epicyon
Detecting group handle
parent
70240c84b1
commit
40f0aac017
|
@ -235,7 +235,7 @@ def sendAnnounceViaServer(baseDir: str, session,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
fromDomain, projectVersion, debug)
|
fromDomain, projectVersion, debug, False)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: announce webfinger failed for ' + handle)
|
print('DEBUG: announce webfinger failed for ' + handle)
|
||||||
|
@ -315,7 +315,7 @@ def sendUndoAnnounceViaServer(baseDir: str, session,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
domain, projectVersion, debug)
|
domain, projectVersion, debug, False)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: undo announce webfinger failed for ' + handle)
|
print('DEBUG: undo announce webfinger failed for ' + handle)
|
||||||
|
|
|
@ -107,7 +107,7 @@ def sendAvailabilityViaServer(baseDir: str, session,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
domain, projectVersion, debug)
|
domain, projectVersion, debug, False)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: availability webfinger failed for ' + handle)
|
print('DEBUG: availability webfinger failed for ' + handle)
|
||||||
|
|
|
@ -376,7 +376,7 @@ def sendBookmarkViaServer(baseDir: str, session,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
domain, projectVersion, debug)
|
domain, projectVersion, debug, False)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: bookmark webfinger failed for ' + handle)
|
print('DEBUG: bookmark webfinger failed for ' + handle)
|
||||||
|
@ -461,7 +461,7 @@ def sendUndoBookmarkViaServer(baseDir: str, session,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
domain, projectVersion, debug)
|
domain, projectVersion, debug, False)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: unbookmark webfinger failed for ' + handle)
|
print('DEBUG: unbookmark webfinger failed for ' + handle)
|
||||||
|
|
|
@ -57,7 +57,7 @@ def sendDeleteViaServer(baseDir: str, session,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = \
|
wfRequest = \
|
||||||
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
||||||
fromDomain, projectVersion, debug)
|
fromDomain, projectVersion, debug, False)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: delete webfinger failed for ' + handle)
|
print('DEBUG: delete webfinger failed for ' + handle)
|
||||||
|
|
|
@ -1765,7 +1765,7 @@ if args.followers:
|
||||||
handle = nickname + '@' + domain
|
handle = nickname + '@' + domain
|
||||||
wfRequest = webfingerHandle(session, handle,
|
wfRequest = webfingerHandle(session, handle,
|
||||||
httpPrefix, cachedWebfingers,
|
httpPrefix, cachedWebfingers,
|
||||||
None, __version__, debug)
|
None, __version__, debug, False)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
print('Unable to webfinger ' + handle)
|
print('Unable to webfinger ' + handle)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
|
@ -984,7 +984,7 @@ def sendFollowRequestViaServer(baseDir: str, session,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = \
|
wfRequest = \
|
||||||
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
||||||
fromDomain, projectVersion, debug)
|
fromDomain, projectVersion, debug, False)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: follow request webfinger failed for ' + handle)
|
print('DEBUG: follow request webfinger failed for ' + handle)
|
||||||
|
@ -1075,7 +1075,7 @@ def sendUnfollowRequestViaServer(baseDir: str, session,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = \
|
wfRequest = \
|
||||||
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
||||||
fromDomain, projectVersion, debug)
|
fromDomain, projectVersion, debug, False)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: unfollow webfinger failed for ' + handle)
|
print('DEBUG: unfollow webfinger failed for ' + handle)
|
||||||
|
|
4
like.py
4
like.py
|
@ -169,7 +169,7 @@ def sendLikeViaServer(baseDir: str, session,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
fromDomain, projectVersion, debug)
|
fromDomain, projectVersion, debug, False)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: like webfinger failed for ' + handle)
|
print('DEBUG: like webfinger failed for ' + handle)
|
||||||
|
@ -251,7 +251,7 @@ def sendUndoLikeViaServer(baseDir: str, session,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
fromDomain, projectVersion, debug)
|
fromDomain, projectVersion, debug, False)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: unlike webfinger failed for ' + handle)
|
print('DEBUG: unlike webfinger failed for ' + handle)
|
||||||
|
|
|
@ -58,7 +58,7 @@ def _updateMovedHandle(baseDir: str, nickname: str, domain: str,
|
||||||
handle = handle[1:]
|
handle = handle[1:]
|
||||||
wfRequest = webfingerHandle(session, handle,
|
wfRequest = webfingerHandle(session, handle,
|
||||||
httpPrefix, cachedWebfingers,
|
httpPrefix, cachedWebfingers,
|
||||||
None, __version__, debug)
|
None, __version__, debug, False)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
print('updateMovedHandle unable to webfinger ' + handle)
|
print('updateMovedHandle unable to webfinger ' + handle)
|
||||||
return ctr
|
return ctr
|
||||||
|
|
69
person.py
69
person.py
|
@ -53,6 +53,7 @@ from utils import getImageExtensions
|
||||||
from utils import isImageFile
|
from utils import isImageFile
|
||||||
from utils import acctDir
|
from utils import acctDir
|
||||||
from utils import getUserPaths
|
from utils import getUserPaths
|
||||||
|
from utils import getGroupPaths
|
||||||
from session import createSession
|
from session import createSession
|
||||||
from session import getJson
|
from session import getJson
|
||||||
from webfinger import webfingerHandle
|
from webfinger import webfingerHandle
|
||||||
|
@ -1213,7 +1214,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
|
groupAccount = False
|
||||||
|
|
||||||
# try to determine the users path
|
# try to determine the users path
|
||||||
detectedUsersPath = _detectUsersPath(handle)
|
detectedUsersPath = _detectUsersPath(handle)
|
||||||
|
@ -1221,9 +1222,9 @@ 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/':
|
groupPaths = getGroupPaths()
|
||||||
# requiresWebfinger = False
|
if detectedUsersPath in groupPaths:
|
||||||
requiresWebfinger = True
|
groupAccount = True
|
||||||
# format: https://domain/@nick
|
# format: https://domain/@nick
|
||||||
originalHandle = handle
|
originalHandle = handle
|
||||||
if not hasUsersPath(originalHandle):
|
if not hasUsersPath(originalHandle):
|
||||||
|
@ -1265,8 +1266,7 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
|
||||||
elif handle.startswith('!'):
|
elif handle.startswith('!'):
|
||||||
# handle for a group
|
# handle for a group
|
||||||
handle = handle[1:]
|
handle = handle[1:]
|
||||||
# requiresWebfinger = False
|
groupAccount = True
|
||||||
requiresWebfinger = True
|
|
||||||
if '@' not in handle:
|
if '@' not in handle:
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print('getActorJsonSyntax: --actor nickname@domain')
|
print('getActorJsonSyntax: --actor nickname@domain')
|
||||||
|
@ -1296,39 +1296,34 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
|
||||||
nickname = domain
|
nickname = domain
|
||||||
|
|
||||||
handle = nickname + '@' + domain
|
handle = nickname + '@' + domain
|
||||||
if requiresWebfinger:
|
wfRequest = webfingerHandle(session, handle,
|
||||||
# person actor requires webfinger
|
httpPrefix, cachedWebfingers,
|
||||||
wfRequest = webfingerHandle(session, handle,
|
None, __version__, debug,
|
||||||
httpPrefix, cachedWebfingers,
|
groupAccount)
|
||||||
None, __version__, debug)
|
if not wfRequest:
|
||||||
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:
|
if not quiet:
|
||||||
pprint(wfRequest)
|
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
|
||||||
|
|
||||||
personUrl = None
|
if not quiet:
|
||||||
if wfRequest.get('errors'):
|
pprint(wfRequest)
|
||||||
if not quiet or debug:
|
|
||||||
print('getActorJson wfRequest error: ' +
|
personUrl = None
|
||||||
str(wfRequest['errors']))
|
if wfRequest.get('errors'):
|
||||||
if hasUsersPath(handle):
|
if not quiet or debug:
|
||||||
personUrl = originalActor
|
print('getActorJson wfRequest error: ' +
|
||||||
else:
|
str(wfRequest['errors']))
|
||||||
if debug:
|
if hasUsersPath(handle):
|
||||||
print('No users path in ' + handle)
|
personUrl = originalActor
|
||||||
return None, None
|
else:
|
||||||
else:
|
if debug:
|
||||||
# group actor only needs a json http GET
|
print('No users path in ' + handle)
|
||||||
originalActor = httpPrefix + '://' + domain + '/c/' + nickname
|
return None, None
|
||||||
personUrl = originalActor
|
|
||||||
|
|
||||||
profileStr = 'https://www.w3.org/ns/activitystreams'
|
profileStr = 'https://www.w3.org/ns/activitystreams'
|
||||||
headersList = (
|
headersList = (
|
||||||
|
|
2
pgp.py
2
pgp.py
|
@ -547,7 +547,7 @@ def pgpPublicKeyUpload(baseDir: str, session,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = \
|
wfRequest = \
|
||||||
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
||||||
domain, __version__, debug)
|
domain, __version__, debug, False)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: pgp actor update webfinger failed for ' +
|
print('DEBUG: pgp actor update webfinger failed for ' +
|
||||||
|
|
22
posts.py
22
posts.py
|
@ -1957,7 +1957,7 @@ def sendPost(projectVersion: str,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
domain, projectVersion, debug)
|
domain, projectVersion, debug, False)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
return 1
|
return 1
|
||||||
if not isinstance(wfRequest, dict):
|
if not isinstance(wfRequest, dict):
|
||||||
|
@ -2077,7 +2077,7 @@ def sendPostViaServer(projectVersion: str,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = \
|
wfRequest = \
|
||||||
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
||||||
fromDomain, projectVersion, debug)
|
fromDomain, projectVersion, debug, False)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: post webfinger failed for ' + handle)
|
print('DEBUG: post webfinger failed for ' + handle)
|
||||||
|
@ -2275,7 +2275,7 @@ def sendSignedJson(postJsonObject: {}, session, baseDir: str,
|
||||||
|
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
wfRequest = webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
||||||
domain, projectVersion, debug)
|
domain, projectVersion, debug, False)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: webfinger for ' + handle + ' failed')
|
print('DEBUG: webfinger for ' + handle + ' failed')
|
||||||
|
@ -2624,7 +2624,7 @@ def _hasSharedInbox(session, httpPrefix: str, domain: str,
|
||||||
]
|
]
|
||||||
for handle in tryHandles:
|
for handle in tryHandles:
|
||||||
wfRequest = webfingerHandle(session, handle, httpPrefix, {},
|
wfRequest = webfingerHandle(session, handle, httpPrefix, {},
|
||||||
None, __version__, debug)
|
None, __version__, debug, False)
|
||||||
if wfRequest:
|
if wfRequest:
|
||||||
if isinstance(wfRequest, dict):
|
if isinstance(wfRequest, dict):
|
||||||
if not wfRequest.get('errors'):
|
if not wfRequest.get('errors'):
|
||||||
|
@ -3594,7 +3594,7 @@ def getPublicPostsOfPerson(baseDir: str, nickname: str, domain: str,
|
||||||
handle = httpPrefix + "://" + domainFull + "/@" + nickname
|
handle = httpPrefix + "://" + domainFull + "/@" + nickname
|
||||||
wfRequest = \
|
wfRequest = \
|
||||||
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
||||||
domain, projectVersion, debug)
|
domain, projectVersion, debug, False)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
if not isinstance(wfRequest, dict):
|
if not isinstance(wfRequest, dict):
|
||||||
|
@ -3637,7 +3637,7 @@ def getPublicPostDomains(session, baseDir: str, nickname: str, domain: str,
|
||||||
handle = httpPrefix + "://" + domainFull + "/@" + nickname
|
handle = httpPrefix + "://" + domainFull + "/@" + nickname
|
||||||
wfRequest = \
|
wfRequest = \
|
||||||
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
||||||
domain, projectVersion, debug)
|
domain, projectVersion, debug, False)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
return domainList
|
return domainList
|
||||||
if not isinstance(wfRequest, dict):
|
if not isinstance(wfRequest, dict):
|
||||||
|
@ -3717,7 +3717,7 @@ def getPublicPostInfo(session, baseDir: str, nickname: str, domain: str,
|
||||||
handle = httpPrefix + "://" + domainFull + "/@" + nickname
|
handle = httpPrefix + "://" + domainFull + "/@" + nickname
|
||||||
wfRequest = \
|
wfRequest = \
|
||||||
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
||||||
domain, projectVersion, debug)
|
domain, projectVersion, debug, False)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
return {}
|
return {}
|
||||||
if not isinstance(wfRequest, dict):
|
if not isinstance(wfRequest, dict):
|
||||||
|
@ -4214,7 +4214,7 @@ def sendBlockViaServer(baseDir: str, session,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
fromDomain, projectVersion, debug)
|
fromDomain, projectVersion, debug, False)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: block webfinger failed for ' + handle)
|
print('DEBUG: block webfinger failed for ' + handle)
|
||||||
|
@ -4290,7 +4290,7 @@ def sendMuteViaServer(baseDir: str, session,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
fromDomain, projectVersion, debug)
|
fromDomain, projectVersion, debug, False)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: mute webfinger failed for ' + handle)
|
print('DEBUG: mute webfinger failed for ' + handle)
|
||||||
|
@ -4371,7 +4371,7 @@ def sendUndoMuteViaServer(baseDir: str, session,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
fromDomain, projectVersion, debug)
|
fromDomain, projectVersion, debug, False)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: undo mute webfinger failed for ' + handle)
|
print('DEBUG: undo mute webfinger failed for ' + handle)
|
||||||
|
@ -4457,7 +4457,7 @@ def sendUndoBlockViaServer(baseDir: str, session,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
fromDomain, projectVersion, debug)
|
fromDomain, projectVersion, debug, False)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: unblock webfinger failed for ' + handle)
|
print('DEBUG: unblock webfinger failed for ' + handle)
|
||||||
|
|
|
@ -509,7 +509,7 @@ def sendShareViaServer(baseDir, session,
|
||||||
wfRequest = \
|
wfRequest = \
|
||||||
webfingerHandle(session, handle, httpPrefix,
|
webfingerHandle(session, handle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
fromDomain, projectVersion, debug)
|
fromDomain, projectVersion, debug, False)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: share webfinger failed for ' + handle)
|
print('DEBUG: share webfinger failed for ' + handle)
|
||||||
|
@ -610,7 +610,7 @@ def sendUndoShareViaServer(baseDir: str, session,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = \
|
wfRequest = \
|
||||||
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
||||||
fromDomain, projectVersion, debug)
|
fromDomain, projectVersion, debug, False)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: unshare webfinger failed for ' + handle)
|
print('DEBUG: unshare webfinger failed for ' + handle)
|
||||||
|
|
|
@ -208,7 +208,7 @@ def sendSkillViaServer(baseDir: str, session, nickname: str, password: str,
|
||||||
wfRequest = \
|
wfRequest = \
|
||||||
webfingerHandle(session, handle, httpPrefix,
|
webfingerHandle(session, handle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
domain, projectVersion, debug)
|
domain, projectVersion, debug, False)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: skill webfinger failed for ' + handle)
|
print('DEBUG: skill webfinger failed for ' + handle)
|
||||||
|
|
|
@ -54,7 +54,7 @@ def instancesGraph(baseDir: str, handles: str,
|
||||||
wfRequest = \
|
wfRequest = \
|
||||||
webfingerHandle(session, handle, httpPrefix,
|
webfingerHandle(session, handle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
domain, projectVersion, debug)
|
domain, projectVersion, debug, False)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
return dotGraphStr + '}\n'
|
return dotGraphStr + '}\n'
|
||||||
if not isinstance(wfRequest, dict):
|
if not isinstance(wfRequest, dict):
|
||||||
|
|
7
utils.py
7
utils.py
|
@ -979,6 +979,13 @@ def getUserPaths() -> []:
|
||||||
return ('/users/', '/profile/', '/accounts/', '/channel/', '/u/', '/c/')
|
return ('/users/', '/profile/', '/accounts/', '/channel/', '/u/', '/c/')
|
||||||
|
|
||||||
|
|
||||||
|
def getGroupPaths() -> []:
|
||||||
|
"""Returns possible group paths
|
||||||
|
e.g. /c/groupname
|
||||||
|
"""
|
||||||
|
return ('/c/')
|
||||||
|
|
||||||
|
|
||||||
def getDomainFromActor(actor: str) -> (str, int):
|
def getDomainFromActor(actor: str) -> (str, int):
|
||||||
"""Returns the domain name from an actor url
|
"""Returns the domain name from an actor url
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1183,7 +1183,7 @@ def individualPostAsHtml(allowDownloads: bool,
|
||||||
postActorWf = \
|
postActorWf = \
|
||||||
webfingerHandle(session, postActorHandle, httpPrefix,
|
webfingerHandle(session, postActorHandle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
domain, __version__, False)
|
domain, __version__, False, False)
|
||||||
|
|
||||||
avatarUrl2 = None
|
avatarUrl2 = None
|
||||||
displayName = None
|
displayName = None
|
||||||
|
|
|
@ -2053,7 +2053,7 @@ def _individualFollowAsHtml(translate: {},
|
||||||
followUrlWf = \
|
followUrlWf = \
|
||||||
webfingerHandle(session, followUrlHandle, httpPrefix,
|
webfingerHandle(session, followUrlHandle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
domain, __version__, debug)
|
domain, __version__, debug, False)
|
||||||
|
|
||||||
(inboxUrl, pubKeyId, pubKey,
|
(inboxUrl, pubKeyId, pubKey,
|
||||||
fromPersonId, sharedInbox,
|
fromPersonId, sharedInbox,
|
||||||
|
|
58
webfinger.py
58
webfinger.py
|
@ -19,13 +19,15 @@ from utils import saveJson
|
||||||
from utils import getProtocolPrefixes
|
from utils import getProtocolPrefixes
|
||||||
from utils import removeDomainPort
|
from utils import removeDomainPort
|
||||||
from utils import getUserPaths
|
from utils import getUserPaths
|
||||||
|
from utils import getGroupPaths
|
||||||
|
|
||||||
|
|
||||||
def _parseHandle(handle: str) -> (str, str):
|
def _parseHandle(handle: str) -> (str, str, bool):
|
||||||
"""Parses a handle and returns nickname and domain
|
"""Parses a handle and returns nickname and domain
|
||||||
"""
|
"""
|
||||||
|
groupAccount = False
|
||||||
if '.' not in handle:
|
if '.' not in handle:
|
||||||
return None, None
|
return None, None, False
|
||||||
prefixes = getProtocolPrefixes()
|
prefixes = getProtocolPrefixes()
|
||||||
handleStr = handle
|
handleStr = handle
|
||||||
for prefix in prefixes:
|
for prefix in prefixes:
|
||||||
|
@ -34,27 +36,33 @@ def _parseHandle(handle: str) -> (str, str):
|
||||||
# try domain/@nick
|
# try domain/@nick
|
||||||
if '/@' in handle:
|
if '/@' in handle:
|
||||||
domain, nickname = handleStr.split('/@')
|
domain, nickname = handleStr.split('/@')
|
||||||
return nickname, domain
|
return nickname, domain, False
|
||||||
|
|
||||||
# try nick@domain
|
# try nick@domain
|
||||||
if '@' in handle:
|
if '@' in handle:
|
||||||
|
if handle.startswith('!'):
|
||||||
|
handle = handle[1:]
|
||||||
|
groupAccount = True
|
||||||
nickname, domain = handle.split('@')
|
nickname, domain = handle.split('@')
|
||||||
return nickname, domain
|
return nickname, domain, groupAccount
|
||||||
|
|
||||||
# try for different /users/ paths
|
# try for different /users/ paths
|
||||||
usersPaths = getUserPaths()
|
usersPaths = getUserPaths()
|
||||||
|
groupPaths = getGroupPaths()
|
||||||
for possibleUsersPath in usersPaths:
|
for possibleUsersPath in usersPaths:
|
||||||
if possibleUsersPath in handle:
|
if possibleUsersPath in handle:
|
||||||
|
if possibleUsersPath in groupPaths:
|
||||||
|
groupAccount = True
|
||||||
domain, nickname = handleStr.split(possibleUsersPath)
|
domain, nickname = handleStr.split(possibleUsersPath)
|
||||||
return nickname, domain
|
return nickname, domain, groupAccount
|
||||||
|
|
||||||
return None, None
|
return None, None, False
|
||||||
|
|
||||||
|
|
||||||
def webfingerHandle(session, handle: str, httpPrefix: str,
|
def webfingerHandle(session, handle: str, httpPrefix: str,
|
||||||
cachedWebfingers: {},
|
cachedWebfingers: {},
|
||||||
fromDomain: str, projectVersion: str,
|
fromDomain: str, projectVersion: str,
|
||||||
debug: bool) -> {}:
|
debug: bool, groupAccount: bool) -> {}:
|
||||||
"""Gets webfinger result for the given ActivityPub handle
|
"""Gets webfinger result for the given ActivityPub handle
|
||||||
"""
|
"""
|
||||||
if not session:
|
if not session:
|
||||||
|
@ -62,9 +70,11 @@ def webfingerHandle(session, handle: str, httpPrefix: str,
|
||||||
print('WARN: No session specified for webfingerHandle')
|
print('WARN: No session specified for webfingerHandle')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
nickname, domain = _parseHandle(handle)
|
nickname, domain, grpAccount = _parseHandle(handle)
|
||||||
if not nickname:
|
if not nickname:
|
||||||
return None
|
return None
|
||||||
|
if grpAccount:
|
||||||
|
groupAccount = True
|
||||||
wfDomain = removeDomainPort(domain)
|
wfDomain = removeDomainPort(domain)
|
||||||
|
|
||||||
wfHandle = nickname + '@' + wfDomain
|
wfHandle = nickname + '@' + wfDomain
|
||||||
|
@ -77,34 +87,22 @@ def webfingerHandle(session, handle: str, httpPrefix: str,
|
||||||
hdr = {
|
hdr = {
|
||||||
'Accept': 'application/jrd+json'
|
'Accept': 'application/jrd+json'
|
||||||
}
|
}
|
||||||
par = {
|
if not groupAccount:
|
||||||
'resource': 'acct:{}'.format(wfHandle)
|
par = {
|
||||||
}
|
'resource': 'acct:{}'.format(wfHandle)
|
||||||
success = False
|
}
|
||||||
|
else:
|
||||||
|
par = {
|
||||||
|
'resource': 'group:{}'.format(wfHandle)
|
||||||
|
}
|
||||||
try:
|
try:
|
||||||
result = \
|
result = \
|
||||||
getJson(session, url, hdr, par,
|
getJson(session, url, hdr, par,
|
||||||
debug, projectVersion,
|
debug, projectVersion,
|
||||||
httpPrefix, fromDomain)
|
httpPrefix, fromDomain)
|
||||||
if result:
|
|
||||||
success = True
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('ERROR: webfingerHandle acct ' + str(e))
|
print('ERROR: webfingerHandle ' + str(e))
|
||||||
pass
|
return None
|
||||||
if not success:
|
|
||||||
par = {
|
|
||||||
'resource': 'group:{}'.format(wfHandle)
|
|
||||||
}
|
|
||||||
try:
|
|
||||||
result = \
|
|
||||||
getJson(session, url, hdr, par,
|
|
||||||
debug, projectVersion,
|
|
||||||
httpPrefix, fromDomain)
|
|
||||||
if result:
|
|
||||||
success = True
|
|
||||||
except Exception as e:
|
|
||||||
print('ERROR: webfingerHandle group ' + str(e))
|
|
||||||
return None
|
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
storeWebfingerInCache(wfHandle, result, cachedWebfingers)
|
storeWebfingerInCache(wfHandle, result, cachedWebfingers)
|
||||||
|
|
Loading…
Reference in New Issue