Snake case

main
Bob Mottram 2021-12-26 00:07:44 +00:00
parent 49308fbcb5
commit 81141ad35b
13 changed files with 135 additions and 132 deletions

View File

@ -75,8 +75,8 @@ def createReject(base_dir: str, federation_list: [],
http_prefix, objectJson, 'Reject')
def _acceptFollow(base_dir: str, domain: str, message_json: {},
federation_list: [], debug: bool) -> None:
def _accept_follow(base_dir: str, domain: str, message_json: {},
federation_list: [], debug: bool) -> None:
"""Receiving a follow Accept activity
"""
if not hasObjectStringType(message_json, debug):
@ -98,87 +98,89 @@ def _acceptFollow(base_dir: str, domain: str, message_json: {},
return
if debug:
print('DEBUG: follow Accept received')
thisActor = message_json['object']['actor']
nickname = getNicknameFromActor(thisActor)
this_actor = message_json['object']['actor']
nickname = getNicknameFromActor(this_actor)
if not nickname:
print('WARN: no nickname found in ' + thisActor)
print('WARN: no nickname found in ' + this_actor)
return
acceptedDomain, acceptedPort = getDomainFromActor(thisActor)
acceptedDomain, acceptedPort = getDomainFromActor(this_actor)
if not acceptedDomain:
if debug:
print('DEBUG: domain not found in ' + thisActor)
print('DEBUG: domain not found in ' + this_actor)
return
if not nickname:
if debug:
print('DEBUG: nickname not found in ' + thisActor)
print('DEBUG: nickname not found in ' + this_actor)
return
if acceptedPort:
if '/' + acceptedDomain + ':' + str(acceptedPort) + \
'/users/' + nickname not in thisActor:
'/users/' + nickname not in this_actor:
if debug:
print('Port: ' + str(acceptedPort))
print('Expected: /' + acceptedDomain + ':' +
str(acceptedPort) + '/users/' + nickname)
print('Actual: ' + thisActor)
print('DEBUG: unrecognized actor ' + thisActor)
print('Actual: ' + this_actor)
print('DEBUG: unrecognized actor ' + this_actor)
return
else:
if not '/' + acceptedDomain + '/users/' + nickname in thisActor:
if not '/' + acceptedDomain + '/users/' + nickname in this_actor:
if debug:
print('Expected: /' + acceptedDomain + '/users/' + nickname)
print('Actual: ' + thisActor)
print('DEBUG: unrecognized actor ' + thisActor)
print('Actual: ' + this_actor)
print('DEBUG: unrecognized actor ' + this_actor)
return
followedActor = message_json['object']['object']
followedDomain, port = getDomainFromActor(followedActor)
if not followedDomain:
followed_actor = message_json['object']['object']
followed_domain, port = getDomainFromActor(followed_actor)
if not followed_domain:
print('DEBUG: no domain found within Follow activity object ' +
followedActor)
followed_actor)
return
followedDomainFull = followedDomain
followed_domain_full = followed_domain
if port:
followedDomainFull = followedDomain + ':' + str(port)
followedNickname = getNicknameFromActor(followedActor)
if not followedNickname:
followed_domain_full = followed_domain + ':' + str(port)
followed_nickname = getNicknameFromActor(followed_actor)
if not followed_nickname:
print('DEBUG: no nickname found within Follow activity object ' +
followedActor)
followed_actor)
return
acceptedDomainFull = acceptedDomain
accepted_domain_full = acceptedDomain
if acceptedPort:
acceptedDomainFull = acceptedDomain + ':' + str(acceptedPort)
accepted_domain_full = acceptedDomain + ':' + str(acceptedPort)
# has this person already been unfollowed?
unfollowedFilename = \
acctDir(base_dir, nickname, acceptedDomainFull) + '/unfollowed.txt'
if os.path.isfile(unfollowedFilename):
if followedNickname + '@' + followedDomainFull in \
open(unfollowedFilename).read():
unfollowed_filename = \
acctDir(base_dir, nickname, accepted_domain_full) + '/unfollowed.txt'
if os.path.isfile(unfollowed_filename):
if followed_nickname + '@' + followed_domain_full in \
open(unfollowed_filename).read():
if debug:
print('DEBUG: follow accept arrived for ' +
nickname + '@' + acceptedDomainFull +
' from ' + followedNickname + '@' + followedDomainFull +
nickname + '@' + accepted_domain_full +
' from ' +
followed_nickname + '@' + followed_domain_full +
' but they have been unfollowed')
return
# does the url path indicate that this is a group actor
groupAccount = hasGroupType(base_dir, followedActor, None, debug)
group_account = hasGroupType(base_dir, followed_actor, None, debug)
if debug:
print('Accepted follow is a group: ' + str(groupAccount) +
' ' + followedActor + ' ' + base_dir)
print('Accepted follow is a group: ' + str(group_account) +
' ' + followed_actor + ' ' + base_dir)
if followPerson(base_dir,
nickname, acceptedDomainFull,
followedNickname, followedDomainFull,
federation_list, debug, groupAccount):
nickname, accepted_domain_full,
followed_nickname, followed_domain_full,
federation_list, debug, group_account):
if debug:
print('DEBUG: ' + nickname + '@' + acceptedDomainFull +
' followed ' + followedNickname + '@' + followedDomainFull)
print('DEBUG: ' + nickname + '@' + accepted_domain_full +
' followed ' +
followed_nickname + '@' + followed_domain_full)
else:
if debug:
print('DEBUG: Unable to create follow - ' +
nickname + '@' + acceptedDomain + ' -> ' +
followedNickname + '@' + followedDomain)
followed_nickname + '@' + followed_domain)
def receiveAcceptReject(session, base_dir: str,
@ -198,7 +200,7 @@ def receiveAcceptReject(session, base_dir: str,
if debug:
print('DEBUG: "users" or "profile" missing from actor in ' +
message_json['type'] + '. Assuming single user instance.')
domain, tempPort = getDomainFromActor(message_json['actor'])
domain, _ = getDomainFromActor(message_json['actor'])
if not domainPermitted(domain, federation_list):
if debug:
print('DEBUG: ' + message_json['type'] +
@ -213,7 +215,7 @@ def receiveAcceptReject(session, base_dir: str,
' does not contain a nickname. ' +
'Assuming single user instance.')
# receive follow accept
_acceptFollow(base_dir, domain, message_json, federation_list, debug)
_accept_follow(base_dir, domain, message_json, federation_list, debug)
if debug:
print('DEBUG: Uh, ' + message_json['type'] + ', I guess')
return True

View File

@ -163,7 +163,7 @@ def createAnnounce(session, base_dir: str, federation_list: [],
announceNickname = None
announceDomain = None
announcePort = None
groupAccount = False
group_account = False
if hasUsersPath(objectUrl):
announceNickname = getNicknameFromActor(objectUrl)
announceDomain, announcePort = getDomainFromActor(objectUrl)
@ -172,7 +172,7 @@ def createAnnounce(session, base_dir: str, federation_list: [],
objectUrl.split('/' + announceNickname + '/')[0] + \
'/' + announceNickname
if hasGroupType(base_dir, announceActor, person_cache):
groupAccount = True
group_account = True
if announceNickname and announceDomain:
sendSignedJson(newAnnounce, session, base_dir,
@ -180,7 +180,7 @@ def createAnnounce(session, base_dir: str, federation_list: [],
announceNickname, announceDomain, announcePort, None,
http_prefix, True, client_to_server, federation_list,
send_threads, postLog, cached_webfingers, person_cache,
debug, project_version, None, groupAccount,
debug, project_version, None, group_account,
signing_priv_key_pem, 639633)
return newAnnounce

View File

@ -2954,13 +2954,13 @@ class PubServer(BaseHTTPRequestHandler):
}
pathUsersSection = path.split('/users/')[1]
self.postToNickname = pathUsersSection.split('/')[0]
groupAccount = hasGroupType(self.server.base_dir,
followingActor,
self.server.person_cache)
group_account = hasGroupType(self.server.base_dir,
followingActor,
self.server.person_cache)
unfollowAccount(self.server.base_dir, self.postToNickname,
self.server.domain,
followingNickname, followingDomainFull,
self.server.debug, groupAccount)
self.server.debug, group_account)
self._postToOutboxThread(unfollowJson)
if callingDomain.endswith('.onion') and onion_domain:

View File

@ -209,12 +209,12 @@ def getMutualsOfPerson(base_dir: str,
def followerOfPerson(base_dir: str, nickname: str, domain: str,
followerNickname: str, followerDomain: str,
federation_list: [], debug: bool,
groupAccount: bool) -> bool:
group_account: bool) -> bool:
"""Adds a follower of the given person
"""
return followPerson(base_dir, nickname, domain,
followerNickname, followerDomain,
federation_list, debug, groupAccount, 'followers.txt')
federation_list, debug, group_account, 'followers.txt')
def getFollowerDomains(base_dir: str, nickname: str, domain: str) -> []:
@ -283,14 +283,14 @@ def isFollowerOfPerson(base_dir: str, nickname: str, domain: str,
def unfollowAccount(base_dir: str, nickname: str, domain: str,
followNickname: str, followDomain: str,
debug: bool, groupAccount: bool,
debug: bool, group_account: bool,
followFile: str = 'following.txt') -> bool:
"""Removes a person to the follow list
"""
domain = removeDomainPort(domain)
handle = nickname + '@' + domain
handleToUnfollow = followNickname + '@' + followDomain
if groupAccount:
if group_account:
handleToUnfollow = '!' + handleToUnfollow
if not os.path.isdir(base_dir + '/accounts'):
os.mkdir(base_dir + '/accounts')
@ -348,12 +348,12 @@ def unfollowAccount(base_dir: str, nickname: str, domain: str,
def unfollowerOfAccount(base_dir: str, nickname: str, domain: str,
followerNickname: str, followerDomain: str,
debug: bool, groupAccount: bool) -> bool:
debug: bool, group_account: bool) -> bool:
"""Remove a follower of a person
"""
return unfollowAccount(base_dir, nickname, domain,
followerNickname, followerDomain,
debug, groupAccount, 'followers.txt')
debug, group_account, 'followers.txt')
def clearFollows(base_dir: str, nickname: str, domain: str,
@ -624,7 +624,7 @@ def storeFollowRequest(base_dir: str,
nickname: str, domain: str, fromPort: int,
followJson: {},
debug: bool, personUrl: str,
groupAccount: bool) -> bool:
group_account: bool) -> bool:
"""Stores the follow request for later use
"""
accountsDir = base_dir + '/accounts/' + \
@ -635,7 +635,7 @@ def storeFollowRequest(base_dir: str,
domainFull = getFullDomain(domain, fromPort)
approveHandle = getFullDomain(nickname + '@' + domain, fromPort)
if groupAccount:
if group_account:
approveHandle = '!' + approveHandle
followersFilename = accountsDir + '/followers.txt'
@ -683,7 +683,7 @@ def storeFollowRequest(base_dir: str,
approveHandleStored = approveHandle
if '/users/' not in personUrl:
approveHandleStored = personUrl
if groupAccount:
if group_account:
approveHandle = '!' + approveHandle
if os.path.isfile(approveFollowsFilename):
@ -759,11 +759,11 @@ def followedAccountAccepts(session, base_dir: str, http_prefix: str,
print('EX: followedAccountAccepts unable to delete ' +
followActivityfilename)
groupAccount = False
group_account = False
if followJson:
if followJson.get('actor'):
if hasGroupType(base_dir, followJson['actor'], person_cache):
groupAccount = True
group_account = True
return sendSignedJson(acceptJson, session, base_dir,
nicknameToFollow, domainToFollow, port,
@ -772,7 +772,7 @@ def followedAccountAccepts(session, base_dir: str, http_prefix: str,
federation_list,
send_threads, postLog, cached_webfingers,
person_cache, debug, project_version, None,
groupAccount, signing_priv_key_pem,
group_account, signing_priv_key_pem,
7856837)
@ -820,9 +820,9 @@ def followedAccountRejects(session, base_dir: str, http_prefix: str,
nickname + '@' + domain + ' port ' + str(fromPort))
client_to_server = False
denyHandle = getFullDomain(nickname + '@' + domain, fromPort)
groupAccount = False
group_account = False
if hasGroupType(base_dir, personUrl, person_cache):
groupAccount = True
group_account = True
# remove from the follow requests file
removeFromFollowRequests(base_dir, nicknameToFollow, domainToFollow,
denyHandle, debug)
@ -840,7 +840,7 @@ def followedAccountRejects(session, base_dir: str, http_prefix: str,
federation_list,
send_threads, postLog, cached_webfingers,
person_cache, debug, project_version, None,
groupAccount, signing_priv_key_pem,
group_account, signing_priv_key_pem,
6393063)
@ -869,12 +869,12 @@ def sendFollowRequest(session, base_dir: str,
statusNumber, published = getStatusNumber()
groupAccount = False
group_account = False
if followNickname:
followedId = followedActor
followHandle = followNickname + '@' + requestDomain
groupAccount = hasGroupType(base_dir, followedActor, person_cache)
if groupAccount:
group_account = hasGroupType(base_dir, followedActor, person_cache)
if group_account:
followHandle = '!' + followHandle
print('Follow request being sent to group account')
else:
@ -911,7 +911,7 @@ def sendFollowRequest(session, base_dir: str,
'actor': followActor,
'object': followedId
}
if groupAccount:
if group_account:
newFollowJson['to'] = followedId
print('Follow request: ' + str(newFollowJson))
@ -931,7 +931,7 @@ def sendFollowRequest(session, base_dir: str,
http_prefix, True, client_to_server,
federation_list,
send_threads, postLog, cached_webfingers, person_cache,
debug, project_version, None, groupAccount,
debug, project_version, None, group_account,
signing_priv_key_pem, 8234389)
return newFollowJson
@ -1414,11 +1414,11 @@ def outboxUndoFollow(base_dir: str, message_json: {}, debug: bool) -> None:
getDomainFromActor(message_json['object']['object'])
domainFollowingFull = getFullDomain(domainFollowing, portFollowing)
groupAccount = \
group_account = \
hasGroupType(base_dir, message_json['object']['object'], None)
if unfollowAccount(base_dir, nicknameFollower, domainFollowerFull,
nicknameFollowing, domainFollowingFull,
debug, groupAccount):
debug, group_account):
if debug:
print('DEBUG: ' + nicknameFollower + ' unfollowed ' +
nicknameFollowing + '@' + domainFollowingFull)

View File

@ -776,12 +776,12 @@ def _receiveUndoFollow(session, base_dir: str, http_prefix: str,
getDomainFromActor(message_json['object']['object'])
domainFollowingFull = getFullDomain(domainFollowing, portFollowing)
groupAccount = \
group_account = \
hasGroupType(base_dir, message_json['object']['actor'], None)
if unfollowerOfAccount(base_dir,
nicknameFollowing, domainFollowingFull,
nicknameFollower, domainFollowerFull,
debug, groupAccount):
debug, group_account):
print(nicknameFollowing + '@' + domainFollowingFull + ': '
'Follower ' + nicknameFollower + '@' + domainFollowerFull +
' was removed')
@ -2823,10 +2823,10 @@ def _bounceDM(senderPostId: str, session, http_prefix: str,
lastBounceMessage[0] = currTime
senderNickname = sendingHandle.split('@')[0]
groupAccount = False
group_account = False
if sendingHandle.startswith('!'):
sendingHandle = sendingHandle[1:]
groupAccount = True
group_account = True
senderDomain = sendingHandle.split('@')[1]
senderPort = port
if ':' in senderDomain:
@ -2875,7 +2875,7 @@ def _bounceDM(senderPostId: str, session, http_prefix: str,
senderNickname, senderDomain, senderPort, cc,
http_prefix, False, False, federation_list,
send_threads, postLog, cached_webfingers,
person_cache, debug, __version__, None, groupAccount,
person_cache, debug, __version__, None, group_account,
signing_priv_key_pem, 7238634)
return True
@ -3984,9 +3984,9 @@ def _receiveFollowRequest(session, base_dir: str, http_prefix: str,
print('Unable to obtain following actor: ' +
message_json['actor'])
groupAccount = \
group_account = \
hasGroupType(base_dir, message_json['actor'], person_cache)
if groupAccount and isGroupAccount(base_dir, nickname, domain):
if group_account and isGroupAccount(base_dir, nickname, domain):
print('Group cannot follow a group')
return False
@ -3995,7 +3995,7 @@ def _receiveFollowRequest(session, base_dir: str, http_prefix: str,
nicknameToFollow, domainToFollow, port,
nickname, domain, fromPort,
message_json, debug, message_json['actor'],
groupAccount)
group_account)
else:
print('Follow request does not require approval ' + approveHandle)
# update the followers
@ -4026,13 +4026,13 @@ def _receiveFollowRequest(session, base_dir: str, http_prefix: str,
followersFilename + ' adding ' + approveHandle)
if os.path.isfile(followersFilename):
if approveHandle not in open(followersFilename).read():
groupAccount = \
group_account = \
hasGroupType(base_dir,
message_json['actor'], person_cache)
if debug:
print(approveHandle + ' / ' + message_json['actor'] +
' is Group: ' + str(groupAccount))
if groupAccount and \
' is Group: ' + str(group_account))
if group_account and \
isGroupAccount(base_dir, nickname, domain):
print('Group cannot follow a group')
return False
@ -4041,7 +4041,7 @@ def _receiveFollowRequest(session, base_dir: str, http_prefix: str,
content = followersFile.read()
if approveHandle + '\n' not in content:
followersFile.seek(0, 0)
if not groupAccount:
if not group_account:
followersFile.write(approveHandle +
'\n' + content)
else:

View File

@ -102,11 +102,11 @@ def _like(recentPostsCache: {},
likedPostNickname = None
likedPostDomain = None
likedPostPort = None
groupAccount = False
group_account = False
if actorLiked:
likedPostNickname = getNicknameFromActor(actorLiked)
likedPostDomain, likedPostPort = getDomainFromActor(actorLiked)
groupAccount = hasGroupType(base_dir, actorLiked, person_cache)
group_account = hasGroupType(base_dir, actorLiked, person_cache)
else:
if hasUsersPath(objectUrl):
likedPostNickname = getNicknameFromActor(objectUrl)
@ -115,7 +115,8 @@ def _like(recentPostsCache: {},
actorLiked = \
objectUrl.split('/' + likedPostNickname + '/')[0] + \
'/' + likedPostNickname
groupAccount = hasGroupType(base_dir, actorLiked, person_cache)
group_account = \
hasGroupType(base_dir, actorLiked, person_cache)
if likedPostNickname:
postFilename = locatePost(base_dir, nickname, domain, objectUrl)
@ -137,7 +138,7 @@ def _like(recentPostsCache: {},
'https://www.w3.org/ns/activitystreams#Public',
http_prefix, True, client_to_server, federation_list,
send_threads, postLog, cached_webfingers, person_cache,
debug, project_version, None, groupAccount,
debug, project_version, None, group_account,
signing_priv_key_pem, 7367374)
return newLikeJson

View File

@ -151,9 +151,9 @@ def manualApproveFollowRequest(session, base_dir: str,
if approveHandle in approveFollowsStr:
exists = True
elif '@' in approveHandle:
groupAccount = False
group_account = False
if approveHandle.startswith('!'):
groupAccount = True
group_account = True
reqNick = approveHandle.split('@')[0].replace('!', '')
reqDomain = approveHandle.split('@')[1].strip()
reqPrefix = http_prefix + '://' + reqDomain
@ -162,7 +162,7 @@ def manualApproveFollowRequest(session, base_dir: str,
if reqPrefix + userPath + reqNick in approveFollowsStr:
exists = True
approveHandleFull = reqPrefix + userPath + reqNick
if groupAccount:
if group_account:
approveHandleFull = '!' + approveHandleFull
break
if not exists:

View File

@ -106,14 +106,14 @@ def _updateMovedHandle(base_dir: str, nickname: str, domain: str,
if movedToPort:
if movedToPort != 80 and movedToPort != 443:
movedToDomainFull = movedToDomain + ':' + str(movedToPort)
groupAccount = hasGroupType(base_dir, movedToUrl, None)
group_account = hasGroupType(base_dir, movedToUrl, None)
if isBlocked(base_dir, nickname, domain,
movedToNickname, movedToDomain):
# someone that you follow has moved to a blocked domain
# so just unfollow them
unfollowAccount(base_dir, nickname, domain,
movedToNickname, movedToDomainFull,
debug, groupAccount, 'following.txt')
debug, group_account, 'following.txt')
return ctr
followingFilename = acctDir(base_dir, nickname, domain) + '/following.txt'
@ -139,7 +139,7 @@ def _updateMovedHandle(base_dir: str, nickname: str, domain: str,
unfollowAccount(base_dir, nickname, domain,
handleNickname,
handleDomain,
debug, groupAccount, 'following.txt')
debug, group_account, 'following.txt')
ctr += 1
print('Unfollowed ' + handle + ' who has moved to ' +
movedToHandle)

View File

@ -351,7 +351,7 @@ def getDefaultPersonContext() -> str:
def _createPersonBase(base_dir: str, nickname: str, domain: str, port: int,
http_prefix: str, saveToFile: bool,
manual_follower_approval: bool,
groupAccount: bool,
group_account: bool,
password: str) -> (str, str, {}, {}):
"""Returns the private key, public key, actor and webfinger endpoint
"""
@ -359,7 +359,7 @@ def _createPersonBase(base_dir: str, nickname: str, domain: str, port: int,
webfingerEndpoint = \
createWebfingerEndpoint(nickname, domain, port,
http_prefix, publicKeyPem,
groupAccount)
group_account)
if saveToFile:
storeWebfingerEndpoint(nickname, domain, port,
base_dir, webfingerEndpoint)
@ -369,7 +369,7 @@ def _createPersonBase(base_dir: str, nickname: str, domain: str, port: int,
domain = getFullDomain(domain, port)
personType = 'Person'
if groupAccount:
if group_account:
personType = 'Group'
# Enable follower approval by default
approveFollowers = manual_follower_approval
@ -595,7 +595,7 @@ def createPerson(base_dir: str, nickname: str, domain: str, port: int,
http_prefix: str, saveToFile: bool,
manual_follower_approval: bool,
password: str,
groupAccount: bool = False) -> (str, str, {}, {}):
group_account: bool = False) -> (str, str, {}, {}):
"""Returns the private key, public key, actor and webfinger endpoint
"""
if not validNickname(domain, nickname):
@ -623,7 +623,7 @@ def createPerson(base_dir: str, nickname: str, domain: str, port: int,
http_prefix,
saveToFile,
manual_follower,
groupAccount,
group_account,
password)
if not getConfigParam(base_dir, 'admin'):
if nickname != 'news':
@ -1436,7 +1436,7 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
if debug:
print('getActorJson for ' + handle)
originalActor = handle
groupAccount = False
group_account = False
# try to determine the users path
detectedUsersPath = _detectUsersPath(handle)
@ -1446,7 +1446,7 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
handle.startswith('hyper'):
groupPaths = getGroupPaths()
if detectedUsersPath in groupPaths:
groupAccount = True
group_account = True
# format: https://domain/@nick
originalHandle = handle
if not hasUsersPath(originalHandle):
@ -1488,7 +1488,7 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
elif handle.startswith('!'):
# handle for a group
handle = handle[1:]
groupAccount = True
group_account = True
if '@' not in handle:
if not quiet:
print('getActorJsonSyntax: --actor nickname@domain')
@ -1528,7 +1528,7 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
if debug:
print(originalActor + ' is an instance actor')
personUrl = originalActor
elif '://' in originalActor and groupAccount:
elif '://' in originalActor and group_account:
if debug:
print(originalActor + ' is a group actor')
personUrl = originalActor
@ -1537,7 +1537,7 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
wfRequest = webfingerHandle(session, handle,
http_prefix, cached_webfingers,
hostDomain, __version__, debug,
groupAccount, signing_priv_key_pem)
group_account, signing_priv_key_pem)
if not wfRequest:
if not quiet:
print('getActorJson Unable to webfinger ' + handle)
@ -1572,7 +1572,7 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
paths = getUserPaths()
for userPath in paths:
personUrl = personUrl.replace(userPath, '/actor/')
if not personUrl and groupAccount:
if not personUrl and group_account:
personUrl = http_prefix + '://' + domain + '/c/' + nickname
if not personUrl:
# try single user instance

View File

@ -2615,7 +2615,7 @@ def sendSignedJson(post_json_object: {}, session, base_dir: str,
federation_list: [],
send_threads: [], postLog: [], cached_webfingers: {},
person_cache: {}, debug: bool, project_version: str,
sharedItemsToken: str, groupAccount: bool,
sharedItemsToken: str, group_account: bool,
signing_priv_key_pem: str,
sourceId: int) -> int:
"""Sends a signed json object to an inbox/outbox
@ -2654,7 +2654,7 @@ def sendSignedJson(post_json_object: {}, session, base_dir: str,
# lookup the inbox for the To handle
wfRequest = webfingerHandle(session, handle, http_prefix,
cached_webfingers,
domain, project_version, debug, groupAccount,
domain, project_version, debug, group_account,
signing_priv_key_pem)
if not wfRequest:
if debug:
@ -2998,7 +2998,7 @@ def _sendToNamedAddresses(session, base_dir: str,
if sharedItemFederationTokens.get(fromDomainFull):
sharedItemsToken = sharedItemFederationTokens[fromDomainFull]
groupAccount = hasGroupType(base_dir, address, person_cache)
group_account = hasGroupType(base_dir, address, person_cache)
sendSignedJson(post_json_object, session, base_dir,
nickname, fromDomain, port,
@ -3007,7 +3007,7 @@ def _sendToNamedAddresses(session, base_dir: str,
federation_list,
send_threads, postLog, cached_webfingers,
person_cache, debug, project_version,
sharedItemsToken, groupAccount,
sharedItemsToken, group_account,
signing_priv_key_pem, 34436782)
@ -3190,9 +3190,9 @@ def sendToFollowers(session, base_dir: str,
if withSharedInbox:
toNickname = followerHandles[index].split('@')[0]
groupAccount = False
group_account = False
if toNickname.startswith('!'):
groupAccount = True
group_account = True
toNickname = toNickname[1:]
# if there are more than one followers on the domain
@ -3217,7 +3217,7 @@ def sendToFollowers(session, base_dir: str,
federation_list,
send_threads, postLog, cached_webfingers,
person_cache, debug, project_version,
sharedItemsToken, groupAccount,
sharedItemsToken, group_account,
signing_priv_key_pem, 639342)
else:
# send to individual followers without using a shared inbox
@ -3225,9 +3225,9 @@ def sendToFollowers(session, base_dir: str,
print('Sending post to followers ' + handle)
toNickname = handle.split('@')[0]
groupAccount = False
group_account = False
if toNickname.startswith('!'):
groupAccount = True
group_account = True
toNickname = toNickname[1:]
if post_json_object['type'] != 'Update':
@ -3246,7 +3246,7 @@ def sendToFollowers(session, base_dir: str,
federation_list,
send_threads, postLog, cached_webfingers,
person_cache, debug, project_version,
sharedItemsToken, groupAccount,
sharedItemsToken, group_account,
signing_priv_key_pem, 634219)
time.sleep(4)
@ -4082,16 +4082,16 @@ def getPublicPostsOfPerson(base_dir: str, nickname: str, domain: str,
person_cache = {}
cached_webfingers = {}
federation_list = []
groupAccount = False
group_account = False
if nickname.startswith('!'):
nickname = nickname[1:]
groupAccount = True
group_account = True
domainFull = getFullDomain(domain, port)
handle = http_prefix + "://" + domainFull + "/@" + nickname
wfRequest = \
webfingerHandle(session, handle, http_prefix, cached_webfingers,
originDomain, project_version, debug, groupAccount,
originDomain, project_version, debug, group_account,
signing_priv_key_pem)
if not wfRequest:
if debug:

View File

@ -99,12 +99,12 @@ def _reaction(recentPostsCache: {},
reactionPostNickname = None
reactionPostDomain = None
reactionPostPort = None
groupAccount = False
group_account = False
if actorReaction:
reactionPostNickname = getNicknameFromActor(actorReaction)
reactionPostDomain, reactionPostPort = \
getDomainFromActor(actorReaction)
groupAccount = hasGroupType(base_dir, actorReaction, person_cache)
group_account = hasGroupType(base_dir, actorReaction, person_cache)
else:
if hasUsersPath(objectUrl):
reactionPostNickname = getNicknameFromActor(objectUrl)
@ -114,7 +114,7 @@ def _reaction(recentPostsCache: {},
actorReaction = \
objectUrl.split('/' + reactionPostNickname + '/')[0] + \
'/' + reactionPostNickname
groupAccount = \
group_account = \
hasGroupType(base_dir, actorReaction, person_cache)
if reactionPostNickname:
@ -139,7 +139,7 @@ def _reaction(recentPostsCache: {},
'https://www.w3.org/ns/activitystreams#Public',
http_prefix, True, client_to_server, federation_list,
send_threads, postLog, cached_webfingers, person_cache,
debug, project_version, None, groupAccount,
debug, project_version, None, group_account,
signing_priv_key_pem, 7165392)
return newReactionJson

View File

@ -1131,7 +1131,7 @@ def _setDefaultPetName(base_dir: str, nickname: str, domain: str,
def followPerson(base_dir: str, nickname: str, domain: str,
followNickname: str, followDomain: str,
federation_list: [], debug: bool,
groupAccount: bool,
group_account: bool,
followFile: str = 'following.txt') -> bool:
"""Adds a person to the follow list
"""
@ -1161,7 +1161,7 @@ def followPerson(base_dir: str, nickname: str, domain: str,
else:
handleToFollow = followNickname + '@' + followDomain
if groupAccount:
if group_account:
handleToFollow = '!' + handleToFollow
# was this person previously unfollowed?
@ -1181,7 +1181,7 @@ def followPerson(base_dir: str, nickname: str, domain: str,
if not os.path.isdir(base_dir + '/accounts'):
os.mkdir(base_dir + '/accounts')
handleToFollow = followNickname + '@' + followDomain
if groupAccount:
if group_account:
handleToFollow = '!' + handleToFollow
filename = base_dir + '/accounts/' + handle + '/' + followFile
if os.path.isfile(filename):

View File

@ -26,7 +26,7 @@ from utils import localActorUrl
def _parseHandle(handle: str) -> (str, str, bool):
"""Parses a handle and returns nickname and domain
"""
groupAccount = False
group_account = False
if '.' not in handle:
return None, None, False
prefixes = getProtocolPrefixes()
@ -43,9 +43,9 @@ def _parseHandle(handle: str) -> (str, str, bool):
if '@' in handle:
if handle.startswith('!'):
handle = handle[1:]
groupAccount = True
group_account = True
nickname, domain = handle.split('@')
return nickname, domain, groupAccount
return nickname, domain, group_account
# try for different /users/ paths
usersPaths = getUserPaths()
@ -53,9 +53,9 @@ def _parseHandle(handle: str) -> (str, str, bool):
for possibleUsersPath in usersPaths:
if possibleUsersPath in handle:
if possibleUsersPath in groupPaths:
groupAccount = True
group_account = True
domain, nickname = handleStr.split(possibleUsersPath)
return nickname, domain, groupAccount
return nickname, domain, group_account
return None, None, False
@ -63,7 +63,7 @@ def _parseHandle(handle: str) -> (str, str, bool):
def webfingerHandle(session, handle: str, http_prefix: str,
cached_webfingers: {},
fromDomain: str, project_version: str,
debug: bool, groupAccount: bool,
debug: bool, group_account: bool,
signing_priv_key_pem: str) -> {}:
"""Gets webfinger result for the given ActivityPub handle
"""
@ -132,7 +132,7 @@ def storeWebfingerEndpoint(nickname: str, domain: str, port: int,
def createWebfingerEndpoint(nickname: str, domain: str, port: int,
http_prefix: str, publicKeyPem: str,
groupAccount: bool) -> {}:
group_account: bool) -> {}:
"""Creates a webfinger endpoint for a user
"""
originalDomain = domain