Snake case

merge-requests/30/head
Bob Mottram 2021-12-26 17:33:24 +00:00
parent 8b853014c5
commit 6f8944ed40
4 changed files with 16 additions and 16 deletions

View File

@ -18,7 +18,7 @@ from like import updateLikesCollection
from reaction import updateReactionCollection from reaction import updateReactionCollection
from reaction import validEmojiContent from reaction import validEmojiContent
from utils import domainPermitted from utils import domainPermitted
from utils import isGroupAccount from utils import is_group_account
from utils import isSystemAccount from utils import isSystemAccount
from utils import invalidCiphertext from utils import invalidCiphertext
from utils import removeHtml from utils import removeHtml
@ -3986,7 +3986,7 @@ def _receiveFollowRequest(session, base_dir: str, http_prefix: str,
group_account = \ group_account = \
hasGroupType(base_dir, message_json['actor'], person_cache) hasGroupType(base_dir, message_json['actor'], person_cache)
if group_account and isGroupAccount(base_dir, nickname, domain): if group_account and is_group_account(base_dir, nickname, domain):
print('Group cannot follow a group') print('Group cannot follow a group')
return False return False
@ -4033,7 +4033,7 @@ def _receiveFollowRequest(session, base_dir: str, http_prefix: str,
print(approveHandle + ' / ' + message_json['actor'] + print(approveHandle + ' / ' + message_json['actor'] +
' is Group: ' + str(group_account)) ' is Group: ' + str(group_account))
if group_account and \ if group_account and \
isGroupAccount(base_dir, nickname, domain): is_group_account(base_dir, nickname, domain):
print('Group cannot follow a group') print('Group cannot follow a group')
return False return False
try: try:

View File

@ -57,7 +57,7 @@ from siteactive import siteIsActive
from utils import get_sha_256 from utils import get_sha_256
from utils import dangerousSVG from utils import dangerousSVG
from utils import canReplyTo from utils import canReplyTo
from utils import isGroupAccount from utils import is_group_account
from utils import get_actor_languages_list from utils import get_actor_languages_list
from utils import get_category_types from utils import get_category_types
from utils import get_supported_languages from utils import get_supported_languages
@ -1557,7 +1557,7 @@ def testFollowBetweenServers(base_dir: str) -> None:
aliceDomain + aliceDomain +
'/followingCalendar.txt').read() '/followingCalendar.txt').read()
assert not isGroupActor(aliceDir, bobActor, alicePersonCache) assert not isGroupActor(aliceDir, bobActor, alicePersonCache)
assert not isGroupAccount(aliceDir, 'alice', aliceDomain) assert not is_group_account(aliceDir, 'alice', aliceDomain)
print('\n\n*********************************************************') print('\n\n*********************************************************')
print('Alice sends a message to Bob') print('Alice sends a message to Bob')
@ -1774,7 +1774,7 @@ def testSharedItemsFederation(base_dir: str) -> None:
aliceDomain + aliceDomain +
'/followingCalendar.txt').read() '/followingCalendar.txt').read()
assert not isGroupActor(aliceDir, bobActor, alicePersonCache) assert not isGroupActor(aliceDir, bobActor, alicePersonCache)
assert not isGroupAccount(bobDir, 'bob', bobDomain) assert not is_group_account(bobDir, 'bob', bobDomain)
print('\n\n*********************************************************') print('\n\n*********************************************************')
print('Bob publishes some shared items') print('Bob publishes some shared items')
@ -2231,8 +2231,8 @@ def testGroupFollow(base_dir: str) -> None:
print('Alice following.txt does not contain !testgroup@' + print('Alice following.txt does not contain !testgroup@' +
testgroupDomain + ':' + str(testgroupPort)) testgroupDomain + ':' + str(testgroupPort))
assert isGroupActor(aliceDir, testgroupActor, alicePersonCache) assert isGroupActor(aliceDir, testgroupActor, alicePersonCache)
assert not isGroupAccount(aliceDir, 'alice', aliceDomain) assert not is_group_account(aliceDir, 'alice', aliceDomain)
assert isGroupAccount(testgroupDir, 'testgroup', testgroupDomain) assert is_group_account(testgroupDir, 'testgroup', testgroupDomain)
assert '!testgroup' in followingStr assert '!testgroup' in followingStr
assert testgroupHandle in open(aliceFollowingFilename).read() assert testgroupHandle in open(aliceFollowingFilename).read()
assert testgroupHandle in open(aliceFollowingCalendarFilename).read() assert testgroupHandle in open(aliceFollowingCalendarFilename).read()

View File

@ -3032,13 +3032,13 @@ def isGroupActor(base_dir: str, actor: str, person_cache: {},
return False return False
def isGroupAccount(base_dir: str, nickname: str, domain: str) -> bool: def is_group_account(base_dir: str, nickname: str, domain: str) -> bool:
"""Returns true if the given account is a group """Returns true if the given account is a group
""" """
accountFilename = acct_dir(base_dir, nickname, domain) + '.json' account_filename = acct_dir(base_dir, nickname, domain) + '.json'
if not os.path.isfile(accountFilename): if not os.path.isfile(account_filename):
return False return False
if '"type": "Group"' in open(accountFilename).read(): if '"type": "Group"' in open(account_filename).read():
return True return True
return False return False

View File

@ -11,7 +11,7 @@ import os
from pprint import pprint from pprint import pprint
from webfinger import webfingerHandle from webfinger import webfingerHandle
from utils import getDisplayName from utils import getDisplayName
from utils import isGroupAccount from utils import is_group_account
from utils import has_object_dict from utils import has_object_dict
from utils import getOccupationName from utils import getOccupationName
from utils import get_locked_account from utils import get_locked_account
@ -859,7 +859,7 @@ def htmlProfile(signing_priv_key_pem: str,
deft = defaultTimeline deft = defaultTimeline
isGroup = False isGroup = False
followersStr = translate['Followers'] followersStr = translate['Followers']
if isGroupAccount(base_dir, nickname, domain): if is_group_account(base_dir, nickname, domain):
isGroup = True isGroup = True
followersStr = translate['Members'] followersStr = translate['Members']
menuTimeline = \ menuTimeline = \
@ -2406,8 +2406,8 @@ def _individualFollowAsHtml(signing_priv_key_pem: str,
elif b == 'unfollow': elif b == 'unfollow':
unfollowStr = 'Unfollow' unfollowStr = 'Unfollow'
if isGroup or \ if isGroup or \
isGroupAccount(base_dir, is_group_account(base_dir,
followUrlNickname, followUrlDomain): followUrlNickname, followUrlDomain):
unfollowStr = 'Leave' unfollowStr = 'Leave'
buttonsStr += \ buttonsStr += \
'<a href="/users/' + actorNickname + \ '<a href="/users/' + actorNickname + \