Only allow admin to create groups

merge-requests/30/head
Bob Mottram 2021-08-12 19:18:50 +01:00
parent e775ed4cdf
commit 71beafd1a6
2 changed files with 14 additions and 7 deletions

View File

@ -5383,8 +5383,11 @@ class PubServer(BaseHTTPRequestHandler):
if fields.get('isGroup'): if fields.get('isGroup'):
if fields['isGroup'] == 'on': if fields['isGroup'] == 'on':
if actorJson['type'] != 'Group': if actorJson['type'] != 'Group':
actorJson['type'] = 'Group' # only allow admin to create groups
actorChanged = True if path.startswith('/users/' +
adminNickname + '/'):
actorJson['type'] = 'Group'
actorChanged = True
else: else:
# this account is a person (default) # this account is a person (default)
if actorJson['type'] != 'Person': if actorJson['type'] != 'Person':

View File

@ -1667,7 +1667,8 @@ def _htmlEditProfileContactInfo(nickname: str,
return editProfileForm return editProfileForm
def _htmlEditProfileOptions(manuallyApprovesFollowers: str, def _htmlEditProfileOptions(isAdmin: bool,
manuallyApprovesFollowers: str,
isBot: str, isGroup: str, isBot: str, isGroup: str,
followDMs: str, removeTwitter: str, followDMs: str, removeTwitter: str,
notifyLikes: str, hideLikeButton: str, notifyLikes: str, hideLikeButton: str,
@ -1681,9 +1682,10 @@ def _htmlEditProfileOptions(manuallyApprovesFollowers: str,
editProfileForm += \ editProfileForm += \
editCheckBox(translate['This is a bot account'], editCheckBox(translate['This is a bot account'],
'isBot', isBot) 'isBot', isBot)
editProfileForm += \ if isAdmin:
editCheckBox(translate['This is a group account'], editProfileForm += \
'isGroup', isGroup) editCheckBox(translate['This is a group account'],
'isGroup', isGroup)
editProfileForm += \ editProfileForm += \
editCheckBox(translate['Only people I follow can send me DMs'], editCheckBox(translate['Only people I follow can send me DMs'],
'followDMs', followDMs) 'followDMs', followDMs)
@ -1932,8 +1934,10 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
path.startswith('/users/' + str(adminNickname) + '/'): path.startswith('/users/' + str(adminNickname) + '/'):
graphicsStr = _htmlEditProfileGraphicDesign(baseDir, translate) graphicsStr = _htmlEditProfileGraphicDesign(baseDir, translate)
isAdmin = False
if adminNickname: if adminNickname:
if path.startswith('/users/' + adminNickname + '/'): if path.startswith('/users/' + adminNickname + '/'):
isAdmin = True
# shared items section # shared items section
sharesFederationStr = \ sharesFederationStr = \
_htmlEditProfileSharedItems(baseDir, nickname, _htmlEditProfileSharedItems(baseDir, nickname,
@ -1982,7 +1986,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
# Option checkboxes # Option checkboxes
editProfileForm += \ editProfileForm += \
_htmlEditProfileOptions(manuallyApprovesFollowers, _htmlEditProfileOptions(isAdmin, manuallyApprovesFollowers,
isBot, isGroup, followDMs, removeTwitter, isBot, isGroup, followDMs, removeTwitter,
notifyLikes, hideLikeButton, translate) notifyLikes, hideLikeButton, translate)