mirror of https://gitlab.com/bashrc2/epicyon
roleName becomes a list
parent
2c70942481
commit
e44ed60ffc
11
daemon.py
11
daemon.py
|
@ -124,7 +124,6 @@ from blocking import isBlockedHashtag
|
||||||
from blocking import isBlockedDomain
|
from blocking import isBlockedDomain
|
||||||
from blocking import getDomainBlocklist
|
from blocking import getDomainBlocklist
|
||||||
from roles import setRole
|
from roles import setRole
|
||||||
from roles import getRolesFromString
|
|
||||||
from roles import clearModeratorStatus
|
from roles import clearModeratorStatus
|
||||||
from roles import clearEditorStatus
|
from roles import clearEditorStatus
|
||||||
from roles import clearCounselorStatus
|
from roles import clearCounselorStatus
|
||||||
|
@ -7397,8 +7396,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
rolesList = []
|
rolesList = []
|
||||||
if actorJson.get('affiliation'):
|
if actorJson.get('affiliation'):
|
||||||
actorRolesStr = actorJson['affiliation']['roleName']
|
if isinstance(actorJson['affiliation']['roleName'],
|
||||||
rolesList = getRolesFromString(actorRolesStr)
|
list):
|
||||||
|
rolesList = actorJson['affiliation']['roleName']
|
||||||
msg = \
|
msg = \
|
||||||
htmlProfile(self.server.rssIconAtTop,
|
htmlProfile(self.server.rssIconAtTop,
|
||||||
self.server.cssCache,
|
self.server.cssCache,
|
||||||
|
@ -7436,8 +7436,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if self._fetchAuthenticated():
|
if self._fetchAuthenticated():
|
||||||
rolesList = []
|
rolesList = []
|
||||||
if actorJson.get('affiliation'):
|
if actorJson.get('affiliation'):
|
||||||
actorRolesStr = actorJson['affiliation']['roleName']
|
if isinstance(actorJson['affiliation']['roleName'],
|
||||||
rolesList = getRolesFromString(actorRolesStr)
|
list):
|
||||||
|
rolesList = actorJson['affiliation']['roleName']
|
||||||
|
|
||||||
msg = json.dumps(rolesList,
|
msg = json.dumps(rolesList,
|
||||||
ensure_ascii=False)
|
ensure_ascii=False)
|
||||||
|
|
10
person.py
10
person.py
|
@ -285,7 +285,7 @@ def _createPersonBase(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
},
|
},
|
||||||
"affiliation": {
|
"affiliation": {
|
||||||
"@type": "OrganizationRole",
|
"@type": "OrganizationRole",
|
||||||
"roleName": "",
|
"roleName": [],
|
||||||
"affiliation": {
|
"affiliation": {
|
||||||
"@type": "WebSite",
|
"@type": "WebSite",
|
||||||
"url": httpPrefix + '://' + domain
|
"url": httpPrefix + '://' + domain
|
||||||
|
@ -598,14 +598,14 @@ def personUpgradeActor(baseDir: str, personJson: {},
|
||||||
# if the older roles format is being used then switch
|
# if the older roles format is being used then switch
|
||||||
# to the new one
|
# to the new one
|
||||||
if not personJson.get('affiliation'):
|
if not personJson.get('affiliation'):
|
||||||
rolesStr = ''
|
rolesList = []
|
||||||
adminName = getConfigParam(baseDir, 'admin')
|
adminName = getConfigParam(baseDir, 'admin')
|
||||||
if personJson['id'].endswith('/users/' + adminName):
|
if personJson['id'].endswith('/users/' + adminName):
|
||||||
rolesStr = 'admin, moderator, editor'
|
rolesList = ["admin", "moderator", "editor"]
|
||||||
statusNumber, published = getStatusNumber()
|
statusNumber, published = getStatusNumber()
|
||||||
personJson['affiliation'] = {
|
personJson['affiliation'] = {
|
||||||
"@type": "OrganizationRole",
|
"@type": "OrganizationRole",
|
||||||
"roleName": rolesStr,
|
"roleName": rolesList,
|
||||||
"affiliation": {
|
"affiliation": {
|
||||||
"@type": "WebSite",
|
"@type": "WebSite",
|
||||||
"url": personJson['id'].split('/users/')[0]
|
"url": personJson['id'].split('/users/')[0]
|
||||||
|
@ -620,7 +620,7 @@ def personUpgradeActor(baseDir: str, personJson: {},
|
||||||
adminName = getConfigParam(baseDir, 'admin')
|
adminName = getConfigParam(baseDir, 'admin')
|
||||||
if personJson['id'].endswith('/users/' + adminName):
|
if personJson['id'].endswith('/users/' + adminName):
|
||||||
personJson['affiliation']['roleName'] = \
|
personJson['affiliation']['roleName'] = \
|
||||||
'admin, moderator, editor'
|
["admin", "moderator", "editor"]
|
||||||
updateActor = True
|
updateActor = True
|
||||||
|
|
||||||
# remove the old roles format
|
# remove the old roles format
|
||||||
|
|
12
roles.py
12
roles.py
|
@ -111,19 +111,17 @@ def _removeRole(baseDir: str, nickname: str, roleFilename: str) -> None:
|
||||||
def setRolesFromList(actorJson: {}, rolesList: []) -> None:
|
def setRolesFromList(actorJson: {}, rolesList: []) -> None:
|
||||||
"""Sets roles from a list
|
"""Sets roles from a list
|
||||||
"""
|
"""
|
||||||
rolesStr = ''
|
|
||||||
for roleName in rolesList:
|
|
||||||
if rolesStr:
|
|
||||||
rolesStr += ', '
|
|
||||||
rolesStr += roleName.lower()
|
|
||||||
if actorJson.get('affiliation'):
|
if actorJson.get('affiliation'):
|
||||||
actorJson['affiliation']['roleName'] = rolesStr
|
actorJson['affiliation']['roleName'] = rolesList.copy()
|
||||||
|
|
||||||
|
|
||||||
def getRolesFromString(rolesStr: str) -> []:
|
def getRolesFromString(rolesStr: str) -> []:
|
||||||
"""Returns a list of roles from a string
|
"""Returns a list of roles from a string
|
||||||
"""
|
"""
|
||||||
rolesList = rolesStr.split(',')
|
if isinstance(rolesStr, list):
|
||||||
|
rolesList = rolesStr
|
||||||
|
else:
|
||||||
|
rolesList = rolesStr.split(',')
|
||||||
rolesResult = []
|
rolesResult = []
|
||||||
for roleName in rolesList:
|
for roleName in rolesList:
|
||||||
rolesResult.append(roleName.strip().lower())
|
rolesResult.append(roleName.strip().lower())
|
||||||
|
|
2
tests.py
2
tests.py
|
@ -3685,7 +3685,7 @@ def testRoles() -> None:
|
||||||
actorJson = {
|
actorJson = {
|
||||||
'affiliation': {
|
'affiliation': {
|
||||||
"@type": "OrganizationRole",
|
"@type": "OrganizationRole",
|
||||||
"roleName": "",
|
"roleName": [],
|
||||||
"affiliation": {
|
"affiliation": {
|
||||||
"@type": "WebSite",
|
"@type": "WebSite",
|
||||||
"url": "https://testinstance.org"
|
"url": "https://testinstance.org"
|
||||||
|
|
Loading…
Reference in New Issue