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 getDomainBlocklist
|
||||
from roles import setRole
|
||||
from roles import getRolesFromString
|
||||
from roles import clearModeratorStatus
|
||||
from roles import clearEditorStatus
|
||||
from roles import clearCounselorStatus
|
||||
|
@ -7397,8 +7396,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
|
||||
rolesList = []
|
||||
if actorJson.get('affiliation'):
|
||||
actorRolesStr = actorJson['affiliation']['roleName']
|
||||
rolesList = getRolesFromString(actorRolesStr)
|
||||
if isinstance(actorJson['affiliation']['roleName'],
|
||||
list):
|
||||
rolesList = actorJson['affiliation']['roleName']
|
||||
msg = \
|
||||
htmlProfile(self.server.rssIconAtTop,
|
||||
self.server.cssCache,
|
||||
|
@ -7436,8 +7436,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if self._fetchAuthenticated():
|
||||
rolesList = []
|
||||
if actorJson.get('affiliation'):
|
||||
actorRolesStr = actorJson['affiliation']['roleName']
|
||||
rolesList = getRolesFromString(actorRolesStr)
|
||||
if isinstance(actorJson['affiliation']['roleName'],
|
||||
list):
|
||||
rolesList = actorJson['affiliation']['roleName']
|
||||
|
||||
msg = json.dumps(rolesList,
|
||||
ensure_ascii=False)
|
||||
|
|
10
person.py
10
person.py
|
@ -285,7 +285,7 @@ def _createPersonBase(baseDir: str, nickname: str, domain: str, port: int,
|
|||
},
|
||||
"affiliation": {
|
||||
"@type": "OrganizationRole",
|
||||
"roleName": "",
|
||||
"roleName": [],
|
||||
"affiliation": {
|
||||
"@type": "WebSite",
|
||||
"url": httpPrefix + '://' + domain
|
||||
|
@ -598,14 +598,14 @@ def personUpgradeActor(baseDir: str, personJson: {},
|
|||
# if the older roles format is being used then switch
|
||||
# to the new one
|
||||
if not personJson.get('affiliation'):
|
||||
rolesStr = ''
|
||||
rolesList = []
|
||||
adminName = getConfigParam(baseDir, 'admin')
|
||||
if personJson['id'].endswith('/users/' + adminName):
|
||||
rolesStr = 'admin, moderator, editor'
|
||||
rolesList = ["admin", "moderator", "editor"]
|
||||
statusNumber, published = getStatusNumber()
|
||||
personJson['affiliation'] = {
|
||||
"@type": "OrganizationRole",
|
||||
"roleName": rolesStr,
|
||||
"roleName": rolesList,
|
||||
"affiliation": {
|
||||
"@type": "WebSite",
|
||||
"url": personJson['id'].split('/users/')[0]
|
||||
|
@ -620,7 +620,7 @@ def personUpgradeActor(baseDir: str, personJson: {},
|
|||
adminName = getConfigParam(baseDir, 'admin')
|
||||
if personJson['id'].endswith('/users/' + adminName):
|
||||
personJson['affiliation']['roleName'] = \
|
||||
'admin, moderator, editor'
|
||||
["admin", "moderator", "editor"]
|
||||
updateActor = True
|
||||
|
||||
# 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:
|
||||
"""Sets roles from a list
|
||||
"""
|
||||
rolesStr = ''
|
||||
for roleName in rolesList:
|
||||
if rolesStr:
|
||||
rolesStr += ', '
|
||||
rolesStr += roleName.lower()
|
||||
if actorJson.get('affiliation'):
|
||||
actorJson['affiliation']['roleName'] = rolesStr
|
||||
actorJson['affiliation']['roleName'] = rolesList.copy()
|
||||
|
||||
|
||||
def getRolesFromString(rolesStr: str) -> []:
|
||||
"""Returns a list of roles from a string
|
||||
"""
|
||||
rolesList = rolesStr.split(',')
|
||||
if isinstance(rolesStr, list):
|
||||
rolesList = rolesStr
|
||||
else:
|
||||
rolesList = rolesStr.split(',')
|
||||
rolesResult = []
|
||||
for roleName in rolesList:
|
||||
rolesResult.append(roleName.strip().lower())
|
||||
|
|
Loading…
Reference in New Issue