mirror of https://gitlab.com/bashrc2/epicyon
Snake case
parent
3d9559bf27
commit
c99a29df89
|
@ -33,10 +33,10 @@ def setAvailability(base_dir: str, nickname: str, domain: str,
|
||||||
actorFilename = acctDir(base_dir, nickname, domain) + '.json'
|
actorFilename = acctDir(base_dir, nickname, domain) + '.json'
|
||||||
if not os.path.isfile(actorFilename):
|
if not os.path.isfile(actorFilename):
|
||||||
return False
|
return False
|
||||||
actorJson = loadJson(actorFilename)
|
actor_json = loadJson(actorFilename)
|
||||||
if actorJson:
|
if actor_json:
|
||||||
actorJson['availability'] = status
|
actor_json['availability'] = status
|
||||||
saveJson(actorJson, actorFilename)
|
saveJson(actor_json, actorFilename)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,11 +46,11 @@ def getAvailability(base_dir: str, nickname: str, domain: str) -> str:
|
||||||
actorFilename = acctDir(base_dir, nickname, domain) + '.json'
|
actorFilename = acctDir(base_dir, nickname, domain) + '.json'
|
||||||
if not os.path.isfile(actorFilename):
|
if not os.path.isfile(actorFilename):
|
||||||
return False
|
return False
|
||||||
actorJson = loadJson(actorFilename)
|
actor_json = loadJson(actorFilename)
|
||||||
if actorJson:
|
if actor_json:
|
||||||
if not actorJson.get('availability'):
|
if not actor_json.get('availability'):
|
||||||
return None
|
return None
|
||||||
return actorJson['availability']
|
return actor_json['availability']
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
10
blog.py
10
blog.py
|
@ -266,11 +266,11 @@ def _htmlBlogPostContent(debug: bool, session, authorized: bool,
|
||||||
blogStr += '<br><center>' + attachmentStr + '</center>'
|
blogStr += '<br><center>' + attachmentStr + '</center>'
|
||||||
|
|
||||||
personUrl = local_actor_url(http_prefix, nickname, domain_full)
|
personUrl = local_actor_url(http_prefix, nickname, domain_full)
|
||||||
actorJson = \
|
actor_json = \
|
||||||
getPersonFromCache(base_dir, personUrl, person_cache, False)
|
getPersonFromCache(base_dir, personUrl, person_cache, False)
|
||||||
languagesUnderstood = []
|
languagesUnderstood = []
|
||||||
if actorJson:
|
if actor_json:
|
||||||
languagesUnderstood = get_actor_languages_list(actorJson)
|
languagesUnderstood = get_actor_languages_list(actor_json)
|
||||||
jsonContent = getContentFromPost(post_json_object, system_language,
|
jsonContent = getContentFromPost(post_json_object, system_language,
|
||||||
languagesUnderstood)
|
languagesUnderstood)
|
||||||
if jsonContent:
|
if jsonContent:
|
||||||
|
@ -945,7 +945,7 @@ def pathContainsBlogLink(base_dir: str,
|
||||||
return locatePost(base_dir, nickname, domain, messageId), nickname
|
return locatePost(base_dir, nickname, domain, messageId), nickname
|
||||||
|
|
||||||
|
|
||||||
def getBlogAddress(actorJson: {}) -> str:
|
def getBlogAddress(actor_json: {}) -> str:
|
||||||
"""Returns blog address for the given actor
|
"""Returns blog address for the given actor
|
||||||
"""
|
"""
|
||||||
return getActorPropertyUrl(actorJson, 'Blog')
|
return getActorPropertyUrl(actor_json, 'Blog')
|
||||||
|
|
20
briar.py
20
briar.py
|
@ -8,12 +8,12 @@ __status__ = "Production"
|
||||||
__module_group__ = "Profile Metadata"
|
__module_group__ = "Profile Metadata"
|
||||||
|
|
||||||
|
|
||||||
def getBriarAddress(actorJson: {}) -> str:
|
def getBriarAddress(actor_json: {}) -> str:
|
||||||
"""Returns briar address for the given actor
|
"""Returns briar address for the given actor
|
||||||
"""
|
"""
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
return ''
|
return ''
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue['name'].lower().startswith('briar'):
|
if not propertyValue['name'].lower().startswith('briar'):
|
||||||
|
@ -43,7 +43,7 @@ def getBriarAddress(actorJson: {}) -> str:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
def setBriarAddress(actorJson: {}, briarAddress: str) -> None:
|
def setBriarAddress(actor_json: {}, briarAddress: str) -> None:
|
||||||
"""Sets an briar address for the given actor
|
"""Sets an briar address for the given actor
|
||||||
"""
|
"""
|
||||||
notBriarAddress = False
|
notBriarAddress = False
|
||||||
|
@ -65,12 +65,12 @@ def setBriarAddress(actorJson: {}, briarAddress: str) -> None:
|
||||||
if '<' in briarAddress:
|
if '<' in briarAddress:
|
||||||
notBriarAddress = True
|
notBriarAddress = True
|
||||||
|
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
actorJson['attachment'] = []
|
actor_json['attachment'] = []
|
||||||
|
|
||||||
# remove any existing value
|
# remove any existing value
|
||||||
propertyFound = None
|
propertyFound = None
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -80,11 +80,11 @@ def setBriarAddress(actorJson: {}, briarAddress: str) -> None:
|
||||||
propertyFound = propertyValue
|
propertyFound = propertyValue
|
||||||
break
|
break
|
||||||
if propertyFound:
|
if propertyFound:
|
||||||
actorJson['attachment'].remove(propertyFound)
|
actor_json['attachment'].remove(propertyFound)
|
||||||
if notBriarAddress:
|
if notBriarAddress:
|
||||||
return
|
return
|
||||||
|
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -101,4 +101,4 @@ def setBriarAddress(actorJson: {}, briarAddress: str) -> None:
|
||||||
"type": "PropertyValue",
|
"type": "PropertyValue",
|
||||||
"value": briarAddress
|
"value": briarAddress
|
||||||
}
|
}
|
||||||
actorJson['attachment'].append(newBriarAddress)
|
actor_json['attachment'].append(newBriarAddress)
|
||||||
|
|
20
cwtch.py
20
cwtch.py
|
@ -10,12 +10,12 @@ __module_group__ = "Profile Metadata"
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
def getCwtchAddress(actorJson: {}) -> str:
|
def getCwtchAddress(actor_json: {}) -> str:
|
||||||
"""Returns cwtch address for the given actor
|
"""Returns cwtch address for the given actor
|
||||||
"""
|
"""
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
return ''
|
return ''
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue['name'].lower().startswith('cwtch'):
|
if not propertyValue['name'].lower().startswith('cwtch'):
|
||||||
|
@ -41,7 +41,7 @@ def getCwtchAddress(actorJson: {}) -> str:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
def setCwtchAddress(actorJson: {}, cwtchAddress: str) -> None:
|
def setCwtchAddress(actor_json: {}, cwtchAddress: str) -> None:
|
||||||
"""Sets an cwtch address for the given actor
|
"""Sets an cwtch address for the given actor
|
||||||
"""
|
"""
|
||||||
notCwtchAddress = False
|
notCwtchAddress = False
|
||||||
|
@ -53,12 +53,12 @@ def setCwtchAddress(actorJson: {}, cwtchAddress: str) -> None:
|
||||||
if not re.match("^[a-z0-9]*$", cwtchAddress):
|
if not re.match("^[a-z0-9]*$", cwtchAddress):
|
||||||
notCwtchAddress = True
|
notCwtchAddress = True
|
||||||
|
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
actorJson['attachment'] = []
|
actor_json['attachment'] = []
|
||||||
|
|
||||||
# remove any existing value
|
# remove any existing value
|
||||||
propertyFound = None
|
propertyFound = None
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -68,11 +68,11 @@ def setCwtchAddress(actorJson: {}, cwtchAddress: str) -> None:
|
||||||
propertyFound = propertyValue
|
propertyFound = propertyValue
|
||||||
break
|
break
|
||||||
if propertyFound:
|
if propertyFound:
|
||||||
actorJson['attachment'].remove(propertyFound)
|
actor_json['attachment'].remove(propertyFound)
|
||||||
if notCwtchAddress:
|
if notCwtchAddress:
|
||||||
return
|
return
|
||||||
|
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -89,4 +89,4 @@ def setCwtchAddress(actorJson: {}, cwtchAddress: str) -> None:
|
||||||
"type": "PropertyValue",
|
"type": "PropertyValue",
|
||||||
"value": cwtchAddress
|
"value": cwtchAddress
|
||||||
}
|
}
|
||||||
actorJson['attachment'].append(newCwtchAddress)
|
actor_json['attachment'].append(newCwtchAddress)
|
||||||
|
|
335
daemon.py
335
daemon.py
|
@ -4885,51 +4885,51 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
actorFilename = \
|
actorFilename = \
|
||||||
acctDir(base_dir, nickname, domain) + '.json'
|
acctDir(base_dir, nickname, domain) + '.json'
|
||||||
if os.path.isfile(actorFilename):
|
if os.path.isfile(actorFilename):
|
||||||
actorJson = loadJson(actorFilename)
|
actor_json = loadJson(actorFilename)
|
||||||
if actorJson:
|
if actor_json:
|
||||||
if not actorJson.get('discoverable'):
|
if not actor_json.get('discoverable'):
|
||||||
# discoverable in profile directory
|
# discoverable in profile directory
|
||||||
# which isn't implemented in Epicyon
|
# which isn't implemented in Epicyon
|
||||||
actorJson['discoverable'] = True
|
actor_json['discoverable'] = True
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
if actorJson.get('capabilityAcquisitionEndpoint'):
|
if actor_json.get('capabilityAcquisitionEndpoint'):
|
||||||
del actorJson['capabilityAcquisitionEndpoint']
|
del actor_json['capabilityAcquisitionEndpoint']
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
# update the avatar/image url file extension
|
# update the avatar/image url file extension
|
||||||
uploads = profileMediaTypesUploaded.items()
|
uploads = profileMediaTypesUploaded.items()
|
||||||
for mType, lastPart in uploads:
|
for mType, lastPart in uploads:
|
||||||
repStr = '/' + lastPart
|
repStr = '/' + lastPart
|
||||||
if mType == 'avatar':
|
if mType == 'avatar':
|
||||||
actorUrl = actorJson['icon']['url']
|
actorUrl = actor_json['icon']['url']
|
||||||
lastPartOfUrl = actorUrl.split('/')[-1]
|
lastPartOfUrl = actorUrl.split('/')[-1]
|
||||||
srchStr = '/' + lastPartOfUrl
|
srchStr = '/' + lastPartOfUrl
|
||||||
actorUrl = actorUrl.replace(srchStr, repStr)
|
actorUrl = actorUrl.replace(srchStr, repStr)
|
||||||
actorJson['icon']['url'] = actorUrl
|
actor_json['icon']['url'] = actorUrl
|
||||||
print('actorUrl: ' + actorUrl)
|
print('actorUrl: ' + actorUrl)
|
||||||
if '.' in actorUrl:
|
if '.' in actorUrl:
|
||||||
imgExt = actorUrl.split('.')[-1]
|
imgExt = actorUrl.split('.')[-1]
|
||||||
if imgExt == 'jpg':
|
if imgExt == 'jpg':
|
||||||
imgExt = 'jpeg'
|
imgExt = 'jpeg'
|
||||||
actorJson['icon']['mediaType'] = \
|
actor_json['icon']['mediaType'] = \
|
||||||
'image/' + imgExt
|
'image/' + imgExt
|
||||||
elif mType == 'image':
|
elif mType == 'image':
|
||||||
lastPartOfUrl = \
|
lastPartOfUrl = \
|
||||||
actorJson['image']['url'].split('/')[-1]
|
actor_json['image']['url'].split('/')[-1]
|
||||||
srchStr = '/' + lastPartOfUrl
|
srchStr = '/' + lastPartOfUrl
|
||||||
actorJson['image']['url'] = \
|
actor_json['image']['url'] = \
|
||||||
actorJson['image']['url'].replace(srchStr,
|
actor_json['image']['url'].replace(srchStr,
|
||||||
repStr)
|
repStr)
|
||||||
if '.' in actorJson['image']['url']:
|
if '.' in actor_json['image']['url']:
|
||||||
imgExt = \
|
imgExt = \
|
||||||
actorJson['image']['url'].split('.')[-1]
|
actor_json['image']['url'].split('.')[-1]
|
||||||
if imgExt == 'jpg':
|
if imgExt == 'jpg':
|
||||||
imgExt = 'jpeg'
|
imgExt = 'jpeg'
|
||||||
actorJson['image']['mediaType'] = \
|
actor_json['image']['mediaType'] = \
|
||||||
'image/' + imgExt
|
'image/' + imgExt
|
||||||
|
|
||||||
# set skill levels
|
# set skill levels
|
||||||
skillCtr = 1
|
skillCtr = 1
|
||||||
actorSkillsCtr = noOfActorSkills(actorJson)
|
actorSkillsCtr = noOfActorSkills(actor_json)
|
||||||
while skillCtr < 10:
|
while skillCtr < 10:
|
||||||
skillName = \
|
skillName = \
|
||||||
fields.get('skillName' + str(skillCtr))
|
fields.get('skillName' + str(skillCtr))
|
||||||
|
@ -4944,20 +4944,20 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if not skillValue:
|
if not skillValue:
|
||||||
skillCtr += 1
|
skillCtr += 1
|
||||||
continue
|
continue
|
||||||
if not actorHasSkill(actorJson, skillName):
|
if not actorHasSkill(actor_json, skillName):
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
else:
|
else:
|
||||||
if actorSkillValue(actorJson, skillName) != \
|
if actorSkillValue(actor_json, skillName) != \
|
||||||
int(skillValue):
|
int(skillValue):
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
setActorSkillLevel(actorJson,
|
setActorSkillLevel(actor_json,
|
||||||
skillName, int(skillValue))
|
skillName, int(skillValue))
|
||||||
skillsStr = self.server.translate['Skills']
|
skillsStr = self.server.translate['Skills']
|
||||||
skillsStr = skillsStr.lower()
|
skillsStr = skillsStr.lower()
|
||||||
setHashtagCategory(base_dir, skillName,
|
setHashtagCategory(base_dir, skillName,
|
||||||
skillsStr, False)
|
skillsStr, False)
|
||||||
skillCtr += 1
|
skillCtr += 1
|
||||||
if noOfActorSkills(actorJson) != \
|
if noOfActorSkills(actor_json) != \
|
||||||
actorSkillsCtr:
|
actorSkillsCtr:
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
|
|
||||||
|
@ -4992,15 +4992,15 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
# change displayed name
|
# change displayed name
|
||||||
if fields.get('displayNickname'):
|
if fields.get('displayNickname'):
|
||||||
if fields['displayNickname'] != actorJson['name']:
|
if fields['displayNickname'] != actor_json['name']:
|
||||||
displayName = \
|
displayName = \
|
||||||
removeHtml(fields['displayNickname'])
|
removeHtml(fields['displayNickname'])
|
||||||
if not isFiltered(base_dir,
|
if not isFiltered(base_dir,
|
||||||
nickname, domain,
|
nickname, domain,
|
||||||
displayName):
|
displayName):
|
||||||
actorJson['name'] = displayName
|
actor_json['name'] = displayName
|
||||||
else:
|
else:
|
||||||
actorJson['name'] = nickname
|
actor_json['name'] = nickname
|
||||||
if checkNameAndBio:
|
if checkNameAndBio:
|
||||||
redirectPath = 'previewAvatar'
|
redirectPath = 'previewAvatar'
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
|
@ -5274,220 +5274,220 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'instanceDescription', '')
|
'instanceDescription', '')
|
||||||
|
|
||||||
# change email address
|
# change email address
|
||||||
currentEmailAddress = getEmailAddress(actorJson)
|
currentEmailAddress = getEmailAddress(actor_json)
|
||||||
if fields.get('email'):
|
if fields.get('email'):
|
||||||
if fields['email'] != currentEmailAddress:
|
if fields['email'] != currentEmailAddress:
|
||||||
setEmailAddress(actorJson, fields['email'])
|
setEmailAddress(actor_json, fields['email'])
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
else:
|
else:
|
||||||
if currentEmailAddress:
|
if currentEmailAddress:
|
||||||
setEmailAddress(actorJson, '')
|
setEmailAddress(actor_json, '')
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
|
|
||||||
# change xmpp address
|
# change xmpp address
|
||||||
currentXmppAddress = getXmppAddress(actorJson)
|
currentXmppAddress = getXmppAddress(actor_json)
|
||||||
if fields.get('xmppAddress'):
|
if fields.get('xmppAddress'):
|
||||||
if fields['xmppAddress'] != currentXmppAddress:
|
if fields['xmppAddress'] != currentXmppAddress:
|
||||||
setXmppAddress(actorJson,
|
setXmppAddress(actor_json,
|
||||||
fields['xmppAddress'])
|
fields['xmppAddress'])
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
else:
|
else:
|
||||||
if currentXmppAddress:
|
if currentXmppAddress:
|
||||||
setXmppAddress(actorJson, '')
|
setXmppAddress(actor_json, '')
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
|
|
||||||
# change matrix address
|
# change matrix address
|
||||||
currentMatrixAddress = getMatrixAddress(actorJson)
|
currentMatrixAddress = getMatrixAddress(actor_json)
|
||||||
if fields.get('matrixAddress'):
|
if fields.get('matrixAddress'):
|
||||||
if fields['matrixAddress'] != currentMatrixAddress:
|
if fields['matrixAddress'] != currentMatrixAddress:
|
||||||
setMatrixAddress(actorJson,
|
setMatrixAddress(actor_json,
|
||||||
fields['matrixAddress'])
|
fields['matrixAddress'])
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
else:
|
else:
|
||||||
if currentMatrixAddress:
|
if currentMatrixAddress:
|
||||||
setMatrixAddress(actorJson, '')
|
setMatrixAddress(actor_json, '')
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
|
|
||||||
# change SSB address
|
# change SSB address
|
||||||
currentSSBAddress = getSSBAddress(actorJson)
|
currentSSBAddress = getSSBAddress(actor_json)
|
||||||
if fields.get('ssbAddress'):
|
if fields.get('ssbAddress'):
|
||||||
if fields['ssbAddress'] != currentSSBAddress:
|
if fields['ssbAddress'] != currentSSBAddress:
|
||||||
setSSBAddress(actorJson,
|
setSSBAddress(actor_json,
|
||||||
fields['ssbAddress'])
|
fields['ssbAddress'])
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
else:
|
else:
|
||||||
if currentSSBAddress:
|
if currentSSBAddress:
|
||||||
setSSBAddress(actorJson, '')
|
setSSBAddress(actor_json, '')
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
|
|
||||||
# change blog address
|
# change blog address
|
||||||
currentBlogAddress = getBlogAddress(actorJson)
|
currentBlogAddress = getBlogAddress(actor_json)
|
||||||
if fields.get('blogAddress'):
|
if fields.get('blogAddress'):
|
||||||
if fields['blogAddress'] != currentBlogAddress:
|
if fields['blogAddress'] != currentBlogAddress:
|
||||||
setBlogAddress(actorJson,
|
setBlogAddress(actor_json,
|
||||||
fields['blogAddress'])
|
fields['blogAddress'])
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
else:
|
else:
|
||||||
if currentBlogAddress:
|
if currentBlogAddress:
|
||||||
setBlogAddress(actorJson, '')
|
setBlogAddress(actor_json, '')
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
|
|
||||||
# change Languages address
|
# change Languages address
|
||||||
currentShowLanguages = getActorLanguages(actorJson)
|
currentShowLanguages = getActorLanguages(actor_json)
|
||||||
if fields.get('showLanguages'):
|
if fields.get('showLanguages'):
|
||||||
if fields['showLanguages'] != currentShowLanguages:
|
if fields['showLanguages'] != currentShowLanguages:
|
||||||
setActorLanguages(base_dir, actorJson,
|
setActorLanguages(base_dir, actor_json,
|
||||||
fields['showLanguages'])
|
fields['showLanguages'])
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
else:
|
else:
|
||||||
if currentShowLanguages:
|
if currentShowLanguages:
|
||||||
setActorLanguages(base_dir, actorJson, '')
|
setActorLanguages(base_dir, actor_json, '')
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
|
|
||||||
# change tox address
|
# change tox address
|
||||||
currentToxAddress = getToxAddress(actorJson)
|
currentToxAddress = getToxAddress(actor_json)
|
||||||
if fields.get('toxAddress'):
|
if fields.get('toxAddress'):
|
||||||
if fields['toxAddress'] != currentToxAddress:
|
if fields['toxAddress'] != currentToxAddress:
|
||||||
setToxAddress(actorJson,
|
setToxAddress(actor_json,
|
||||||
fields['toxAddress'])
|
fields['toxAddress'])
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
else:
|
else:
|
||||||
if currentToxAddress:
|
if currentToxAddress:
|
||||||
setToxAddress(actorJson, '')
|
setToxAddress(actor_json, '')
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
|
|
||||||
# change briar address
|
# change briar address
|
||||||
currentBriarAddress = getBriarAddress(actorJson)
|
currentBriarAddress = getBriarAddress(actor_json)
|
||||||
if fields.get('briarAddress'):
|
if fields.get('briarAddress'):
|
||||||
if fields['briarAddress'] != currentBriarAddress:
|
if fields['briarAddress'] != currentBriarAddress:
|
||||||
setBriarAddress(actorJson,
|
setBriarAddress(actor_json,
|
||||||
fields['briarAddress'])
|
fields['briarAddress'])
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
else:
|
else:
|
||||||
if currentBriarAddress:
|
if currentBriarAddress:
|
||||||
setBriarAddress(actorJson, '')
|
setBriarAddress(actor_json, '')
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
|
|
||||||
# change jami address
|
# change jami address
|
||||||
currentJamiAddress = getJamiAddress(actorJson)
|
currentJamiAddress = getJamiAddress(actor_json)
|
||||||
if fields.get('jamiAddress'):
|
if fields.get('jamiAddress'):
|
||||||
if fields['jamiAddress'] != currentJamiAddress:
|
if fields['jamiAddress'] != currentJamiAddress:
|
||||||
setJamiAddress(actorJson,
|
setJamiAddress(actor_json,
|
||||||
fields['jamiAddress'])
|
fields['jamiAddress'])
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
else:
|
else:
|
||||||
if currentJamiAddress:
|
if currentJamiAddress:
|
||||||
setJamiAddress(actorJson, '')
|
setJamiAddress(actor_json, '')
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
|
|
||||||
# change cwtch address
|
# change cwtch address
|
||||||
currentCwtchAddress = getCwtchAddress(actorJson)
|
currentCwtchAddress = getCwtchAddress(actor_json)
|
||||||
if fields.get('cwtchAddress'):
|
if fields.get('cwtchAddress'):
|
||||||
if fields['cwtchAddress'] != currentCwtchAddress:
|
if fields['cwtchAddress'] != currentCwtchAddress:
|
||||||
setCwtchAddress(actorJson,
|
setCwtchAddress(actor_json,
|
||||||
fields['cwtchAddress'])
|
fields['cwtchAddress'])
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
else:
|
else:
|
||||||
if currentCwtchAddress:
|
if currentCwtchAddress:
|
||||||
setCwtchAddress(actorJson, '')
|
setCwtchAddress(actor_json, '')
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
|
|
||||||
# change Enigma public key
|
# change Enigma public key
|
||||||
currentEnigmaPubKey = getEnigmaPubKey(actorJson)
|
currentEnigmaPubKey = getEnigmaPubKey(actor_json)
|
||||||
if fields.get('enigmapubkey'):
|
if fields.get('enigmapubkey'):
|
||||||
if fields['enigmapubkey'] != currentEnigmaPubKey:
|
if fields['enigmapubkey'] != currentEnigmaPubKey:
|
||||||
setEnigmaPubKey(actorJson,
|
setEnigmaPubKey(actor_json,
|
||||||
fields['enigmapubkey'])
|
fields['enigmapubkey'])
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
else:
|
else:
|
||||||
if currentEnigmaPubKey:
|
if currentEnigmaPubKey:
|
||||||
setEnigmaPubKey(actorJson, '')
|
setEnigmaPubKey(actor_json, '')
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
|
|
||||||
# change PGP public key
|
# change PGP public key
|
||||||
currentPGPpubKey = getPGPpubKey(actorJson)
|
currentPGPpubKey = getPGPpubKey(actor_json)
|
||||||
if fields.get('pgp'):
|
if fields.get('pgp'):
|
||||||
if fields['pgp'] != currentPGPpubKey:
|
if fields['pgp'] != currentPGPpubKey:
|
||||||
setPGPpubKey(actorJson,
|
setPGPpubKey(actor_json,
|
||||||
fields['pgp'])
|
fields['pgp'])
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
else:
|
else:
|
||||||
if currentPGPpubKey:
|
if currentPGPpubKey:
|
||||||
setPGPpubKey(actorJson, '')
|
setPGPpubKey(actor_json, '')
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
|
|
||||||
# change PGP fingerprint
|
# change PGP fingerprint
|
||||||
currentPGPfingerprint = getPGPfingerprint(actorJson)
|
currentPGPfingerprint = getPGPfingerprint(actor_json)
|
||||||
if fields.get('openpgp'):
|
if fields.get('openpgp'):
|
||||||
if fields['openpgp'] != currentPGPfingerprint:
|
if fields['openpgp'] != currentPGPfingerprint:
|
||||||
setPGPfingerprint(actorJson,
|
setPGPfingerprint(actor_json,
|
||||||
fields['openpgp'])
|
fields['openpgp'])
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
else:
|
else:
|
||||||
if currentPGPfingerprint:
|
if currentPGPfingerprint:
|
||||||
setPGPfingerprint(actorJson, '')
|
setPGPfingerprint(actor_json, '')
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
|
|
||||||
# change donation link
|
# change donation link
|
||||||
currentDonateUrl = getDonationUrl(actorJson)
|
currentDonateUrl = getDonationUrl(actor_json)
|
||||||
if fields.get('donateUrl'):
|
if fields.get('donateUrl'):
|
||||||
if fields['donateUrl'] != currentDonateUrl:
|
if fields['donateUrl'] != currentDonateUrl:
|
||||||
setDonationUrl(actorJson,
|
setDonationUrl(actor_json,
|
||||||
fields['donateUrl'])
|
fields['donateUrl'])
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
else:
|
else:
|
||||||
if currentDonateUrl:
|
if currentDonateUrl:
|
||||||
setDonationUrl(actorJson, '')
|
setDonationUrl(actor_json, '')
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
|
|
||||||
# change website
|
# change website
|
||||||
currentWebsite = \
|
currentWebsite = \
|
||||||
getWebsite(actorJson, self.server.translate)
|
getWebsite(actor_json, self.server.translate)
|
||||||
if fields.get('websiteUrl'):
|
if fields.get('websiteUrl'):
|
||||||
if fields['websiteUrl'] != currentWebsite:
|
if fields['websiteUrl'] != currentWebsite:
|
||||||
setWebsite(actorJson,
|
setWebsite(actor_json,
|
||||||
fields['websiteUrl'],
|
fields['websiteUrl'],
|
||||||
self.server.translate)
|
self.server.translate)
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
else:
|
else:
|
||||||
if currentWebsite:
|
if currentWebsite:
|
||||||
setWebsite(actorJson, '', self.server.translate)
|
setWebsite(actor_json, '', self.server.translate)
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
|
|
||||||
# account moved to new address
|
# account moved to new address
|
||||||
movedTo = ''
|
movedTo = ''
|
||||||
if actorJson.get('movedTo'):
|
if actor_json.get('movedTo'):
|
||||||
movedTo = actorJson['movedTo']
|
movedTo = actor_json['movedTo']
|
||||||
if fields.get('movedTo'):
|
if fields.get('movedTo'):
|
||||||
if fields['movedTo'] != movedTo and \
|
if fields['movedTo'] != movedTo and \
|
||||||
'://' in fields['movedTo'] and \
|
'://' in fields['movedTo'] and \
|
||||||
'.' in fields['movedTo']:
|
'.' in fields['movedTo']:
|
||||||
actorJson['movedTo'] = movedTo
|
actor_json['movedTo'] = movedTo
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
else:
|
else:
|
||||||
if movedTo:
|
if movedTo:
|
||||||
del actorJson['movedTo']
|
del actor_json['movedTo']
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
|
|
||||||
# Other accounts (alsoKnownAs)
|
# Other accounts (alsoKnownAs)
|
||||||
occupationName = getOccupationName(actorJson)
|
occupationName = getOccupationName(actor_json)
|
||||||
if fields.get('occupationName'):
|
if fields.get('occupationName'):
|
||||||
fields['occupationName'] = \
|
fields['occupationName'] = \
|
||||||
removeHtml(fields['occupationName'])
|
removeHtml(fields['occupationName'])
|
||||||
if occupationName != \
|
if occupationName != \
|
||||||
fields['occupationName']:
|
fields['occupationName']:
|
||||||
setOccupationName(actorJson,
|
setOccupationName(actor_json,
|
||||||
fields['occupationName'])
|
fields['occupationName'])
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
else:
|
else:
|
||||||
if occupationName:
|
if occupationName:
|
||||||
setOccupationName(actorJson, '')
|
setOccupationName(actor_json, '')
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
|
|
||||||
# Other accounts (alsoKnownAs)
|
# Other accounts (alsoKnownAs)
|
||||||
alsoKnownAs = []
|
alsoKnownAs = []
|
||||||
if actorJson.get('alsoKnownAs'):
|
if actor_json.get('alsoKnownAs'):
|
||||||
alsoKnownAs = actorJson['alsoKnownAs']
|
alsoKnownAs = actor_json['alsoKnownAs']
|
||||||
if fields.get('alsoKnownAs'):
|
if fields.get('alsoKnownAs'):
|
||||||
alsoKnownAsStr = ''
|
alsoKnownAsStr = ''
|
||||||
alsoKnownAsCtr = 0
|
alsoKnownAsCtr = 0
|
||||||
|
@ -5510,30 +5510,30 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if '://' in altActor and '.' in altActor:
|
if '://' in altActor and '.' in altActor:
|
||||||
if altActor not in alsoKnownAs:
|
if altActor not in alsoKnownAs:
|
||||||
alsoKnownAs.append(altActor)
|
alsoKnownAs.append(altActor)
|
||||||
actorJson['alsoKnownAs'] = alsoKnownAs
|
actor_json['alsoKnownAs'] = alsoKnownAs
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
else:
|
else:
|
||||||
if alsoKnownAs:
|
if alsoKnownAs:
|
||||||
del actorJson['alsoKnownAs']
|
del actor_json['alsoKnownAs']
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
|
|
||||||
# change user bio
|
# change user bio
|
||||||
if fields.get('bio'):
|
if fields.get('bio'):
|
||||||
if fields['bio'] != actorJson['summary']:
|
if fields['bio'] != actor_json['summary']:
|
||||||
bioStr = removeHtml(fields['bio'])
|
bioStr = removeHtml(fields['bio'])
|
||||||
if not isFiltered(base_dir,
|
if not isFiltered(base_dir,
|
||||||
nickname, domain, bioStr):
|
nickname, domain, bioStr):
|
||||||
actorTags = {}
|
actorTags = {}
|
||||||
actorJson['summary'] = \
|
actor_json['summary'] = \
|
||||||
addHtmlTags(base_dir,
|
addHtmlTags(base_dir,
|
||||||
http_prefix,
|
http_prefix,
|
||||||
nickname,
|
nickname,
|
||||||
domain_full,
|
domain_full,
|
||||||
bioStr, [], actorTags)
|
bioStr, [], actorTags)
|
||||||
if actorTags:
|
if actorTags:
|
||||||
actorJson['tag'] = []
|
actor_json['tag'] = []
|
||||||
for tagName, tag in actorTags.items():
|
for tagName, tag in actorTags.items():
|
||||||
actorJson['tag'].append(tag)
|
actor_json['tag'].append(tag)
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
else:
|
else:
|
||||||
if checkNameAndBio:
|
if checkNameAndBio:
|
||||||
|
@ -5905,7 +5905,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
# approve followers
|
# approve followers
|
||||||
if onFinalWelcomeScreen:
|
if onFinalWelcomeScreen:
|
||||||
# Default setting created via the welcome screen
|
# Default setting created via the welcome screen
|
||||||
actorJson['manuallyApprovesFollowers'] = True
|
actor_json['manuallyApprovesFollowers'] = True
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
else:
|
else:
|
||||||
approveFollowers = False
|
approveFollowers = False
|
||||||
|
@ -5913,8 +5913,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if fields['approveFollowers'] == 'on':
|
if fields['approveFollowers'] == 'on':
|
||||||
approveFollowers = True
|
approveFollowers = True
|
||||||
if approveFollowers != \
|
if approveFollowers != \
|
||||||
actorJson['manuallyApprovesFollowers']:
|
actor_json['manuallyApprovesFollowers']:
|
||||||
actorJson['manuallyApprovesFollowers'] = \
|
actor_json['manuallyApprovesFollowers'] = \
|
||||||
approveFollowers
|
approveFollowers
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
|
|
||||||
|
@ -6174,23 +6174,23 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
# this account is a bot
|
# this account is a bot
|
||||||
if fields.get('isBot'):
|
if fields.get('isBot'):
|
||||||
if fields['isBot'] == 'on':
|
if fields['isBot'] == 'on':
|
||||||
if actorJson['type'] != 'Service':
|
if actor_json['type'] != 'Service':
|
||||||
actorJson['type'] = 'Service'
|
actor_json['type'] = 'Service'
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
else:
|
else:
|
||||||
# this account is a group
|
# this account is a group
|
||||||
if fields.get('isGroup'):
|
if fields.get('isGroup'):
|
||||||
if fields['isGroup'] == 'on':
|
if fields['isGroup'] == 'on':
|
||||||
if actorJson['type'] != 'Group':
|
if actor_json['type'] != 'Group':
|
||||||
# only allow admin to create groups
|
# only allow admin to create groups
|
||||||
if path.startswith('/users/' +
|
if path.startswith('/users/' +
|
||||||
adminNickname + '/'):
|
adminNickname + '/'):
|
||||||
actorJson['type'] = 'Group'
|
actor_json['type'] = 'Group'
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
else:
|
else:
|
||||||
# this account is a person (default)
|
# this account is a person (default)
|
||||||
if actorJson['type'] != 'Person':
|
if actor_json['type'] != 'Person':
|
||||||
actorJson['type'] = 'Person'
|
actor_json['type'] = 'Person'
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
|
|
||||||
# grayscale theme
|
# grayscale theme
|
||||||
|
@ -6478,23 +6478,23 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
# save actor json file within accounts
|
# save actor json file within accounts
|
||||||
if actorChanged:
|
if actorChanged:
|
||||||
# update the context for the actor
|
# update the context for the actor
|
||||||
actorJson['@context'] = [
|
actor_json['@context'] = [
|
||||||
'https://www.w3.org/ns/activitystreams',
|
'https://www.w3.org/ns/activitystreams',
|
||||||
'https://w3id.org/security/v1',
|
'https://w3id.org/security/v1',
|
||||||
getDefaultPersonContext()
|
getDefaultPersonContext()
|
||||||
]
|
]
|
||||||
if actorJson.get('nomadicLocations'):
|
if actor_json.get('nomadicLocations'):
|
||||||
del actorJson['nomadicLocations']
|
del actor_json['nomadicLocations']
|
||||||
if not actorJson.get('featured'):
|
if not actor_json.get('featured'):
|
||||||
actorJson['featured'] = \
|
actor_json['featured'] = \
|
||||||
actorJson['id'] + '/collections/featured'
|
actor_json['id'] + '/collections/featured'
|
||||||
if not actorJson.get('featuredTags'):
|
if not actor_json.get('featuredTags'):
|
||||||
actorJson['featuredTags'] = \
|
actor_json['featuredTags'] = \
|
||||||
actorJson['id'] + '/collections/tags'
|
actor_json['id'] + '/collections/tags'
|
||||||
randomizeActorImages(actorJson)
|
randomizeActorImages(actor_json)
|
||||||
addActorUpdateTimestamp(actorJson)
|
addActorUpdateTimestamp(actor_json)
|
||||||
# save the actor
|
# save the actor
|
||||||
saveJson(actorJson, actorFilename)
|
saveJson(actor_json, actorFilename)
|
||||||
webfingerUpdate(base_dir,
|
webfingerUpdate(base_dir,
|
||||||
nickname, domain,
|
nickname, domain,
|
||||||
onion_domain,
|
onion_domain,
|
||||||
|
@ -6502,20 +6502,20 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
# also copy to the actors cache and
|
# also copy to the actors cache and
|
||||||
# person_cache in memory
|
# person_cache in memory
|
||||||
storePersonInCache(base_dir,
|
storePersonInCache(base_dir,
|
||||||
actorJson['id'], actorJson,
|
actor_json['id'], actor_json,
|
||||||
self.server.person_cache,
|
self.server.person_cache,
|
||||||
True)
|
True)
|
||||||
# clear any cached images for this actor
|
# clear any cached images for this actor
|
||||||
idStr = actorJson['id'].replace('/', '-')
|
idStr = actor_json['id'].replace('/', '-')
|
||||||
removeAvatarFromCache(base_dir, idStr)
|
removeAvatarFromCache(base_dir, idStr)
|
||||||
# save the actor to the cache
|
# save the actor to the cache
|
||||||
actorCacheFilename = \
|
actorCacheFilename = \
|
||||||
base_dir + '/cache/actors/' + \
|
base_dir + '/cache/actors/' + \
|
||||||
actorJson['id'].replace('/', '#') + '.json'
|
actor_json['id'].replace('/', '#') + '.json'
|
||||||
saveJson(actorJson, actorCacheFilename)
|
saveJson(actor_json, actorCacheFilename)
|
||||||
# send profile update to followers
|
# send profile update to followers
|
||||||
pubNumber, pubDate = getStatusNumber()
|
pubNumber, pubDate = getStatusNumber()
|
||||||
updateActorJson = getActorUpdateJson(actorJson)
|
updateActorJson = getActorUpdateJson(actor_json)
|
||||||
print('Sending actor update: ' + str(updateActorJson))
|
print('Sending actor update: ' + str(updateActorJson))
|
||||||
self._postToOutbox(updateActorJson,
|
self._postToOutbox(updateActorJson,
|
||||||
self.server.project_version,
|
self.server.project_version,
|
||||||
|
@ -7104,34 +7104,35 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
lockedAccount = False
|
lockedAccount = False
|
||||||
alsoKnownAs = None
|
alsoKnownAs = None
|
||||||
movedTo = ''
|
movedTo = ''
|
||||||
actorJson = getPersonFromCache(base_dir,
|
actor_json = \
|
||||||
optionsActor,
|
getPersonFromCache(base_dir,
|
||||||
self.server.person_cache,
|
optionsActor,
|
||||||
True)
|
self.server.person_cache,
|
||||||
if actorJson:
|
True)
|
||||||
if actorJson.get('movedTo'):
|
if actor_json:
|
||||||
movedTo = actorJson['movedTo']
|
if actor_json.get('movedTo'):
|
||||||
|
movedTo = actor_json['movedTo']
|
||||||
if '"' in movedTo:
|
if '"' in movedTo:
|
||||||
movedTo = movedTo.split('"')[1]
|
movedTo = movedTo.split('"')[1]
|
||||||
if actorJson['type'] == 'Group':
|
if actor_json['type'] == 'Group':
|
||||||
isGroup = True
|
isGroup = True
|
||||||
lockedAccount = getLockedAccount(actorJson)
|
lockedAccount = getLockedAccount(actor_json)
|
||||||
donateUrl = getDonationUrl(actorJson)
|
donateUrl = getDonationUrl(actor_json)
|
||||||
websiteUrl = getWebsite(actorJson, self.server.translate)
|
websiteUrl = getWebsite(actor_json, self.server.translate)
|
||||||
xmppAddress = getXmppAddress(actorJson)
|
xmppAddress = getXmppAddress(actor_json)
|
||||||
matrixAddress = getMatrixAddress(actorJson)
|
matrixAddress = getMatrixAddress(actor_json)
|
||||||
ssbAddress = getSSBAddress(actorJson)
|
ssbAddress = getSSBAddress(actor_json)
|
||||||
blogAddress = getBlogAddress(actorJson)
|
blogAddress = getBlogAddress(actor_json)
|
||||||
toxAddress = getToxAddress(actorJson)
|
toxAddress = getToxAddress(actor_json)
|
||||||
briarAddress = getBriarAddress(actorJson)
|
briarAddress = getBriarAddress(actor_json)
|
||||||
jamiAddress = getJamiAddress(actorJson)
|
jamiAddress = getJamiAddress(actor_json)
|
||||||
cwtchAddress = getCwtchAddress(actorJson)
|
cwtchAddress = getCwtchAddress(actor_json)
|
||||||
emailAddress = getEmailAddress(actorJson)
|
emailAddress = getEmailAddress(actor_json)
|
||||||
EnigmaPubKey = getEnigmaPubKey(actorJson)
|
EnigmaPubKey = getEnigmaPubKey(actor_json)
|
||||||
PGPpubKey = getPGPpubKey(actorJson)
|
PGPpubKey = getPGPpubKey(actor_json)
|
||||||
PGPfingerprint = getPGPfingerprint(actorJson)
|
PGPfingerprint = getPGPfingerprint(actor_json)
|
||||||
if actorJson.get('alsoKnownAs'):
|
if actor_json.get('alsoKnownAs'):
|
||||||
alsoKnownAs = actorJson['alsoKnownAs']
|
alsoKnownAs = actor_json['alsoKnownAs']
|
||||||
|
|
||||||
if self.server.session:
|
if self.server.session:
|
||||||
checkForChangedActor(self.server.session,
|
checkForChangedActor(self.server.session,
|
||||||
|
@ -9661,11 +9662,11 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if not os.path.isfile(actorFilename):
|
if not os.path.isfile(actorFilename):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
actorJson = loadJson(actorFilename)
|
actor_json = loadJson(actorFilename)
|
||||||
if not actorJson:
|
if not actor_json:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if actorJson.get('hasOccupation'):
|
if actor_json.get('hasOccupation'):
|
||||||
if self._requestHTTP():
|
if self._requestHTTP():
|
||||||
getPerson = \
|
getPerson = \
|
||||||
personLookup(domain, path.replace('/roles', ''),
|
personLookup(domain, path.replace('/roles', ''),
|
||||||
|
@ -9688,7 +9689,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if self.server.keyShortcuts.get(nickname):
|
if self.server.keyShortcuts.get(nickname):
|
||||||
accessKeys = self.server.keyShortcuts[nickname]
|
accessKeys = self.server.keyShortcuts[nickname]
|
||||||
|
|
||||||
rolesList = getActorRolesList(actorJson)
|
rolesList = getActorRolesList(actor_json)
|
||||||
city = \
|
city = \
|
||||||
getSpoofedCity(self.server.city,
|
getSpoofedCity(self.server.city,
|
||||||
base_dir, nickname, domain)
|
base_dir, nickname, domain)
|
||||||
|
@ -9735,7 +9736,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.debug)
|
self.server.debug)
|
||||||
else:
|
else:
|
||||||
if self._secure_mode():
|
if self._secure_mode():
|
||||||
rolesList = getActorRolesList(actorJson)
|
rolesList = getActorRolesList(actor_json)
|
||||||
msg = json.dumps(rolesList,
|
msg = json.dumps(rolesList,
|
||||||
ensure_ascii=False)
|
ensure_ascii=False)
|
||||||
msg = msg.encode('utf-8')
|
msg = msg.encode('utf-8')
|
||||||
|
@ -9767,9 +9768,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
nickname = postSections[0]
|
nickname = postSections[0]
|
||||||
actorFilename = acctDir(base_dir, nickname, domain) + '.json'
|
actorFilename = acctDir(base_dir, nickname, domain) + '.json'
|
||||||
if os.path.isfile(actorFilename):
|
if os.path.isfile(actorFilename):
|
||||||
actorJson = loadJson(actorFilename)
|
actor_json = loadJson(actorFilename)
|
||||||
if actorJson:
|
if actor_json:
|
||||||
if noOfActorSkills(actorJson) > 0:
|
if noOfActorSkills(actor_json) > 0:
|
||||||
if self._requestHTTP():
|
if self._requestHTTP():
|
||||||
getPerson = \
|
getPerson = \
|
||||||
personLookup(domain,
|
personLookup(domain,
|
||||||
|
@ -9797,7 +9798,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
accessKeys = \
|
accessKeys = \
|
||||||
self.server.keyShortcuts[nickname]
|
self.server.keyShortcuts[nickname]
|
||||||
actorSkillsList = \
|
actorSkillsList = \
|
||||||
getOccupationSkills(actorJson)
|
getOccupationSkills(actor_json)
|
||||||
skills = getSkillsFromList(actorSkillsList)
|
skills = getSkillsFromList(actorSkillsList)
|
||||||
city = getSpoofedCity(self.server.city,
|
city = getSpoofedCity(self.server.city,
|
||||||
base_dir,
|
base_dir,
|
||||||
|
@ -9854,7 +9855,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
else:
|
else:
|
||||||
if self._secure_mode():
|
if self._secure_mode():
|
||||||
actorSkillsList = \
|
actorSkillsList = \
|
||||||
getOccupationSkills(actorJson)
|
getOccupationSkills(actor_json)
|
||||||
skills = getSkillsFromList(actorSkillsList)
|
skills = getSkillsFromList(actorSkillsList)
|
||||||
msg = json.dumps(skills,
|
msg = json.dumps(skills,
|
||||||
ensure_ascii=False)
|
ensure_ascii=False)
|
||||||
|
@ -12188,8 +12189,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
"""Shows the profile for a person
|
"""Shows the profile for a person
|
||||||
"""
|
"""
|
||||||
# look up a person
|
# look up a person
|
||||||
actorJson = personLookup(domain, path, base_dir)
|
actor_json = personLookup(domain, path, base_dir)
|
||||||
if not actorJson:
|
if not actor_json:
|
||||||
return False
|
return False
|
||||||
if self._requestHTTP():
|
if self._requestHTTP():
|
||||||
if not self._establishSession("showPersonProfile"):
|
if not self._establishSession("showPersonProfile"):
|
||||||
|
@ -12221,7 +12222,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
base_dir,
|
base_dir,
|
||||||
http_prefix,
|
http_prefix,
|
||||||
authorized,
|
authorized,
|
||||||
actorJson, 'posts',
|
actor_json, 'posts',
|
||||||
self.server.session,
|
self.server.session,
|
||||||
self.server.cached_webfingers,
|
self.server.cached_webfingers,
|
||||||
self.server.person_cache,
|
self.server.person_cache,
|
||||||
|
@ -12254,7 +12255,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
else:
|
else:
|
||||||
if self._secure_mode():
|
if self._secure_mode():
|
||||||
acceptStr = self.headers['Accept']
|
acceptStr = self.headers['Accept']
|
||||||
msgStr = json.dumps(actorJson, ensure_ascii=False)
|
msgStr = json.dumps(actor_json, ensure_ascii=False)
|
||||||
msg = msgStr.encode('utf-8')
|
msg = msgStr.encode('utf-8')
|
||||||
msglen = len(msg)
|
msglen = len(msg)
|
||||||
if 'application/ld+json' in acceptStr:
|
if 'application/ld+json' in acceptStr:
|
||||||
|
@ -12290,8 +12291,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if self._requestHTTP():
|
if self._requestHTTP():
|
||||||
self._404()
|
self._404()
|
||||||
return False
|
return False
|
||||||
actorJson = personLookup(domain, path, base_dir)
|
actor_json = personLookup(domain, path, base_dir)
|
||||||
if not actorJson:
|
if not actor_json:
|
||||||
print('ERROR: no instance actor found')
|
print('ERROR: no instance actor found')
|
||||||
self._404()
|
self._404()
|
||||||
return False
|
return False
|
||||||
|
@ -12308,25 +12309,25 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'featuredTags', 'discoverable', 'published',
|
'featuredTags', 'discoverable', 'published',
|
||||||
'devices')
|
'devices')
|
||||||
for r in removeFields:
|
for r in removeFields:
|
||||||
if r in actorJson:
|
if r in actor_json:
|
||||||
del actorJson[r]
|
del actor_json[r]
|
||||||
actorJson['endpoints'] = {}
|
actor_json['endpoints'] = {}
|
||||||
if enable_shared_inbox:
|
if enable_shared_inbox:
|
||||||
actorJson['endpoints'] = {
|
actor_json['endpoints'] = {
|
||||||
'sharedInbox': actorDomainUrl + '/inbox'
|
'sharedInbox': actorDomainUrl + '/inbox'
|
||||||
}
|
}
|
||||||
actorJson['name'] = 'ACTOR'
|
actor_json['name'] = 'ACTOR'
|
||||||
actorJson['preferredUsername'] = domain_full
|
actor_json['preferredUsername'] = domain_full
|
||||||
actorJson['id'] = actorDomainUrl + '/actor'
|
actor_json['id'] = actorDomainUrl + '/actor'
|
||||||
actorJson['type'] = 'Application'
|
actor_json['type'] = 'Application'
|
||||||
actorJson['summary'] = 'Instance Actor'
|
actor_json['summary'] = 'Instance Actor'
|
||||||
actorJson['publicKey']['id'] = actorDomainUrl + '/actor#main-key'
|
actor_json['publicKey']['id'] = actorDomainUrl + '/actor#main-key'
|
||||||
actorJson['publicKey']['owner'] = actorDomainUrl + '/actor'
|
actor_json['publicKey']['owner'] = actorDomainUrl + '/actor'
|
||||||
actorJson['url'] = actorDomainUrl + '/actor'
|
actor_json['url'] = actorDomainUrl + '/actor'
|
||||||
actorJson['inbox'] = actorUrl + '/inbox'
|
actor_json['inbox'] = actorUrl + '/inbox'
|
||||||
actorJson['followers'] = actorUrl + '/followers'
|
actor_json['followers'] = actorUrl + '/followers'
|
||||||
actorJson['following'] = actorUrl + '/following'
|
actor_json['following'] = actorUrl + '/following'
|
||||||
msgStr = json.dumps(actorJson, ensure_ascii=False)
|
msgStr = json.dumps(actor_json, ensure_ascii=False)
|
||||||
if onion_domain and callingDomain.endswith('.onion'):
|
if onion_domain and callingDomain.endswith('.onion'):
|
||||||
msgStr = msgStr.replace(http_prefix + '://' + domain_full,
|
msgStr = msgStr.replace(http_prefix + '://' + domain_full,
|
||||||
'http://' + onion_domain)
|
'http://' + onion_domain)
|
||||||
|
|
|
@ -798,12 +798,12 @@ def _readLocalBoxPost(session, nickname: str, domain: str,
|
||||||
return post_json_object
|
return post_json_object
|
||||||
|
|
||||||
|
|
||||||
def _desktopShowActor(base_dir: str, actorJson: {}, translate: {},
|
def _desktopShowActor(base_dir: str, actor_json: {}, translate: {},
|
||||||
system_language: str, screenreader: str,
|
system_language: str, screenreader: str,
|
||||||
espeak) -> None:
|
espeak) -> None:
|
||||||
"""Shows information for the given actor
|
"""Shows information for the given actor
|
||||||
"""
|
"""
|
||||||
actor = actorJson['id']
|
actor = actor_json['id']
|
||||||
actorNickname = getNicknameFromActor(actor)
|
actorNickname = getNicknameFromActor(actor)
|
||||||
actorDomain, actorPort = getDomainFromActor(actor)
|
actorDomain, actorPort = getDomainFromActor(actor)
|
||||||
actorDomainFull = getFullDomain(actorDomain, actorPort)
|
actorDomainFull = getFullDomain(actorDomain, actorPort)
|
||||||
|
@ -812,13 +812,13 @@ def _desktopShowActor(base_dir: str, actorJson: {}, translate: {},
|
||||||
sayStr = 'Profile for ' + html.unescape(handle)
|
sayStr = 'Profile for ' + html.unescape(handle)
|
||||||
_sayCommand(sayStr, sayStr, screenreader, system_language, espeak)
|
_sayCommand(sayStr, sayStr, screenreader, system_language, espeak)
|
||||||
print(actor)
|
print(actor)
|
||||||
if actorJson.get('movedTo'):
|
if actor_json.get('movedTo'):
|
||||||
sayStr = 'Moved to ' + html.unescape(actorJson['movedTo'])
|
sayStr = 'Moved to ' + html.unescape(actor_json['movedTo'])
|
||||||
_sayCommand(sayStr, sayStr, screenreader, system_language, espeak)
|
_sayCommand(sayStr, sayStr, screenreader, system_language, espeak)
|
||||||
if actorJson.get('alsoKnownAs'):
|
if actor_json.get('alsoKnownAs'):
|
||||||
alsoKnownAsStr = ''
|
alsoKnownAsStr = ''
|
||||||
ctr = 0
|
ctr = 0
|
||||||
for altActor in actorJson['alsoKnownAs']:
|
for altActor in actor_json['alsoKnownAs']:
|
||||||
if ctr > 0:
|
if ctr > 0:
|
||||||
alsoKnownAsStr += ', '
|
alsoKnownAsStr += ', '
|
||||||
ctr += 1
|
ctr += 1
|
||||||
|
@ -826,8 +826,8 @@ def _desktopShowActor(base_dir: str, actorJson: {}, translate: {},
|
||||||
|
|
||||||
sayStr = 'Also known as ' + html.unescape(alsoKnownAsStr)
|
sayStr = 'Also known as ' + html.unescape(alsoKnownAsStr)
|
||||||
_sayCommand(sayStr, sayStr, screenreader, system_language, espeak)
|
_sayCommand(sayStr, sayStr, screenreader, system_language, espeak)
|
||||||
if actorJson.get('summary'):
|
if actor_json.get('summary'):
|
||||||
sayStr = html.unescape(removeHtml(actorJson['summary']))
|
sayStr = html.unescape(removeHtml(actor_json['summary']))
|
||||||
sayStr = sayStr.replace('"', "'")
|
sayStr = sayStr.replace('"', "'")
|
||||||
sayStr2 = speakableText(base_dir, sayStr, translate)[0]
|
sayStr2 = speakableText(base_dir, sayStr, translate)[0]
|
||||||
_sayCommand(sayStr, sayStr2, screenreader, system_language, espeak)
|
_sayCommand(sayStr, sayStr2, screenreader, system_language, espeak)
|
||||||
|
@ -869,14 +869,14 @@ def _desktopShowProfile(session, nickname: str, domain: str,
|
||||||
isHttp = False
|
isHttp = False
|
||||||
if 'http://' in actor:
|
if 'http://' in actor:
|
||||||
isHttp = True
|
isHttp = True
|
||||||
actorJson, asHeader = \
|
actor_json, asHeader = \
|
||||||
getActorJson(domain, actor, isHttp, False, False, True,
|
getActorJson(domain, actor, isHttp, False, False, True,
|
||||||
signing_priv_key_pem, session)
|
signing_priv_key_pem, session)
|
||||||
|
|
||||||
_desktopShowActor(base_dir, actorJson, translate,
|
_desktopShowActor(base_dir, actor_json, translate,
|
||||||
system_language, screenreader, espeak)
|
system_language, screenreader, espeak)
|
||||||
|
|
||||||
return actorJson
|
return actor_json
|
||||||
|
|
||||||
|
|
||||||
def _desktopShowProfileFromHandle(session, nickname: str, domain: str,
|
def _desktopShowProfileFromHandle(session, nickname: str, domain: str,
|
||||||
|
@ -890,14 +890,14 @@ def _desktopShowProfileFromHandle(session, nickname: str, domain: str,
|
||||||
"""Shows the profile for a handle
|
"""Shows the profile for a handle
|
||||||
Returns the actor json
|
Returns the actor json
|
||||||
"""
|
"""
|
||||||
actorJson, asHeader = \
|
actor_json, asHeader = \
|
||||||
getActorJson(domain, handle, False, False, False, True,
|
getActorJson(domain, handle, False, False, False, True,
|
||||||
signing_priv_key_pem, session)
|
signing_priv_key_pem, session)
|
||||||
|
|
||||||
_desktopShowActor(base_dir, actorJson, translate,
|
_desktopShowActor(base_dir, actor_json, translate,
|
||||||
system_language, screenreader, espeak)
|
system_language, screenreader, espeak)
|
||||||
|
|
||||||
return actorJson
|
return actor_json
|
||||||
|
|
||||||
|
|
||||||
def _desktopGetBoxPostObject(boxJson: {}, index: int) -> {}:
|
def _desktopGetBoxPostObject(boxJson: {}, index: int) -> {}:
|
||||||
|
@ -1410,7 +1410,7 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
|
||||||
|
|
||||||
domain_full = getFullDomain(domain, port)
|
domain_full = getFullDomain(domain, port)
|
||||||
yourActor = local_actor_url(http_prefix, nickname, domain_full)
|
yourActor = local_actor_url(http_prefix, nickname, domain_full)
|
||||||
actorJson = None
|
actor_json = None
|
||||||
|
|
||||||
notifyJson = {
|
notifyJson = {
|
||||||
"dmPostId": "Initial",
|
"dmPostId": "Initial",
|
||||||
|
@ -1656,10 +1656,10 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
|
||||||
refreshTimeline = True
|
refreshTimeline = True
|
||||||
print('')
|
print('')
|
||||||
elif commandStr.startswith('profile ') or commandStr == 'profile':
|
elif commandStr.startswith('profile ') or commandStr == 'profile':
|
||||||
actorJson = None
|
actor_json = None
|
||||||
if commandStr == 'profile':
|
if commandStr == 'profile':
|
||||||
if post_json_object:
|
if post_json_object:
|
||||||
actorJson = \
|
actor_json = \
|
||||||
_desktopShowProfile(session, nickname, domain,
|
_desktopShowProfile(session, nickname, domain,
|
||||||
http_prefix, base_dir,
|
http_prefix, base_dir,
|
||||||
currTimeline,
|
currTimeline,
|
||||||
|
@ -1695,11 +1695,11 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
|
||||||
input()
|
input()
|
||||||
prevTimelineFirstId = ''
|
prevTimelineFirstId = ''
|
||||||
refreshTimeline = True
|
refreshTimeline = True
|
||||||
elif not actorJson and boxJson:
|
elif not actor_json and boxJson:
|
||||||
_desktopClearScreen()
|
_desktopClearScreen()
|
||||||
_desktopShowBanner()
|
_desktopShowBanner()
|
||||||
postIndex = int(postIndexStr)
|
postIndex = int(postIndexStr)
|
||||||
actorJson = \
|
actor_json = \
|
||||||
_desktopShowProfile(session, nickname, domain,
|
_desktopShowProfile(session, nickname, domain,
|
||||||
http_prefix, base_dir,
|
http_prefix, base_dir,
|
||||||
currTimeline,
|
currTimeline,
|
||||||
|
@ -2201,8 +2201,8 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
|
||||||
elif (commandStr == 'follow' or
|
elif (commandStr == 'follow' or
|
||||||
commandStr.startswith('follow ')):
|
commandStr.startswith('follow ')):
|
||||||
if commandStr == 'follow':
|
if commandStr == 'follow':
|
||||||
if actorJson:
|
if actor_json:
|
||||||
followHandle = actorJson['id']
|
followHandle = actor_json['id']
|
||||||
else:
|
else:
|
||||||
followHandle = ''
|
followHandle = ''
|
||||||
else:
|
else:
|
||||||
|
|
38
donate.py
38
donate.py
|
@ -18,13 +18,13 @@ def _getWebsiteStrings() -> []:
|
||||||
return ['www', 'website', 'web', 'homepage']
|
return ['www', 'website', 'web', 'homepage']
|
||||||
|
|
||||||
|
|
||||||
def getDonationUrl(actorJson: {}) -> str:
|
def getDonationUrl(actor_json: {}) -> str:
|
||||||
"""Returns a link used for donations
|
"""Returns a link used for donations
|
||||||
"""
|
"""
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
return ''
|
return ''
|
||||||
donationType = _getDonationTypes()
|
donationType = _getDonationTypes()
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if propertyValue['name'].lower() not in donationType:
|
if propertyValue['name'].lower() not in donationType:
|
||||||
|
@ -43,14 +43,14 @@ def getDonationUrl(actorJson: {}) -> str:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
def getWebsite(actorJson: {}, translate: {}) -> str:
|
def getWebsite(actor_json: {}, translate: {}) -> str:
|
||||||
"""Returns a web address link
|
"""Returns a web address link
|
||||||
"""
|
"""
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
return ''
|
return ''
|
||||||
matchStrings = _getWebsiteStrings()
|
matchStrings = _getWebsiteStrings()
|
||||||
matchStrings.append(translate['Website'].lower())
|
matchStrings.append(translate['Website'].lower())
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if propertyValue['name'].lower() not in matchStrings:
|
if propertyValue['name'].lower() not in matchStrings:
|
||||||
|
@ -65,7 +65,7 @@ def getWebsite(actorJson: {}, translate: {}) -> str:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
def setDonationUrl(actorJson: {}, donateUrl: str) -> None:
|
def setDonationUrl(actor_json: {}, donateUrl: str) -> None:
|
||||||
"""Sets a link used for donations
|
"""Sets a link used for donations
|
||||||
"""
|
"""
|
||||||
notUrl = False
|
notUrl = False
|
||||||
|
@ -78,8 +78,8 @@ def setDonationUrl(actorJson: {}, donateUrl: str) -> None:
|
||||||
if '<' in donateUrl:
|
if '<' in donateUrl:
|
||||||
notUrl = True
|
notUrl = True
|
||||||
|
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
actorJson['attachment'] = []
|
actor_json['attachment'] = []
|
||||||
|
|
||||||
donationType = _getDonationTypes()
|
donationType = _getDonationTypes()
|
||||||
donateName = None
|
donateName = None
|
||||||
|
@ -91,7 +91,7 @@ def setDonationUrl(actorJson: {}, donateUrl: str) -> None:
|
||||||
|
|
||||||
# remove any existing value
|
# remove any existing value
|
||||||
propertyFound = None
|
propertyFound = None
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -101,7 +101,7 @@ def setDonationUrl(actorJson: {}, donateUrl: str) -> None:
|
||||||
propertyFound = propertyValue
|
propertyFound = propertyValue
|
||||||
break
|
break
|
||||||
if propertyFound:
|
if propertyFound:
|
||||||
actorJson['attachment'].remove(propertyFound)
|
actor_json['attachment'].remove(propertyFound)
|
||||||
if notUrl:
|
if notUrl:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ def setDonationUrl(actorJson: {}, donateUrl: str) -> None:
|
||||||
'" rel="me nofollow noopener noreferrer" target="_blank">' + \
|
'" rel="me nofollow noopener noreferrer" target="_blank">' + \
|
||||||
donateUrl + '</a>'
|
donateUrl + '</a>'
|
||||||
|
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -127,10 +127,10 @@ def setDonationUrl(actorJson: {}, donateUrl: str) -> None:
|
||||||
"type": "PropertyValue",
|
"type": "PropertyValue",
|
||||||
"value": donateValue
|
"value": donateValue
|
||||||
}
|
}
|
||||||
actorJson['attachment'].append(newDonate)
|
actor_json['attachment'].append(newDonate)
|
||||||
|
|
||||||
|
|
||||||
def setWebsite(actorJson: {}, websiteUrl: str, translate: {}) -> None:
|
def setWebsite(actor_json: {}, websiteUrl: str, translate: {}) -> None:
|
||||||
"""Sets a web address
|
"""Sets a web address
|
||||||
"""
|
"""
|
||||||
websiteUrl = websiteUrl.strip()
|
websiteUrl = websiteUrl.strip()
|
||||||
|
@ -144,15 +144,15 @@ def setWebsite(actorJson: {}, websiteUrl: str, translate: {}) -> None:
|
||||||
if '<' in websiteUrl:
|
if '<' in websiteUrl:
|
||||||
notUrl = True
|
notUrl = True
|
||||||
|
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
actorJson['attachment'] = []
|
actor_json['attachment'] = []
|
||||||
|
|
||||||
matchStrings = _getWebsiteStrings()
|
matchStrings = _getWebsiteStrings()
|
||||||
matchStrings.append(translate['Website'].lower())
|
matchStrings.append(translate['Website'].lower())
|
||||||
|
|
||||||
# remove any existing value
|
# remove any existing value
|
||||||
propertyFound = None
|
propertyFound = None
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -162,7 +162,7 @@ def setWebsite(actorJson: {}, websiteUrl: str, translate: {}) -> None:
|
||||||
propertyFound = propertyValue
|
propertyFound = propertyValue
|
||||||
break
|
break
|
||||||
if propertyFound:
|
if propertyFound:
|
||||||
actorJson['attachment'].remove(propertyFound)
|
actor_json['attachment'].remove(propertyFound)
|
||||||
if notUrl:
|
if notUrl:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -171,4 +171,4 @@ def setWebsite(actorJson: {}, websiteUrl: str, translate: {}) -> None:
|
||||||
"type": "PropertyValue",
|
"type": "PropertyValue",
|
||||||
"value": websiteUrl
|
"value": websiteUrl
|
||||||
}
|
}
|
||||||
actorJson['attachment'].append(newEntry)
|
actor_json['attachment'].append(newEntry)
|
||||||
|
|
20
enigma.py
20
enigma.py
|
@ -8,12 +8,12 @@ __status__ = "Production"
|
||||||
__module_group__ = "Profile Metadata"
|
__module_group__ = "Profile Metadata"
|
||||||
|
|
||||||
|
|
||||||
def getEnigmaPubKey(actorJson: {}) -> str:
|
def getEnigmaPubKey(actor_json: {}) -> str:
|
||||||
"""Returns Enigma public key for the given actor
|
"""Returns Enigma public key for the given actor
|
||||||
"""
|
"""
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
return ''
|
return ''
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue['name'].lower().startswith('enigma'):
|
if not propertyValue['name'].lower().startswith('enigma'):
|
||||||
|
@ -28,19 +28,19 @@ def getEnigmaPubKey(actorJson: {}) -> str:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
def setEnigmaPubKey(actorJson: {}, enigmaPubKey: str) -> None:
|
def setEnigmaPubKey(actor_json: {}, enigmaPubKey: str) -> None:
|
||||||
"""Sets a Enigma public key for the given actor
|
"""Sets a Enigma public key for the given actor
|
||||||
"""
|
"""
|
||||||
removeKey = False
|
removeKey = False
|
||||||
if not enigmaPubKey:
|
if not enigmaPubKey:
|
||||||
removeKey = True
|
removeKey = True
|
||||||
|
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
actorJson['attachment'] = []
|
actor_json['attachment'] = []
|
||||||
|
|
||||||
# remove any existing value
|
# remove any existing value
|
||||||
propertyFound = None
|
propertyFound = None
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -50,11 +50,11 @@ def setEnigmaPubKey(actorJson: {}, enigmaPubKey: str) -> None:
|
||||||
propertyFound = propertyValue
|
propertyFound = propertyValue
|
||||||
break
|
break
|
||||||
if propertyFound:
|
if propertyFound:
|
||||||
actorJson['attachment'].remove(propertyValue)
|
actor_json['attachment'].remove(propertyValue)
|
||||||
if removeKey:
|
if removeKey:
|
||||||
return
|
return
|
||||||
|
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -71,4 +71,4 @@ def setEnigmaPubKey(actorJson: {}, enigmaPubKey: str) -> None:
|
||||||
"type": "PropertyValue",
|
"type": "PropertyValue",
|
||||||
"value": enigmaPubKey
|
"value": enigmaPubKey
|
||||||
}
|
}
|
||||||
actorJson['attachment'].append(newenigmaPubKey)
|
actor_json['attachment'].append(newenigmaPubKey)
|
||||||
|
|
|
@ -1434,9 +1434,9 @@ def followerApprovalActive(base_dir: str, nickname: str, domain: str) -> bool:
|
||||||
manuallyApprovesFollowers = False
|
manuallyApprovesFollowers = False
|
||||||
actorFilename = acctDir(base_dir, nickname, domain) + '.json'
|
actorFilename = acctDir(base_dir, nickname, domain) + '.json'
|
||||||
if os.path.isfile(actorFilename):
|
if os.path.isfile(actorFilename):
|
||||||
actorJson = loadJson(actorFilename)
|
actor_json = loadJson(actorFilename)
|
||||||
if actorJson:
|
if actor_json:
|
||||||
if actorJson.get('manuallyApprovesFollowers'):
|
if actor_json.get('manuallyApprovesFollowers'):
|
||||||
manuallyApprovesFollowers = \
|
manuallyApprovesFollowers = \
|
||||||
actorJson['manuallyApprovesFollowers']
|
actor_json['manuallyApprovesFollowers']
|
||||||
return manuallyApprovesFollowers
|
return manuallyApprovesFollowers
|
||||||
|
|
6
inbox.py
6
inbox.py
|
@ -2608,10 +2608,10 @@ def _groupHandle(base_dir: str, handle: str) -> bool:
|
||||||
actorFile = base_dir + '/accounts/' + handle + '.json'
|
actorFile = base_dir + '/accounts/' + handle + '.json'
|
||||||
if not os.path.isfile(actorFile):
|
if not os.path.isfile(actorFile):
|
||||||
return False
|
return False
|
||||||
actorJson = loadJson(actorFile)
|
actor_json = loadJson(actorFile)
|
||||||
if not actorJson:
|
if not actor_json:
|
||||||
return False
|
return False
|
||||||
return actorJson['type'] == 'Group'
|
return actor_json['type'] == 'Group'
|
||||||
|
|
||||||
|
|
||||||
def _sendToGroupMembers(session, base_dir: str, handle: str, port: int,
|
def _sendToGroupMembers(session, base_dir: str, handle: str, port: int,
|
||||||
|
|
20
jami.py
20
jami.py
|
@ -8,12 +8,12 @@ __status__ = "Production"
|
||||||
__module_group__ = "Profile Metadata"
|
__module_group__ = "Profile Metadata"
|
||||||
|
|
||||||
|
|
||||||
def getJamiAddress(actorJson: {}) -> str:
|
def getJamiAddress(actor_json: {}) -> str:
|
||||||
"""Returns jami address for the given actor
|
"""Returns jami address for the given actor
|
||||||
"""
|
"""
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
return ''
|
return ''
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue['name'].lower().startswith('jami'):
|
if not propertyValue['name'].lower().startswith('jami'):
|
||||||
|
@ -39,7 +39,7 @@ def getJamiAddress(actorJson: {}) -> str:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
def setJamiAddress(actorJson: {}, jamiAddress: str) -> None:
|
def setJamiAddress(actor_json: {}, jamiAddress: str) -> None:
|
||||||
"""Sets an jami address for the given actor
|
"""Sets an jami address for the given actor
|
||||||
"""
|
"""
|
||||||
notJamiAddress = False
|
notJamiAddress = False
|
||||||
|
@ -57,12 +57,12 @@ def setJamiAddress(actorJson: {}, jamiAddress: str) -> None:
|
||||||
if '<' in jamiAddress:
|
if '<' in jamiAddress:
|
||||||
notJamiAddress = True
|
notJamiAddress = True
|
||||||
|
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
actorJson['attachment'] = []
|
actor_json['attachment'] = []
|
||||||
|
|
||||||
# remove any existing value
|
# remove any existing value
|
||||||
propertyFound = None
|
propertyFound = None
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -72,11 +72,11 @@ def setJamiAddress(actorJson: {}, jamiAddress: str) -> None:
|
||||||
propertyFound = propertyValue
|
propertyFound = propertyValue
|
||||||
break
|
break
|
||||||
if propertyFound:
|
if propertyFound:
|
||||||
actorJson['attachment'].remove(propertyFound)
|
actor_json['attachment'].remove(propertyFound)
|
||||||
if notJamiAddress:
|
if notJamiAddress:
|
||||||
return
|
return
|
||||||
|
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -93,4 +93,4 @@ def setJamiAddress(actorJson: {}, jamiAddress: str) -> None:
|
||||||
"type": "PropertyValue",
|
"type": "PropertyValue",
|
||||||
"value": jamiAddress
|
"value": jamiAddress
|
||||||
}
|
}
|
||||||
actorJson['attachment'].append(newJamiAddress)
|
actor_json['attachment'].append(newJamiAddress)
|
||||||
|
|
19
languages.py
19
languages.py
|
@ -18,10 +18,10 @@ from utils import local_actor_url
|
||||||
from cache import getPersonFromCache
|
from cache import getPersonFromCache
|
||||||
|
|
||||||
|
|
||||||
def getActorLanguages(actorJson: {}) -> str:
|
def getActorLanguages(actor_json: {}) -> str:
|
||||||
"""Returns a string containing languages used by the given actor
|
"""Returns a string containing languages used by the given actor
|
||||||
"""
|
"""
|
||||||
langList = get_actor_languages_list(actorJson)
|
langList = get_actor_languages_list(actor_json)
|
||||||
if not langList:
|
if not langList:
|
||||||
return ''
|
return ''
|
||||||
languagesStr = ''
|
languagesStr = ''
|
||||||
|
@ -33,7 +33,8 @@ def getActorLanguages(actorJson: {}) -> str:
|
||||||
return languagesStr
|
return languagesStr
|
||||||
|
|
||||||
|
|
||||||
def setActorLanguages(base_dir: str, actorJson: {}, languagesStr: str) -> None:
|
def setActorLanguages(base_dir: str, actor_json: {},
|
||||||
|
languagesStr: str) -> None:
|
||||||
"""Sets the languages used by the given actor
|
"""Sets the languages used by the given actor
|
||||||
"""
|
"""
|
||||||
separator = ','
|
separator = ','
|
||||||
|
@ -66,7 +67,7 @@ def setActorLanguages(base_dir: str, actorJson: {}, languagesStr: str) -> None:
|
||||||
|
|
||||||
# remove any existing value
|
# remove any existing value
|
||||||
propertyFound = None
|
propertyFound = None
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -76,7 +77,7 @@ def setActorLanguages(base_dir: str, actorJson: {}, languagesStr: str) -> None:
|
||||||
propertyFound = propertyValue
|
propertyFound = propertyValue
|
||||||
break
|
break
|
||||||
if propertyFound:
|
if propertyFound:
|
||||||
actorJson['attachment'].remove(propertyFound)
|
actor_json['attachment'].remove(propertyFound)
|
||||||
|
|
||||||
if not langList2:
|
if not langList2:
|
||||||
return
|
return
|
||||||
|
@ -86,7 +87,7 @@ def setActorLanguages(base_dir: str, actorJson: {}, languagesStr: str) -> None:
|
||||||
"type": "PropertyValue",
|
"type": "PropertyValue",
|
||||||
"value": langList2
|
"value": langList2
|
||||||
}
|
}
|
||||||
actorJson['attachment'].append(newLanguages)
|
actor_json['attachment'].append(newLanguages)
|
||||||
|
|
||||||
|
|
||||||
def understoodPostLanguage(base_dir: str, nickname: str, domain: str,
|
def understoodPostLanguage(base_dir: str, nickname: str, domain: str,
|
||||||
|
@ -106,11 +107,11 @@ def understoodPostLanguage(base_dir: str, nickname: str, domain: str,
|
||||||
if msgObject['contentMap'].get(system_language):
|
if msgObject['contentMap'].get(system_language):
|
||||||
return True
|
return True
|
||||||
personUrl = local_actor_url(http_prefix, nickname, domain_full)
|
personUrl = local_actor_url(http_prefix, nickname, domain_full)
|
||||||
actorJson = getPersonFromCache(base_dir, personUrl, person_cache, False)
|
actor_json = getPersonFromCache(base_dir, personUrl, person_cache, False)
|
||||||
if not actorJson:
|
if not actor_json:
|
||||||
print('WARN: unable to load actor to check languages ' + personUrl)
|
print('WARN: unable to load actor to check languages ' + personUrl)
|
||||||
return False
|
return False
|
||||||
languagesUnderstood = get_actor_languages_list(actorJson)
|
languagesUnderstood = get_actor_languages_list(actor_json)
|
||||||
if not languagesUnderstood:
|
if not languagesUnderstood:
|
||||||
return True
|
return True
|
||||||
for lang in languagesUnderstood:
|
for lang in languagesUnderstood:
|
||||||
|
|
20
matrix.py
20
matrix.py
|
@ -8,12 +8,12 @@ __status__ = "Production"
|
||||||
__module_group__ = "Profile Metadata"
|
__module_group__ = "Profile Metadata"
|
||||||
|
|
||||||
|
|
||||||
def getMatrixAddress(actorJson: {}) -> str:
|
def getMatrixAddress(actor_json: {}) -> str:
|
||||||
"""Returns matrix address for the given actor
|
"""Returns matrix address for the given actor
|
||||||
"""
|
"""
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
return ''
|
return ''
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue['name'].lower().startswith('matrix'):
|
if not propertyValue['name'].lower().startswith('matrix'):
|
||||||
|
@ -36,15 +36,15 @@ def getMatrixAddress(actorJson: {}) -> str:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
def setMatrixAddress(actorJson: {}, matrixAddress: str) -> None:
|
def setMatrixAddress(actor_json: {}, matrixAddress: str) -> None:
|
||||||
"""Sets an matrix address for the given actor
|
"""Sets an matrix address for the given actor
|
||||||
"""
|
"""
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
actorJson['attachment'] = []
|
actor_json['attachment'] = []
|
||||||
|
|
||||||
# remove any existing value
|
# remove any existing value
|
||||||
propertyFound = None
|
propertyFound = None
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -54,7 +54,7 @@ def setMatrixAddress(actorJson: {}, matrixAddress: str) -> None:
|
||||||
propertyFound = propertyValue
|
propertyFound = propertyValue
|
||||||
break
|
break
|
||||||
if propertyFound:
|
if propertyFound:
|
||||||
actorJson['attachment'].remove(propertyFound)
|
actor_json['attachment'].remove(propertyFound)
|
||||||
|
|
||||||
if '@' not in matrixAddress:
|
if '@' not in matrixAddress:
|
||||||
return
|
return
|
||||||
|
@ -69,7 +69,7 @@ def setMatrixAddress(actorJson: {}, matrixAddress: str) -> None:
|
||||||
if ':' not in matrixAddress:
|
if ':' not in matrixAddress:
|
||||||
return
|
return
|
||||||
|
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -86,4 +86,4 @@ def setMatrixAddress(actorJson: {}, matrixAddress: str) -> None:
|
||||||
"type": "PropertyValue",
|
"type": "PropertyValue",
|
||||||
"value": matrixAddress
|
"value": matrixAddress
|
||||||
}
|
}
|
||||||
actorJson['attachment'].append(newMatrixAddress)
|
actor_json['attachment'].append(newMatrixAddress)
|
||||||
|
|
24
outbox.py
24
outbox.py
|
@ -123,8 +123,8 @@ def _outboxPersonReceiveUpdate(recentPostsCache: {},
|
||||||
if not os.path.isfile(actorFilename):
|
if not os.path.isfile(actorFilename):
|
||||||
print('actorFilename not found: ' + actorFilename)
|
print('actorFilename not found: ' + actorFilename)
|
||||||
return
|
return
|
||||||
actorJson = loadJson(actorFilename)
|
actor_json = loadJson(actorFilename)
|
||||||
if not actorJson:
|
if not actor_json:
|
||||||
return
|
return
|
||||||
actorChanged = False
|
actorChanged = False
|
||||||
# update fields within actor
|
# update fields within actor
|
||||||
|
@ -140,26 +140,26 @@ def _outboxPersonReceiveUpdate(recentPostsCache: {},
|
||||||
continue
|
continue
|
||||||
if newPropertyValue['type'] != 'PropertyValue':
|
if newPropertyValue['type'] != 'PropertyValue':
|
||||||
continue
|
continue
|
||||||
if 'attachment' not in actorJson:
|
if 'attachment' not in actor_json:
|
||||||
continue
|
continue
|
||||||
found = False
|
found = False
|
||||||
for attachIdx in range(len(actorJson['attachment'])):
|
for attachIdx in range(len(actor_json['attachment'])):
|
||||||
if actorJson['attachment'][attachIdx]['type'] != \
|
if actor_json['attachment'][attachIdx]['type'] != \
|
||||||
'PropertyValue':
|
'PropertyValue':
|
||||||
continue
|
continue
|
||||||
if actorJson['attachment'][attachIdx]['name'] != \
|
if actor_json['attachment'][attachIdx]['name'] != \
|
||||||
newPropertyValue['name']:
|
newPropertyValue['name']:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
if actorJson['attachment'][attachIdx]['value'] != \
|
if actor_json['attachment'][attachIdx]['value'] != \
|
||||||
newPropertyValue['value']:
|
newPropertyValue['value']:
|
||||||
actorJson['attachment'][attachIdx]['value'] = \
|
actor_json['attachment'][attachIdx]['value'] = \
|
||||||
newPropertyValue['value']
|
newPropertyValue['value']
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
found = True
|
found = True
|
||||||
break
|
break
|
||||||
if not found:
|
if not found:
|
||||||
actorJson['attachment'].append({
|
actor_json['attachment'].append({
|
||||||
"name": newPropertyValue['name'],
|
"name": newPropertyValue['name'],
|
||||||
"type": "PropertyValue",
|
"type": "PropertyValue",
|
||||||
"value": newPropertyValue['value']
|
"value": newPropertyValue['value']
|
||||||
|
@ -167,12 +167,12 @@ def _outboxPersonReceiveUpdate(recentPostsCache: {},
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
# save actor to file
|
# save actor to file
|
||||||
if actorChanged:
|
if actorChanged:
|
||||||
saveJson(actorJson, actorFilename)
|
saveJson(actor_json, actorFilename)
|
||||||
if debug:
|
if debug:
|
||||||
print('actor saved: ' + actorFilename)
|
print('actor saved: ' + actorFilename)
|
||||||
if debug:
|
if debug:
|
||||||
print('New attachment: ' + str(actorJson['attachment']))
|
print('New attachment: ' + str(actor_json['attachment']))
|
||||||
message_json['object'] = actorJson
|
message_json['object'] = actor_json
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: actor update via c2s - ' + nickname + '@' + domain)
|
print('DEBUG: actor update via c2s - ' + nickname + '@' + domain)
|
||||||
|
|
||||||
|
|
98
person.py
98
person.py
|
@ -196,11 +196,11 @@ def randomizeActorImages(personJson: {}) -> None:
|
||||||
'/image' + randStr + '.' + existingExtension
|
'/image' + randStr + '.' + existingExtension
|
||||||
|
|
||||||
|
|
||||||
def getActorUpdateJson(actorJson: {}) -> {}:
|
def getActorUpdateJson(actor_json: {}) -> {}:
|
||||||
"""Returns the json for an Person Update
|
"""Returns the json for an Person Update
|
||||||
"""
|
"""
|
||||||
pubNumber, _ = getStatusNumber()
|
pubNumber, _ = getStatusNumber()
|
||||||
manuallyApprovesFollowers = actorJson['manuallyApprovesFollowers']
|
manuallyApprovesFollowers = actor_json['manuallyApprovesFollowers']
|
||||||
return {
|
return {
|
||||||
'@context': [
|
'@context': [
|
||||||
"https://www.w3.org/ns/activitystreams",
|
"https://www.w3.org/ns/activitystreams",
|
||||||
|
@ -271,38 +271,38 @@ def getActorUpdateJson(actorJson: {}) -> {}:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'id': actorJson['id'] + '#updates/' + pubNumber,
|
'id': actor_json['id'] + '#updates/' + pubNumber,
|
||||||
'type': 'Update',
|
'type': 'Update',
|
||||||
'actor': actorJson['id'],
|
'actor': actor_json['id'],
|
||||||
'to': ['https://www.w3.org/ns/activitystreams#Public'],
|
'to': ['https://www.w3.org/ns/activitystreams#Public'],
|
||||||
'cc': [actorJson['id'] + '/followers'],
|
'cc': [actor_json['id'] + '/followers'],
|
||||||
'object': {
|
'object': {
|
||||||
'id': actorJson['id'],
|
'id': actor_json['id'],
|
||||||
'type': actorJson['type'],
|
'type': actor_json['type'],
|
||||||
'icon': {
|
'icon': {
|
||||||
'type': 'Image',
|
'type': 'Image',
|
||||||
'url': actorJson['icon']['url']
|
'url': actor_json['icon']['url']
|
||||||
},
|
},
|
||||||
'image': {
|
'image': {
|
||||||
'type': 'Image',
|
'type': 'Image',
|
||||||
'url': actorJson['image']['url']
|
'url': actor_json['image']['url']
|
||||||
},
|
},
|
||||||
'attachment': actorJson['attachment'],
|
'attachment': actor_json['attachment'],
|
||||||
'following': actorJson['id'] + '/following',
|
'following': actor_json['id'] + '/following',
|
||||||
'followers': actorJson['id'] + '/followers',
|
'followers': actor_json['id'] + '/followers',
|
||||||
'inbox': actorJson['id'] + '/inbox',
|
'inbox': actor_json['id'] + '/inbox',
|
||||||
'outbox': actorJson['id'] + '/outbox',
|
'outbox': actor_json['id'] + '/outbox',
|
||||||
'featured': actorJson['id'] + '/collections/featured',
|
'featured': actor_json['id'] + '/collections/featured',
|
||||||
'featuredTags': actorJson['id'] + '/collections/tags',
|
'featuredTags': actor_json['id'] + '/collections/tags',
|
||||||
'preferredUsername': actorJson['preferredUsername'],
|
'preferredUsername': actor_json['preferredUsername'],
|
||||||
'name': actorJson['name'],
|
'name': actor_json['name'],
|
||||||
'summary': actorJson['summary'],
|
'summary': actor_json['summary'],
|
||||||
'url': actorJson['url'],
|
'url': actor_json['url'],
|
||||||
'manuallyApprovesFollowers': manuallyApprovesFollowers,
|
'manuallyApprovesFollowers': manuallyApprovesFollowers,
|
||||||
'discoverable': actorJson['discoverable'],
|
'discoverable': actor_json['discoverable'],
|
||||||
'published': actorJson['published'],
|
'published': actor_json['published'],
|
||||||
'devices': actorJson['devices'],
|
'devices': actor_json['devices'],
|
||||||
"publicKey": actorJson['publicKey'],
|
"publicKey": actor_json['publicKey'],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1643,15 +1643,15 @@ def getPersonAvatarUrl(base_dir: str, personUrl: str, person_cache: {},
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def addActorUpdateTimestamp(actorJson: {}) -> None:
|
def addActorUpdateTimestamp(actor_json: {}) -> None:
|
||||||
"""Adds 'updated' fields with a timestamp
|
"""Adds 'updated' fields with a timestamp
|
||||||
"""
|
"""
|
||||||
updatedTime = datetime.datetime.utcnow()
|
updatedTime = datetime.datetime.utcnow()
|
||||||
currDateStr = updatedTime.strftime("%Y-%m-%dT%H:%M:%SZ")
|
currDateStr = updatedTime.strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||||
actorJson['updated'] = currDateStr
|
actor_json['updated'] = currDateStr
|
||||||
# add updated timestamp to avatar and banner
|
# add updated timestamp to avatar and banner
|
||||||
actorJson['icon']['updated'] = currDateStr
|
actor_json['icon']['updated'] = currDateStr
|
||||||
actorJson['image']['updated'] = currDateStr
|
actor_json['image']['updated'] = currDateStr
|
||||||
|
|
||||||
|
|
||||||
def validSendingActor(session, base_dir: str,
|
def validSendingActor(session, base_dir: str,
|
||||||
|
@ -1675,26 +1675,26 @@ def validSendingActor(session, base_dir: str,
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# get their actor
|
# get their actor
|
||||||
actorJson = getPersonFromCache(base_dir, sendingActor, person_cache, True)
|
actor_json = getPersonFromCache(base_dir, sendingActor, person_cache, True)
|
||||||
downloadedActor = False
|
downloadedActor = False
|
||||||
if not actorJson:
|
if not actor_json:
|
||||||
# download the actor
|
# download the actor
|
||||||
actorJson, _ = getActorJson(domain, sendingActor,
|
actor_json, _ = getActorJson(domain, sendingActor,
|
||||||
True, False, debug, True,
|
True, False, debug, True,
|
||||||
signing_priv_key_pem, session)
|
signing_priv_key_pem, session)
|
||||||
if actorJson:
|
if actor_json:
|
||||||
downloadedActor = True
|
downloadedActor = True
|
||||||
if not actorJson:
|
if not actor_json:
|
||||||
# if the actor couldn't be obtained then proceed anyway
|
# if the actor couldn't be obtained then proceed anyway
|
||||||
return True
|
return True
|
||||||
if not actorJson.get('preferredUsername'):
|
if not actor_json.get('preferredUsername'):
|
||||||
print('REJECT: no preferredUsername within actor ' + str(actorJson))
|
print('REJECT: no preferredUsername within actor ' + str(actor_json))
|
||||||
return False
|
return False
|
||||||
# does the actor have a bio ?
|
# does the actor have a bio ?
|
||||||
if not unit_test:
|
if not unit_test:
|
||||||
bioStr = ''
|
bioStr = ''
|
||||||
if actorJson.get('summary'):
|
if actor_json.get('summary'):
|
||||||
bioStr = removeHtml(actorJson['summary']).strip()
|
bioStr = removeHtml(actor_json['summary']).strip()
|
||||||
if not bioStr:
|
if not bioStr:
|
||||||
# allow no bio if it's an actor in this instance
|
# allow no bio if it's an actor in this instance
|
||||||
if domain not in sendingActor:
|
if domain not in sendingActor:
|
||||||
|
@ -1705,11 +1705,11 @@ def validSendingActor(session, base_dir: str,
|
||||||
print('REJECT: actor bio is not long enough ' +
|
print('REJECT: actor bio is not long enough ' +
|
||||||
sendingActor + ' ' + bioStr)
|
sendingActor + ' ' + bioStr)
|
||||||
return False
|
return False
|
||||||
bioStr += ' ' + removeHtml(actorJson['preferredUsername'])
|
bioStr += ' ' + removeHtml(actor_json['preferredUsername'])
|
||||||
|
|
||||||
if actorJson.get('attachment'):
|
if actor_json.get('attachment'):
|
||||||
if isinstance(actorJson['attachment'], list):
|
if isinstance(actor_json['attachment'], list):
|
||||||
for tag in actorJson['attachment']:
|
for tag in actor_json['attachment']:
|
||||||
if not isinstance(tag, dict):
|
if not isinstance(tag, dict):
|
||||||
continue
|
continue
|
||||||
if not tag.get('name'):
|
if not tag.get('name'):
|
||||||
|
@ -1721,8 +1721,8 @@ def validSendingActor(session, base_dir: str,
|
||||||
if isinstance(tag['value'], str):
|
if isinstance(tag['value'], str):
|
||||||
bioStr += ' ' + tag['value']
|
bioStr += ' ' + tag['value']
|
||||||
|
|
||||||
if actorJson.get('name'):
|
if actor_json.get('name'):
|
||||||
bioStr += ' ' + removeHtml(actorJson['name'])
|
bioStr += ' ' + removeHtml(actor_json['name'])
|
||||||
if containsInvalidChars(bioStr):
|
if containsInvalidChars(bioStr):
|
||||||
print('REJECT: post actor bio contains invalid characters')
|
print('REJECT: post actor bio contains invalid characters')
|
||||||
return False
|
return False
|
||||||
|
@ -1734,11 +1734,11 @@ def validSendingActor(session, base_dir: str,
|
||||||
|
|
||||||
# Check any attached fields for the actor.
|
# Check any attached fields for the actor.
|
||||||
# Spam actors will sometimes have attached fields which are all empty
|
# Spam actors will sometimes have attached fields which are all empty
|
||||||
if actorJson.get('attachment'):
|
if actor_json.get('attachment'):
|
||||||
if isinstance(actorJson['attachment'], list):
|
if isinstance(actor_json['attachment'], list):
|
||||||
noOfTags = 0
|
noOfTags = 0
|
||||||
tagsWithoutValue = 0
|
tagsWithoutValue = 0
|
||||||
for tag in actorJson['attachment']:
|
for tag in actor_json['attachment']:
|
||||||
if not isinstance(tag, dict):
|
if not isinstance(tag, dict):
|
||||||
continue
|
continue
|
||||||
if not tag.get('name'):
|
if not tag.get('name'):
|
||||||
|
@ -1765,6 +1765,6 @@ def validSendingActor(session, base_dir: str,
|
||||||
if downloadedActor:
|
if downloadedActor:
|
||||||
# if the actor is valid and was downloaded then
|
# if the actor is valid and was downloaded then
|
||||||
# store it in the cache, but don't write it to file
|
# store it in the cache, but don't write it to file
|
||||||
storePersonInCache(base_dir, sendingActor, actorJson, person_cache,
|
storePersonInCache(base_dir, sendingActor, actor_json, person_cache,
|
||||||
False)
|
False)
|
||||||
return True
|
return True
|
||||||
|
|
98
pgp.py
98
pgp.py
|
@ -23,12 +23,12 @@ from auth import createBasicAuthHeader
|
||||||
from session import postJson
|
from session import postJson
|
||||||
|
|
||||||
|
|
||||||
def getEmailAddress(actorJson: {}) -> str:
|
def getEmailAddress(actor_json: {}) -> str:
|
||||||
"""Returns the email address for the given actor
|
"""Returns the email address for the given actor
|
||||||
"""
|
"""
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
return ''
|
return ''
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue['name'].lower().startswith('email'):
|
if not propertyValue['name'].lower().startswith('email'):
|
||||||
|
@ -47,12 +47,12 @@ def getEmailAddress(actorJson: {}) -> str:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
def getPGPpubKey(actorJson: {}) -> str:
|
def getPGPpubKey(actor_json: {}) -> str:
|
||||||
"""Returns PGP public key for the given actor
|
"""Returns PGP public key for the given actor
|
||||||
"""
|
"""
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
return ''
|
return ''
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue['name'].lower().startswith('pgp'):
|
if not propertyValue['name'].lower().startswith('pgp'):
|
||||||
|
@ -69,12 +69,12 @@ def getPGPpubKey(actorJson: {}) -> str:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
def getPGPfingerprint(actorJson: {}) -> str:
|
def getPGPfingerprint(actor_json: {}) -> str:
|
||||||
"""Returns PGP fingerprint for the given actor
|
"""Returns PGP fingerprint for the given actor
|
||||||
"""
|
"""
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
return ''
|
return ''
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue['name'].lower().startswith('openpgp'):
|
if not propertyValue['name'].lower().startswith('openpgp'):
|
||||||
|
@ -91,7 +91,7 @@ def getPGPfingerprint(actorJson: {}) -> str:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
def setEmailAddress(actorJson: {}, emailAddress: str) -> None:
|
def setEmailAddress(actor_json: {}, emailAddress: str) -> None:
|
||||||
"""Sets the email address for the given actor
|
"""Sets the email address for the given actor
|
||||||
"""
|
"""
|
||||||
notEmailAddress = False
|
notEmailAddress = False
|
||||||
|
@ -104,12 +104,12 @@ def setEmailAddress(actorJson: {}, emailAddress: str) -> None:
|
||||||
if emailAddress.startswith('@'):
|
if emailAddress.startswith('@'):
|
||||||
notEmailAddress = True
|
notEmailAddress = True
|
||||||
|
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
actorJson['attachment'] = []
|
actor_json['attachment'] = []
|
||||||
|
|
||||||
# remove any existing value
|
# remove any existing value
|
||||||
propertyFound = None
|
propertyFound = None
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -119,11 +119,11 @@ def setEmailAddress(actorJson: {}, emailAddress: str) -> None:
|
||||||
propertyFound = propertyValue
|
propertyFound = propertyValue
|
||||||
break
|
break
|
||||||
if propertyFound:
|
if propertyFound:
|
||||||
actorJson['attachment'].remove(propertyFound)
|
actor_json['attachment'].remove(propertyFound)
|
||||||
if notEmailAddress:
|
if notEmailAddress:
|
||||||
return
|
return
|
||||||
|
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -140,10 +140,10 @@ def setEmailAddress(actorJson: {}, emailAddress: str) -> None:
|
||||||
"type": "PropertyValue",
|
"type": "PropertyValue",
|
||||||
"value": emailAddress
|
"value": emailAddress
|
||||||
}
|
}
|
||||||
actorJson['attachment'].append(newEmailAddress)
|
actor_json['attachment'].append(newEmailAddress)
|
||||||
|
|
||||||
|
|
||||||
def setPGPpubKey(actorJson: {}, PGPpubKey: str) -> None:
|
def setPGPpubKey(actor_json: {}, PGPpubKey: str) -> None:
|
||||||
"""Sets a PGP public key for the given actor
|
"""Sets a PGP public key for the given actor
|
||||||
"""
|
"""
|
||||||
removeKey = False
|
removeKey = False
|
||||||
|
@ -155,12 +155,12 @@ def setPGPpubKey(actorJson: {}, PGPpubKey: str) -> None:
|
||||||
if '<' in PGPpubKey:
|
if '<' in PGPpubKey:
|
||||||
removeKey = True
|
removeKey = True
|
||||||
|
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
actorJson['attachment'] = []
|
actor_json['attachment'] = []
|
||||||
|
|
||||||
# remove any existing value
|
# remove any existing value
|
||||||
propertyFound = None
|
propertyFound = None
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -170,11 +170,11 @@ def setPGPpubKey(actorJson: {}, PGPpubKey: str) -> None:
|
||||||
propertyFound = propertyValue
|
propertyFound = propertyValue
|
||||||
break
|
break
|
||||||
if propertyFound:
|
if propertyFound:
|
||||||
actorJson['attachment'].remove(propertyValue)
|
actor_json['attachment'].remove(propertyValue)
|
||||||
if removeKey:
|
if removeKey:
|
||||||
return
|
return
|
||||||
|
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -191,10 +191,10 @@ def setPGPpubKey(actorJson: {}, PGPpubKey: str) -> None:
|
||||||
"type": "PropertyValue",
|
"type": "PropertyValue",
|
||||||
"value": PGPpubKey
|
"value": PGPpubKey
|
||||||
}
|
}
|
||||||
actorJson['attachment'].append(newPGPpubKey)
|
actor_json['attachment'].append(newPGPpubKey)
|
||||||
|
|
||||||
|
|
||||||
def setPGPfingerprint(actorJson: {}, fingerprint: str) -> None:
|
def setPGPfingerprint(actor_json: {}, fingerprint: str) -> None:
|
||||||
"""Sets a PGP fingerprint for the given actor
|
"""Sets a PGP fingerprint for the given actor
|
||||||
"""
|
"""
|
||||||
removeFingerprint = False
|
removeFingerprint = False
|
||||||
|
@ -204,12 +204,12 @@ def setPGPfingerprint(actorJson: {}, fingerprint: str) -> None:
|
||||||
if len(fingerprint) < 10:
|
if len(fingerprint) < 10:
|
||||||
removeFingerprint = True
|
removeFingerprint = True
|
||||||
|
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
actorJson['attachment'] = []
|
actor_json['attachment'] = []
|
||||||
|
|
||||||
# remove any existing value
|
# remove any existing value
|
||||||
propertyFound = None
|
propertyFound = None
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -219,11 +219,11 @@ def setPGPfingerprint(actorJson: {}, fingerprint: str) -> None:
|
||||||
propertyFound = propertyValue
|
propertyFound = propertyValue
|
||||||
break
|
break
|
||||||
if propertyFound:
|
if propertyFound:
|
||||||
actorJson['attachment'].remove(propertyValue)
|
actor_json['attachment'].remove(propertyValue)
|
||||||
if removeFingerprint:
|
if removeFingerprint:
|
||||||
return
|
return
|
||||||
|
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -240,7 +240,7 @@ def setPGPfingerprint(actorJson: {}, fingerprint: str) -> None:
|
||||||
"type": "PropertyValue",
|
"type": "PropertyValue",
|
||||||
"value": fingerprint
|
"value": fingerprint
|
||||||
}
|
}
|
||||||
actorJson['attachment'].append(newPGPfingerprint)
|
actor_json['attachment'].append(newPGPfingerprint)
|
||||||
|
|
||||||
|
|
||||||
def extractPGPPublicKey(content: str) -> str:
|
def extractPGPPublicKey(content: str) -> str:
|
||||||
|
@ -336,22 +336,22 @@ def _pgpEncrypt(content: str, recipientPubKey: str) -> str:
|
||||||
|
|
||||||
def _getPGPPublicKeyFromActor(signing_priv_key_pem: str,
|
def _getPGPPublicKeyFromActor(signing_priv_key_pem: str,
|
||||||
domain: str, handle: str,
|
domain: str, handle: str,
|
||||||
actorJson: {} = None) -> str:
|
actor_json: {} = None) -> str:
|
||||||
"""Searches tags on the actor to see if there is any PGP
|
"""Searches tags on the actor to see if there is any PGP
|
||||||
public key specified
|
public key specified
|
||||||
"""
|
"""
|
||||||
if not actorJson:
|
if not actor_json:
|
||||||
actorJson, asHeader = \
|
actor_json, asHeader = \
|
||||||
getActorJson(domain, handle, False, False, False, True,
|
getActorJson(domain, handle, False, False, False, True,
|
||||||
signing_priv_key_pem, None)
|
signing_priv_key_pem, None)
|
||||||
if not actorJson:
|
if not actor_json:
|
||||||
return None
|
return None
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
return None
|
return None
|
||||||
if not isinstance(actorJson['attachment'], list):
|
if not isinstance(actor_json['attachment'], list):
|
||||||
return None
|
return None
|
||||||
# search through the tags on the actor
|
# search through the tags on the actor
|
||||||
for tag in actorJson['attachment']:
|
for tag in actor_json['attachment']:
|
||||||
if not isinstance(tag, dict):
|
if not isinstance(tag, dict):
|
||||||
continue
|
continue
|
||||||
if not tag.get('value'):
|
if not tag.get('value'):
|
||||||
|
@ -489,10 +489,10 @@ def pgpPublicKeyUpload(base_dir: str, session,
|
||||||
if debug:
|
if debug:
|
||||||
print('Getting actor for ' + handle)
|
print('Getting actor for ' + handle)
|
||||||
|
|
||||||
actorJson, asHeader = \
|
actor_json, asHeader = \
|
||||||
getActorJson(domain_full, handle, False, False, debug, True,
|
getActorJson(domain_full, handle, False, False, debug, True,
|
||||||
signing_priv_key_pem, session)
|
signing_priv_key_pem, session)
|
||||||
if not actorJson:
|
if not actor_json:
|
||||||
if debug:
|
if debug:
|
||||||
print('No actor returned for ' + handle)
|
print('No actor returned for ' + handle)
|
||||||
return None
|
return None
|
||||||
|
@ -504,42 +504,42 @@ def pgpPublicKeyUpload(base_dir: str, session,
|
||||||
handle = replaceUsersWithAt(actor)
|
handle = replaceUsersWithAt(actor)
|
||||||
|
|
||||||
# check that this looks like the correct actor
|
# check that this looks like the correct actor
|
||||||
if not actorJson.get('id'):
|
if not actor_json.get('id'):
|
||||||
if debug:
|
if debug:
|
||||||
print('Actor has no id')
|
print('Actor has no id')
|
||||||
return None
|
return None
|
||||||
if not actorJson.get('url'):
|
if not actor_json.get('url'):
|
||||||
if debug:
|
if debug:
|
||||||
print('Actor has no url')
|
print('Actor has no url')
|
||||||
return None
|
return None
|
||||||
if not actorJson.get('type'):
|
if not actor_json.get('type'):
|
||||||
if debug:
|
if debug:
|
||||||
print('Actor has no type')
|
print('Actor has no type')
|
||||||
return None
|
return None
|
||||||
if actorJson['id'] != actor:
|
if actor_json['id'] != actor:
|
||||||
if debug:
|
if debug:
|
||||||
print('Actor id is not ' + actor +
|
print('Actor id is not ' + actor +
|
||||||
' instead is ' + actorJson['id'])
|
' instead is ' + actor_json['id'])
|
||||||
return None
|
return None
|
||||||
if actorJson['url'] != handle:
|
if actor_json['url'] != handle:
|
||||||
if debug:
|
if debug:
|
||||||
print('Actor url is not ' + handle)
|
print('Actor url is not ' + handle)
|
||||||
return None
|
return None
|
||||||
if actorJson['type'] != 'Person':
|
if actor_json['type'] != 'Person':
|
||||||
if debug:
|
if debug:
|
||||||
print('Actor type is not Person')
|
print('Actor type is not Person')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# set the pgp details
|
# set the pgp details
|
||||||
if PGPpubKeyId:
|
if PGPpubKeyId:
|
||||||
setPGPfingerprint(actorJson, PGPpubKeyId)
|
setPGPfingerprint(actor_json, PGPpubKeyId)
|
||||||
else:
|
else:
|
||||||
if debug:
|
if debug:
|
||||||
print('No PGP key Id. Continuing anyway.')
|
print('No PGP key Id. Continuing anyway.')
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
print('Setting PGP key within ' + actor)
|
print('Setting PGP key within ' + actor)
|
||||||
setPGPpubKey(actorJson, PGPpubKey)
|
setPGPpubKey(actor_json, PGPpubKey)
|
||||||
|
|
||||||
# create an actor update
|
# create an actor update
|
||||||
statusNumber, published = getStatusNumber()
|
statusNumber, published = getStatusNumber()
|
||||||
|
@ -550,7 +550,7 @@ def pgpPublicKeyUpload(base_dir: str, session,
|
||||||
'actor': actor,
|
'actor': actor,
|
||||||
'to': [actor],
|
'to': [actor],
|
||||||
'cc': [],
|
'cc': [],
|
||||||
'object': actorJson
|
'object': actor_json
|
||||||
}
|
}
|
||||||
if debug:
|
if debug:
|
||||||
print('actor update is ' + str(actorUpdate))
|
print('actor update is ' + str(actorUpdate))
|
||||||
|
|
56
roles.py
56
roles.py
|
@ -31,14 +31,14 @@ def _clearRoleStatus(base_dir: str, role: str) -> None:
|
||||||
filename = os.path.join(base_dir + '/accounts/', filename)
|
filename = os.path.join(base_dir + '/accounts/', filename)
|
||||||
if '"' + role + '"' not in open(filename).read():
|
if '"' + role + '"' not in open(filename).read():
|
||||||
continue
|
continue
|
||||||
actorJson = loadJson(filename)
|
actor_json = loadJson(filename)
|
||||||
if not actorJson:
|
if not actor_json:
|
||||||
continue
|
continue
|
||||||
rolesList = getActorRolesList(actorJson)
|
rolesList = getActorRolesList(actor_json)
|
||||||
if role in rolesList:
|
if role in rolesList:
|
||||||
rolesList.remove(role)
|
rolesList.remove(role)
|
||||||
setRolesFromList(actorJson, rolesList)
|
setRolesFromList(actor_json, rolesList)
|
||||||
saveJson(actorJson, filename)
|
saveJson(actor_json, filename)
|
||||||
|
|
||||||
|
|
||||||
def clearEditorStatus(base_dir: str) -> None:
|
def clearEditorStatus(base_dir: str) -> None:
|
||||||
|
@ -120,12 +120,12 @@ def _removeRole(base_dir: str, nickname: str, roleFilename: str) -> None:
|
||||||
f.write(roleNickname + '\n')
|
f.write(roleNickname + '\n')
|
||||||
|
|
||||||
|
|
||||||
def _setActorRole(actorJson: {}, roleName: str) -> bool:
|
def _setActorRole(actor_json: {}, roleName: str) -> bool:
|
||||||
"""Sets a role for an actor
|
"""Sets a role for an actor
|
||||||
"""
|
"""
|
||||||
if not actorJson.get('hasOccupation'):
|
if not actor_json.get('hasOccupation'):
|
||||||
return False
|
return False
|
||||||
if not isinstance(actorJson['hasOccupation'], list):
|
if not isinstance(actor_json['hasOccupation'], list):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# occupation category from www.onetonline.org
|
# occupation category from www.onetonline.org
|
||||||
|
@ -143,8 +143,8 @@ def _setActorRole(actorJson: {}, roleName: str) -> bool:
|
||||||
if not category:
|
if not category:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
for index in range(len(actorJson['hasOccupation'])):
|
for index in range(len(actor_json['hasOccupation'])):
|
||||||
occupationItem = actorJson['hasOccupation'][index]
|
occupationItem = actor_json['hasOccupation'][index]
|
||||||
if not isinstance(occupationItem, dict):
|
if not isinstance(occupationItem, dict):
|
||||||
continue
|
continue
|
||||||
if not occupationItem.get('@type'):
|
if not occupationItem.get('@type'):
|
||||||
|
@ -178,16 +178,16 @@ def _setActorRole(actorJson: {}, roleName: str) -> bool:
|
||||||
},
|
},
|
||||||
"startDate": published
|
"startDate": published
|
||||||
}
|
}
|
||||||
actorJson['hasOccupation'].append(newRole)
|
actor_json['hasOccupation'].append(newRole)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def setRolesFromList(actorJson: {}, rolesList: []) -> None:
|
def setRolesFromList(actor_json: {}, rolesList: []) -> None:
|
||||||
"""Sets roles from a list
|
"""Sets roles from a list
|
||||||
"""
|
"""
|
||||||
# clear Roles from the occupation list
|
# clear Roles from the occupation list
|
||||||
emptyRolesList = []
|
emptyRolesList = []
|
||||||
for occupationItem in actorJson['hasOccupation']:
|
for occupationItem in actor_json['hasOccupation']:
|
||||||
if not isinstance(occupationItem, dict):
|
if not isinstance(occupationItem, dict):
|
||||||
continue
|
continue
|
||||||
if not occupationItem.get('@type'):
|
if not occupationItem.get('@type'):
|
||||||
|
@ -195,22 +195,22 @@ def setRolesFromList(actorJson: {}, rolesList: []) -> None:
|
||||||
if occupationItem['@type'] == 'Role':
|
if occupationItem['@type'] == 'Role':
|
||||||
continue
|
continue
|
||||||
emptyRolesList.append(occupationItem)
|
emptyRolesList.append(occupationItem)
|
||||||
actorJson['hasOccupation'] = emptyRolesList
|
actor_json['hasOccupation'] = emptyRolesList
|
||||||
|
|
||||||
# create the new list
|
# create the new list
|
||||||
for roleName in rolesList:
|
for roleName in rolesList:
|
||||||
_setActorRole(actorJson, roleName)
|
_setActorRole(actor_json, roleName)
|
||||||
|
|
||||||
|
|
||||||
def getActorRolesList(actorJson: {}) -> []:
|
def getActorRolesList(actor_json: {}) -> []:
|
||||||
"""Gets a list of role names from an actor
|
"""Gets a list of role names from an actor
|
||||||
"""
|
"""
|
||||||
if not actorJson.get('hasOccupation'):
|
if not actor_json.get('hasOccupation'):
|
||||||
return []
|
return []
|
||||||
if not isinstance(actorJson['hasOccupation'], list):
|
if not isinstance(actor_json['hasOccupation'], list):
|
||||||
return []
|
return []
|
||||||
rolesList = []
|
rolesList = []
|
||||||
for occupationItem in actorJson['hasOccupation']:
|
for occupationItem in actor_json['hasOccupation']:
|
||||||
if not isinstance(occupationItem, dict):
|
if not isinstance(occupationItem, dict):
|
||||||
continue
|
continue
|
||||||
if not occupationItem.get('@type'):
|
if not occupationItem.get('@type'):
|
||||||
|
@ -242,11 +242,11 @@ def setRole(base_dir: str, nickname: str, domain: str,
|
||||||
"artist": "artists.txt"
|
"artist": "artists.txt"
|
||||||
}
|
}
|
||||||
|
|
||||||
actorJson = loadJson(actorFilename)
|
actor_json = loadJson(actorFilename)
|
||||||
if actorJson:
|
if actor_json:
|
||||||
if not actorJson.get('hasOccupation'):
|
if not actor_json.get('hasOccupation'):
|
||||||
return False
|
return False
|
||||||
rolesList = getActorRolesList(actorJson)
|
rolesList = getActorRolesList(actor_json)
|
||||||
actorChanged = False
|
actorChanged = False
|
||||||
if role:
|
if role:
|
||||||
# add the role
|
# add the role
|
||||||
|
@ -255,7 +255,7 @@ def setRole(base_dir: str, nickname: str, domain: str,
|
||||||
if role not in rolesList:
|
if role not in rolesList:
|
||||||
rolesList.append(role)
|
rolesList.append(role)
|
||||||
rolesList.sort()
|
rolesList.sort()
|
||||||
setRolesFromList(actorJson, rolesList)
|
setRolesFromList(actor_json, rolesList)
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
else:
|
else:
|
||||||
# remove the role
|
# remove the role
|
||||||
|
@ -263,15 +263,15 @@ def setRole(base_dir: str, nickname: str, domain: str,
|
||||||
_removeRole(base_dir, nickname, roleFiles[role])
|
_removeRole(base_dir, nickname, roleFiles[role])
|
||||||
if role in rolesList:
|
if role in rolesList:
|
||||||
rolesList.remove(role)
|
rolesList.remove(role)
|
||||||
setRolesFromList(actorJson, rolesList)
|
setRolesFromList(actor_json, rolesList)
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
if actorChanged:
|
if actorChanged:
|
||||||
saveJson(actorJson, actorFilename)
|
saveJson(actor_json, actorFilename)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def actorHasRole(actorJson: {}, roleName: str) -> bool:
|
def actorHasRole(actor_json: {}, roleName: str) -> bool:
|
||||||
"""Returns true if the given actor has the given role
|
"""Returns true if the given actor has the given role
|
||||||
"""
|
"""
|
||||||
rolesList = getActorRolesList(actorJson)
|
rolesList = getActorRolesList(actor_json)
|
||||||
return roleName in rolesList
|
return roleName in rolesList
|
||||||
|
|
44
skills.py
44
skills.py
|
@ -24,14 +24,14 @@ from utils import local_actor_url
|
||||||
from utils import hasActor
|
from utils import hasActor
|
||||||
|
|
||||||
|
|
||||||
def setSkillsFromDict(actorJson: {}, skillsDict: {}) -> []:
|
def setSkillsFromDict(actor_json: {}, skillsDict: {}) -> []:
|
||||||
"""Converts a dict containing skills to a list
|
"""Converts a dict containing skills to a list
|
||||||
Returns the string version of the dictionary
|
Returns the string version of the dictionary
|
||||||
"""
|
"""
|
||||||
skillsList = []
|
skillsList = []
|
||||||
for name, value in skillsDict.items():
|
for name, value in skillsDict.items():
|
||||||
skillsList.append(name + ':' + str(value))
|
skillsList.append(name + ':' + str(value))
|
||||||
setOccupationSkillsList(actorJson, skillsList)
|
setOccupationSkillsList(actor_json, skillsList)
|
||||||
return skillsList
|
return skillsList
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,10 +54,10 @@ def getSkillsFromList(skillsList: []) -> {}:
|
||||||
return skillsDict
|
return skillsDict
|
||||||
|
|
||||||
|
|
||||||
def actorSkillValue(actorJson: {}, skillName: str) -> int:
|
def actorSkillValue(actor_json: {}, skillName: str) -> int:
|
||||||
"""Returns The skill level from an actor
|
"""Returns The skill level from an actor
|
||||||
"""
|
"""
|
||||||
ocSkillsList = getOccupationSkills(actorJson)
|
ocSkillsList = getOccupationSkills(actor_json)
|
||||||
skillsDict = getSkillsFromList(ocSkillsList)
|
skillsDict = getSkillsFromList(ocSkillsList)
|
||||||
if not skillsDict:
|
if not skillsDict:
|
||||||
return 0
|
return 0
|
||||||
|
@ -67,16 +67,16 @@ def actorSkillValue(actorJson: {}, skillName: str) -> int:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def noOfActorSkills(actorJson: {}) -> int:
|
def noOfActorSkills(actor_json: {}) -> int:
|
||||||
"""Returns the number of skills that an actor has
|
"""Returns the number of skills that an actor has
|
||||||
"""
|
"""
|
||||||
if actorJson.get('hasOccupation'):
|
if actor_json.get('hasOccupation'):
|
||||||
skillsList = getOccupationSkills(actorJson)
|
skillsList = getOccupationSkills(actor_json)
|
||||||
return len(skillsList)
|
return len(skillsList)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def setActorSkillLevel(actorJson: {},
|
def setActorSkillLevel(actor_json: {},
|
||||||
skill: str, skillLevelPercent: int) -> bool:
|
skill: str, skillLevelPercent: int) -> bool:
|
||||||
"""Set a skill level for a person
|
"""Set a skill level for a person
|
||||||
Setting skill level to zero removes it
|
Setting skill level to zero removes it
|
||||||
|
@ -84,10 +84,10 @@ def setActorSkillLevel(actorJson: {},
|
||||||
if skillLevelPercent < 0 or skillLevelPercent > 100:
|
if skillLevelPercent < 0 or skillLevelPercent > 100:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not actorJson:
|
if not actor_json:
|
||||||
return True
|
return True
|
||||||
if not actorJson.get('hasOccupation'):
|
if not actor_json.get('hasOccupation'):
|
||||||
actorJson['hasOccupation'] = [{
|
actor_json['hasOccupation'] = [{
|
||||||
'@type': 'Occupation',
|
'@type': 'Occupation',
|
||||||
'name': '',
|
'name': '',
|
||||||
"occupationLocation": {
|
"occupationLocation": {
|
||||||
|
@ -96,19 +96,19 @@ def setActorSkillLevel(actorJson: {},
|
||||||
},
|
},
|
||||||
'skills': []
|
'skills': []
|
||||||
}]
|
}]
|
||||||
ocSkillsList = getOccupationSkills(actorJson)
|
ocSkillsList = getOccupationSkills(actor_json)
|
||||||
skillsDict = getSkillsFromList(ocSkillsList)
|
skillsDict = getSkillsFromList(ocSkillsList)
|
||||||
if not skillsDict.get(skill):
|
if not skillsDict.get(skill):
|
||||||
if len(skillsDict.items()) >= 32:
|
if len(skillsDict.items()) >= 32:
|
||||||
print('WARN: Maximum number of skills reached for ' +
|
print('WARN: Maximum number of skills reached for ' +
|
||||||
actorJson['id'])
|
actor_json['id'])
|
||||||
return False
|
return False
|
||||||
if skillLevelPercent > 0:
|
if skillLevelPercent > 0:
|
||||||
skillsDict[skill] = skillLevelPercent
|
skillsDict[skill] = skillLevelPercent
|
||||||
else:
|
else:
|
||||||
if skillsDict.get(skill):
|
if skillsDict.get(skill):
|
||||||
del skillsDict[skill]
|
del skillsDict[skill]
|
||||||
setSkillsFromDict(actorJson, skillsDict)
|
setSkillsFromDict(actor_json, skillsDict)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -123,8 +123,8 @@ def setSkillLevel(base_dir: str, nickname: str, domain: str,
|
||||||
if not os.path.isfile(actorFilename):
|
if not os.path.isfile(actorFilename):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
actorJson = loadJson(actorFilename)
|
actor_json = loadJson(actorFilename)
|
||||||
return setActorSkillLevel(actorJson,
|
return setActorSkillLevel(actor_json,
|
||||||
skill, skillLevelPercent)
|
skill, skillLevelPercent)
|
||||||
|
|
||||||
|
|
||||||
|
@ -135,11 +135,11 @@ def getSkills(base_dir: str, nickname: str, domain: str) -> []:
|
||||||
if not os.path.isfile(actorFilename):
|
if not os.path.isfile(actorFilename):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
actorJson = loadJson(actorFilename)
|
actor_json = loadJson(actorFilename)
|
||||||
if actorJson:
|
if actor_json:
|
||||||
if not actorJson.get('hasOccupation'):
|
if not actor_json.get('hasOccupation'):
|
||||||
return None
|
return None
|
||||||
ocSkillsList = getOccupationSkills(actorJson)
|
ocSkillsList = getOccupationSkills(actor_json)
|
||||||
return getSkillsFromList(ocSkillsList)
|
return getSkillsFromList(ocSkillsList)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -265,10 +265,10 @@ def sendSkillViaServer(base_dir: str, session, nickname: str, password: str,
|
||||||
return newSkillJson
|
return newSkillJson
|
||||||
|
|
||||||
|
|
||||||
def actorHasSkill(actorJson: {}, skillName: str) -> bool:
|
def actorHasSkill(actor_json: {}, skillName: str) -> bool:
|
||||||
"""Returns true if the given actor has the given skill
|
"""Returns true if the given actor has the given skill
|
||||||
"""
|
"""
|
||||||
ocSkillsList = getOccupationSkills(actorJson)
|
ocSkillsList = getOccupationSkills(actor_json)
|
||||||
for skillStr in ocSkillsList:
|
for skillStr in ocSkillsList:
|
||||||
if skillName + ':' in skillStr:
|
if skillName + ':' in skillStr:
|
||||||
return True
|
return True
|
||||||
|
|
20
ssb.py
20
ssb.py
|
@ -8,12 +8,12 @@ __status__ = "Production"
|
||||||
__module_group__ = "Profile Metadata"
|
__module_group__ = "Profile Metadata"
|
||||||
|
|
||||||
|
|
||||||
def getSSBAddress(actorJson: {}) -> str:
|
def getSSBAddress(actor_json: {}) -> str:
|
||||||
"""Returns ssb address for the given actor
|
"""Returns ssb address for the given actor
|
||||||
"""
|
"""
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
return ''
|
return ''
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue['name'].lower().startswith('ssb'):
|
if not propertyValue['name'].lower().startswith('ssb'):
|
||||||
|
@ -39,7 +39,7 @@ def getSSBAddress(actorJson: {}) -> str:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
def setSSBAddress(actorJson: {}, ssbAddress: str) -> None:
|
def setSSBAddress(actor_json: {}, ssbAddress: str) -> None:
|
||||||
"""Sets an ssb address for the given actor
|
"""Sets an ssb address for the given actor
|
||||||
"""
|
"""
|
||||||
notSSBAddress = False
|
notSSBAddress = False
|
||||||
|
@ -56,12 +56,12 @@ def setSSBAddress(actorJson: {}, ssbAddress: str) -> None:
|
||||||
if '<' in ssbAddress:
|
if '<' in ssbAddress:
|
||||||
notSSBAddress = True
|
notSSBAddress = True
|
||||||
|
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
actorJson['attachment'] = []
|
actor_json['attachment'] = []
|
||||||
|
|
||||||
# remove any existing value
|
# remove any existing value
|
||||||
propertyFound = None
|
propertyFound = None
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -71,11 +71,11 @@ def setSSBAddress(actorJson: {}, ssbAddress: str) -> None:
|
||||||
propertyFound = propertyValue
|
propertyFound = propertyValue
|
||||||
break
|
break
|
||||||
if propertyFound:
|
if propertyFound:
|
||||||
actorJson['attachment'].remove(propertyFound)
|
actor_json['attachment'].remove(propertyFound)
|
||||||
if notSSBAddress:
|
if notSSBAddress:
|
||||||
return
|
return
|
||||||
|
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -92,4 +92,4 @@ def setSSBAddress(actorJson: {}, ssbAddress: str) -> None:
|
||||||
"type": "PropertyValue",
|
"type": "PropertyValue",
|
||||||
"value": ssbAddress
|
"value": ssbAddress
|
||||||
}
|
}
|
||||||
actorJson['attachment'].append(newSSBAddress)
|
actor_json['attachment'].append(newSSBAddress)
|
||||||
|
|
56
tests.py
56
tests.py
|
@ -5154,13 +5154,13 @@ def testUpdateActor(base_dir: str):
|
||||||
|
|
||||||
# load alice actor
|
# load alice actor
|
||||||
print('Loading actor: ' + actorFilename)
|
print('Loading actor: ' + actorFilename)
|
||||||
actorJson = loadJson(actorFilename)
|
actor_json = loadJson(actorFilename)
|
||||||
assert actorJson
|
assert actor_json
|
||||||
if len(actorJson['attachment']) == 0:
|
if len(actor_json['attachment']) == 0:
|
||||||
print("actorJson['attachment'] has no contents")
|
print("actor_json['attachment'] has no contents")
|
||||||
assert len(actorJson['attachment']) > 0
|
assert len(actor_json['attachment']) > 0
|
||||||
propertyFound = False
|
propertyFound = False
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if propertyValue['name'] == 'PGP':
|
if propertyValue['name'] == 'PGP':
|
||||||
print('PGP property set within attachment')
|
print('PGP property set within attachment')
|
||||||
assert pubKey in propertyValue['value']
|
assert pubKey in propertyValue['value']
|
||||||
|
@ -5455,7 +5455,7 @@ def _testSpoofGeolocation() -> None:
|
||||||
|
|
||||||
def _testSkills() -> None:
|
def _testSkills() -> None:
|
||||||
print('testSkills')
|
print('testSkills')
|
||||||
actorJson = {
|
actor_json = {
|
||||||
'hasOccupation': [
|
'hasOccupation': [
|
||||||
{
|
{
|
||||||
'@type': 'Occupation',
|
'@type': 'Occupation',
|
||||||
|
@ -5472,16 +5472,16 @@ def _testSkills() -> None:
|
||||||
'bakery': 40,
|
'bakery': 40,
|
||||||
'gardening': 70
|
'gardening': 70
|
||||||
}
|
}
|
||||||
setSkillsFromDict(actorJson, skillsDict)
|
setSkillsFromDict(actor_json, skillsDict)
|
||||||
assert actorHasSkill(actorJson, 'bakery')
|
assert actorHasSkill(actor_json, 'bakery')
|
||||||
assert actorHasSkill(actorJson, 'gardening')
|
assert actorHasSkill(actor_json, 'gardening')
|
||||||
assert actorSkillValue(actorJson, 'bakery') == 40
|
assert actorSkillValue(actor_json, 'bakery') == 40
|
||||||
assert actorSkillValue(actorJson, 'gardening') == 70
|
assert actorSkillValue(actor_json, 'gardening') == 70
|
||||||
|
|
||||||
|
|
||||||
def _testRoles() -> None:
|
def _testRoles() -> None:
|
||||||
print('testRoles')
|
print('testRoles')
|
||||||
actorJson = {
|
actor_json = {
|
||||||
'hasOccupation': [
|
'hasOccupation': [
|
||||||
{
|
{
|
||||||
'@type': 'Occupation',
|
'@type': 'Occupation',
|
||||||
|
@ -5495,12 +5495,12 @@ def _testRoles() -> None:
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
testRolesList = ["admin", "moderator"]
|
testRolesList = ["admin", "moderator"]
|
||||||
setRolesFromList(actorJson, testRolesList)
|
setRolesFromList(actor_json, testRolesList)
|
||||||
assert actorHasRole(actorJson, "admin")
|
assert actorHasRole(actor_json, "admin")
|
||||||
assert actorHasRole(actorJson, "moderator")
|
assert actorHasRole(actor_json, "moderator")
|
||||||
assert not actorHasRole(actorJson, "editor")
|
assert not actorHasRole(actor_json, "editor")
|
||||||
assert not actorHasRole(actorJson, "counselor")
|
assert not actorHasRole(actor_json, "counselor")
|
||||||
assert not actorHasRole(actorJson, "artist")
|
assert not actorHasRole(actor_json, "artist")
|
||||||
|
|
||||||
|
|
||||||
def _testUserAgentDomain() -> None:
|
def _testUserAgentDomain() -> None:
|
||||||
|
@ -5586,20 +5586,20 @@ def _testLimitRepetedWords() -> None:
|
||||||
|
|
||||||
def _testSetActorLanguages():
|
def _testSetActorLanguages():
|
||||||
print('testSetActorLanguages')
|
print('testSetActorLanguages')
|
||||||
actorJson = {
|
actor_json = {
|
||||||
"attachment": []
|
"attachment": []
|
||||||
}
|
}
|
||||||
setActorLanguages(None, actorJson, 'es, fr, en')
|
setActorLanguages(None, actor_json, 'es, fr, en')
|
||||||
assert len(actorJson['attachment']) == 1
|
assert len(actor_json['attachment']) == 1
|
||||||
assert actorJson['attachment'][0]['name'] == 'Languages'
|
assert actor_json['attachment'][0]['name'] == 'Languages'
|
||||||
assert actorJson['attachment'][0]['type'] == 'PropertyValue'
|
assert actor_json['attachment'][0]['type'] == 'PropertyValue'
|
||||||
assert isinstance(actorJson['attachment'][0]['value'], str)
|
assert isinstance(actor_json['attachment'][0]['value'], str)
|
||||||
assert ',' in actorJson['attachment'][0]['value']
|
assert ',' in actor_json['attachment'][0]['value']
|
||||||
langList = get_actor_languages_list(actorJson)
|
langList = get_actor_languages_list(actor_json)
|
||||||
assert 'en' in langList
|
assert 'en' in langList
|
||||||
assert 'fr' in langList
|
assert 'fr' in langList
|
||||||
assert 'es' in langList
|
assert 'es' in langList
|
||||||
languagesStr = getActorLanguages(actorJson)
|
languagesStr = getActorLanguages(actor_json)
|
||||||
assert languagesStr == 'en / es / fr'
|
assert languagesStr == 'en / es / fr'
|
||||||
|
|
||||||
|
|
||||||
|
|
20
tox.py
20
tox.py
|
@ -8,12 +8,12 @@ __status__ = "Production"
|
||||||
__module_group__ = "Profile Metadata"
|
__module_group__ = "Profile Metadata"
|
||||||
|
|
||||||
|
|
||||||
def getToxAddress(actorJson: {}) -> str:
|
def getToxAddress(actor_json: {}) -> str:
|
||||||
"""Returns tox address for the given actor
|
"""Returns tox address for the given actor
|
||||||
"""
|
"""
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
return ''
|
return ''
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue['name'].lower().startswith('tox'):
|
if not propertyValue['name'].lower().startswith('tox'):
|
||||||
|
@ -41,7 +41,7 @@ def getToxAddress(actorJson: {}) -> str:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
def setToxAddress(actorJson: {}, toxAddress: str) -> None:
|
def setToxAddress(actor_json: {}, toxAddress: str) -> None:
|
||||||
"""Sets an tox address for the given actor
|
"""Sets an tox address for the given actor
|
||||||
"""
|
"""
|
||||||
notToxAddress = False
|
notToxAddress = False
|
||||||
|
@ -61,12 +61,12 @@ def setToxAddress(actorJson: {}, toxAddress: str) -> None:
|
||||||
if '<' in toxAddress:
|
if '<' in toxAddress:
|
||||||
notToxAddress = True
|
notToxAddress = True
|
||||||
|
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
actorJson['attachment'] = []
|
actor_json['attachment'] = []
|
||||||
|
|
||||||
# remove any existing value
|
# remove any existing value
|
||||||
propertyFound = None
|
propertyFound = None
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -76,11 +76,11 @@ def setToxAddress(actorJson: {}, toxAddress: str) -> None:
|
||||||
propertyFound = propertyValue
|
propertyFound = propertyValue
|
||||||
break
|
break
|
||||||
if propertyFound:
|
if propertyFound:
|
||||||
actorJson['attachment'].remove(propertyFound)
|
actor_json['attachment'].remove(propertyFound)
|
||||||
if notToxAddress:
|
if notToxAddress:
|
||||||
return
|
return
|
||||||
|
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -97,4 +97,4 @@ def setToxAddress(actorJson: {}, toxAddress: str) -> None:
|
||||||
"type": "PropertyValue",
|
"type": "PropertyValue",
|
||||||
"value": toxAddress
|
"value": toxAddress
|
||||||
}
|
}
|
||||||
actorJson['attachment'].append(newToxAddress)
|
actor_json['attachment'].append(newToxAddress)
|
||||||
|
|
78
utils.py
78
utils.py
|
@ -34,12 +34,12 @@ def local_actor_url(http_prefix: str, nickname: str, domain_full: str) -> str:
|
||||||
return http_prefix + '://' + domain_full + '/users/' + nickname
|
return http_prefix + '://' + domain_full + '/users/' + nickname
|
||||||
|
|
||||||
|
|
||||||
def get_actor_languages_list(actorJson: {}) -> []:
|
def get_actor_languages_list(actor_json: {}) -> []:
|
||||||
"""Returns a list containing languages used by the given actor
|
"""Returns a list containing languages used by the given actor
|
||||||
"""
|
"""
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
return []
|
return []
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue['name'].lower().startswith('languages'):
|
if not propertyValue['name'].lower().startswith('languages'):
|
||||||
|
@ -180,12 +180,12 @@ def decodedHost(host: str) -> str:
|
||||||
return host
|
return host
|
||||||
|
|
||||||
|
|
||||||
def getLockedAccount(actorJson: {}) -> bool:
|
def getLockedAccount(actor_json: {}) -> bool:
|
||||||
"""Returns whether the given account requires follower approval
|
"""Returns whether the given account requires follower approval
|
||||||
"""
|
"""
|
||||||
if not actorJson.get('manuallyApprovesFollowers'):
|
if not actor_json.get('manuallyApprovesFollowers'):
|
||||||
return False
|
return False
|
||||||
if actorJson['manuallyApprovesFollowers'] is True:
|
if actor_json['manuallyApprovesFollowers'] is True:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -917,10 +917,10 @@ def getDisplayName(base_dir: str, actor: str, person_cache: {}) -> str:
|
||||||
cachedActorFilename = \
|
cachedActorFilename = \
|
||||||
base_dir + '/cache/actors/' + (actor.replace('/', '#')) + '.json'
|
base_dir + '/cache/actors/' + (actor.replace('/', '#')) + '.json'
|
||||||
if os.path.isfile(cachedActorFilename):
|
if os.path.isfile(cachedActorFilename):
|
||||||
actorJson = loadJson(cachedActorFilename, 1)
|
actor_json = loadJson(cachedActorFilename, 1)
|
||||||
if actorJson:
|
if actor_json:
|
||||||
if actorJson.get('name'):
|
if actor_json.get('name'):
|
||||||
nameFound = actorJson['name']
|
nameFound = actor_json['name']
|
||||||
if nameFound:
|
if nameFound:
|
||||||
if dangerousMarkup(nameFound, False):
|
if dangerousMarkup(nameFound, False):
|
||||||
nameFound = "*ADVERSARY*"
|
nameFound = "*ADVERSARY*"
|
||||||
|
@ -966,20 +966,20 @@ def getGenderFromBio(base_dir: str, actor: str, person_cache: {},
|
||||||
pronounStr = translate['pronoun'].lower()
|
pronounStr = translate['pronoun'].lower()
|
||||||
else:
|
else:
|
||||||
pronounStr = 'pronoun'
|
pronounStr = 'pronoun'
|
||||||
actorJson = None
|
actor_json = None
|
||||||
if person_cache[actor].get('actor'):
|
if person_cache[actor].get('actor'):
|
||||||
actorJson = person_cache[actor]['actor']
|
actor_json = person_cache[actor]['actor']
|
||||||
else:
|
else:
|
||||||
# Try to obtain from the cached actors
|
# Try to obtain from the cached actors
|
||||||
cachedActorFilename = \
|
cachedActorFilename = \
|
||||||
base_dir + '/cache/actors/' + (actor.replace('/', '#')) + '.json'
|
base_dir + '/cache/actors/' + (actor.replace('/', '#')) + '.json'
|
||||||
if os.path.isfile(cachedActorFilename):
|
if os.path.isfile(cachedActorFilename):
|
||||||
actorJson = loadJson(cachedActorFilename, 1)
|
actor_json = loadJson(cachedActorFilename, 1)
|
||||||
if not actorJson:
|
if not actor_json:
|
||||||
return defaultGender
|
return defaultGender
|
||||||
# is gender defined as a profile tag?
|
# is gender defined as a profile tag?
|
||||||
if actorJson.get('attachment'):
|
if actor_json.get('attachment'):
|
||||||
tagsList = actorJson['attachment']
|
tagsList = actor_json['attachment']
|
||||||
if isinstance(tagsList, list):
|
if isinstance(tagsList, list):
|
||||||
# look for a gender field name
|
# look for a gender field name
|
||||||
for tag in tagsList:
|
for tag in tagsList:
|
||||||
|
@ -1006,8 +1006,8 @@ def getGenderFromBio(base_dir: str, actor: str, person_cache: {},
|
||||||
if gender:
|
if gender:
|
||||||
return gender
|
return gender
|
||||||
# if not then use the bio
|
# if not then use the bio
|
||||||
if not bioFound and actorJson.get('summary'):
|
if not bioFound and actor_json.get('summary'):
|
||||||
bioFound = actorJson['summary']
|
bioFound = actor_json['summary']
|
||||||
if not bioFound:
|
if not bioFound:
|
||||||
return defaultGender
|
return defaultGender
|
||||||
gender = _genderFromString(translate, bioFound)
|
gender = _genderFromString(translate, bioFound)
|
||||||
|
@ -2714,14 +2714,14 @@ def dmAllowedFromDomain(base_dir: str,
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def getOccupationSkills(actorJson: {}) -> []:
|
def getOccupationSkills(actor_json: {}) -> []:
|
||||||
"""Returns the list of skills for an actor
|
"""Returns the list of skills for an actor
|
||||||
"""
|
"""
|
||||||
if 'hasOccupation' not in actorJson:
|
if 'hasOccupation' not in actor_json:
|
||||||
return []
|
return []
|
||||||
if not isinstance(actorJson['hasOccupation'], list):
|
if not isinstance(actor_json['hasOccupation'], list):
|
||||||
return []
|
return []
|
||||||
for occupationItem in actorJson['hasOccupation']:
|
for occupationItem in actor_json['hasOccupation']:
|
||||||
if not isinstance(occupationItem, dict):
|
if not isinstance(occupationItem, dict):
|
||||||
continue
|
continue
|
||||||
if not occupationItem.get('@type'):
|
if not occupationItem.get('@type'):
|
||||||
|
@ -2738,14 +2738,14 @@ def getOccupationSkills(actorJson: {}) -> []:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
def getOccupationName(actorJson: {}) -> str:
|
def getOccupationName(actor_json: {}) -> str:
|
||||||
"""Returns the occupation name an actor
|
"""Returns the occupation name an actor
|
||||||
"""
|
"""
|
||||||
if not actorJson.get('hasOccupation'):
|
if not actor_json.get('hasOccupation'):
|
||||||
return ""
|
return ""
|
||||||
if not isinstance(actorJson['hasOccupation'], list):
|
if not isinstance(actor_json['hasOccupation'], list):
|
||||||
return ""
|
return ""
|
||||||
for occupationItem in actorJson['hasOccupation']:
|
for occupationItem in actor_json['hasOccupation']:
|
||||||
if not isinstance(occupationItem, dict):
|
if not isinstance(occupationItem, dict):
|
||||||
continue
|
continue
|
||||||
if not occupationItem.get('@type'):
|
if not occupationItem.get('@type'):
|
||||||
|
@ -2760,15 +2760,15 @@ def getOccupationName(actorJson: {}) -> str:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
def setOccupationName(actorJson: {}, name: str) -> bool:
|
def setOccupationName(actor_json: {}, name: str) -> bool:
|
||||||
"""Sets the occupation name of an actor
|
"""Sets the occupation name of an actor
|
||||||
"""
|
"""
|
||||||
if not actorJson.get('hasOccupation'):
|
if not actor_json.get('hasOccupation'):
|
||||||
return False
|
return False
|
||||||
if not isinstance(actorJson['hasOccupation'], list):
|
if not isinstance(actor_json['hasOccupation'], list):
|
||||||
return False
|
return False
|
||||||
for index in range(len(actorJson['hasOccupation'])):
|
for index in range(len(actor_json['hasOccupation'])):
|
||||||
occupationItem = actorJson['hasOccupation'][index]
|
occupationItem = actor_json['hasOccupation'][index]
|
||||||
if not isinstance(occupationItem, dict):
|
if not isinstance(occupationItem, dict):
|
||||||
continue
|
continue
|
||||||
if not occupationItem.get('@type'):
|
if not occupationItem.get('@type'):
|
||||||
|
@ -2780,15 +2780,15 @@ def setOccupationName(actorJson: {}, name: str) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def setOccupationSkillsList(actorJson: {}, skillsList: []) -> bool:
|
def setOccupationSkillsList(actor_json: {}, skillsList: []) -> bool:
|
||||||
"""Sets the occupation skills for an actor
|
"""Sets the occupation skills for an actor
|
||||||
"""
|
"""
|
||||||
if 'hasOccupation' not in actorJson:
|
if 'hasOccupation' not in actor_json:
|
||||||
return False
|
return False
|
||||||
if not isinstance(actorJson['hasOccupation'], list):
|
if not isinstance(actor_json['hasOccupation'], list):
|
||||||
return False
|
return False
|
||||||
for index in range(len(actorJson['hasOccupation'])):
|
for index in range(len(actor_json['hasOccupation'])):
|
||||||
occupationItem = actorJson['hasOccupation'][index]
|
occupationItem = actor_json['hasOccupation'][index]
|
||||||
if not isinstance(occupationItem, dict):
|
if not isinstance(occupationItem, dict):
|
||||||
continue
|
continue
|
||||||
if not occupationItem.get('@type'):
|
if not occupationItem.get('@type'):
|
||||||
|
@ -2868,13 +2868,13 @@ def getAltPath(actor: str, domain_full: str, callingDomain: str) -> str:
|
||||||
return postActor
|
return postActor
|
||||||
|
|
||||||
|
|
||||||
def getActorPropertyUrl(actorJson: {}, propertyName: str) -> str:
|
def getActorPropertyUrl(actor_json: {}, propertyName: str) -> str:
|
||||||
"""Returns a url property from an actor
|
"""Returns a url property from an actor
|
||||||
"""
|
"""
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
return ''
|
return ''
|
||||||
propertyName = propertyName.lower()
|
propertyName = propertyName.lower()
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue['name'].lower().startswith(propertyName):
|
if not propertyValue['name'].lower().startswith(propertyName):
|
||||||
|
|
|
@ -322,15 +322,15 @@ def htmlModerationInfo(cssCache: {}, translate: {},
|
||||||
for acct in accounts:
|
for acct in accounts:
|
||||||
acctNickname = acct.split('@')[0]
|
acctNickname = acct.split('@')[0]
|
||||||
accountDir = os.path.join(base_dir + '/accounts', acct)
|
accountDir = os.path.join(base_dir + '/accounts', acct)
|
||||||
actorJson = loadJson(accountDir + '.json')
|
actor_json = loadJson(accountDir + '.json')
|
||||||
if not actorJson:
|
if not actor_json:
|
||||||
continue
|
continue
|
||||||
actor = actorJson['id']
|
actor = actor_json['id']
|
||||||
avatarUrl = ''
|
avatarUrl = ''
|
||||||
ext = ''
|
ext = ''
|
||||||
if actorJson.get('icon'):
|
if actor_json.get('icon'):
|
||||||
if actorJson['icon'].get('url'):
|
if actor_json['icon'].get('url'):
|
||||||
avatarUrl = actorJson['icon']['url']
|
avatarUrl = actor_json['icon']['url']
|
||||||
if '.' in avatarUrl:
|
if '.' in avatarUrl:
|
||||||
ext = '.' + avatarUrl.split('.')[-1]
|
ext = '.' + avatarUrl.split('.')[-1]
|
||||||
acctUrl = \
|
acctUrl = \
|
||||||
|
|
|
@ -1850,11 +1850,11 @@ def individualPostAsHtml(signing_priv_key_pem: str,
|
||||||
|
|
||||||
domain_full = getFullDomain(domain, port)
|
domain_full = getFullDomain(domain, port)
|
||||||
personUrl = local_actor_url(http_prefix, nickname, domain_full)
|
personUrl = local_actor_url(http_prefix, nickname, domain_full)
|
||||||
actorJson = \
|
actor_json = \
|
||||||
getPersonFromCache(base_dir, personUrl, person_cache, False)
|
getPersonFromCache(base_dir, personUrl, person_cache, False)
|
||||||
languagesUnderstood = []
|
languagesUnderstood = []
|
||||||
if actorJson:
|
if actor_json:
|
||||||
languagesUnderstood = get_actor_languages_list(actorJson)
|
languagesUnderstood = get_actor_languages_list(actor_json)
|
||||||
contentStr = getContentFromPost(post_json_object, system_language,
|
contentStr = getContentFromPost(post_json_object, system_language,
|
||||||
languagesUnderstood)
|
languagesUnderstood)
|
||||||
if not contentStr:
|
if not contentStr:
|
||||||
|
|
|
@ -1985,7 +1985,7 @@ def _getSupportedLanguagesSorted(base_dir: str) -> str:
|
||||||
|
|
||||||
def _htmlEditProfileMain(base_dir: str, displayNickname: str, bioStr: str,
|
def _htmlEditProfileMain(base_dir: str, displayNickname: str, bioStr: str,
|
||||||
movedTo: str, donateUrl: str, websiteUrl: str,
|
movedTo: str, donateUrl: str, websiteUrl: str,
|
||||||
blogAddress: str, actorJson: {},
|
blogAddress: str, actor_json: {},
|
||||||
translate: {}) -> str:
|
translate: {}) -> str:
|
||||||
"""main info on edit profile screen
|
"""main info on edit profile screen
|
||||||
"""
|
"""
|
||||||
|
@ -2007,16 +2007,16 @@ def _htmlEditProfileMain(base_dir: str, displayNickname: str, bioStr: str,
|
||||||
' accept="' + imageFormats + '">\n'
|
' accept="' + imageFormats + '">\n'
|
||||||
|
|
||||||
occupationName = ''
|
occupationName = ''
|
||||||
if actorJson.get('hasOccupation'):
|
if actor_json.get('hasOccupation'):
|
||||||
occupationName = getOccupationName(actorJson)
|
occupationName = getOccupationName(actor_json)
|
||||||
|
|
||||||
editProfileForm += \
|
editProfileForm += \
|
||||||
editTextField(translate['Occupation'], 'occupationName',
|
editTextField(translate['Occupation'], 'occupationName',
|
||||||
occupationName)
|
occupationName)
|
||||||
|
|
||||||
alsoKnownAsStr = ''
|
alsoKnownAsStr = ''
|
||||||
if actorJson.get('alsoKnownAs'):
|
if actor_json.get('alsoKnownAs'):
|
||||||
alsoKnownAs = actorJson['alsoKnownAs']
|
alsoKnownAs = actor_json['alsoKnownAs']
|
||||||
ctr = 0
|
ctr = 0
|
||||||
for altActor in alsoKnownAs:
|
for altActor in alsoKnownAs:
|
||||||
if ctr > 0:
|
if ctr > 0:
|
||||||
|
@ -2044,7 +2044,7 @@ def _htmlEditProfileMain(base_dir: str, displayNickname: str, bioStr: str,
|
||||||
editTextField('Blog', 'blogAddress', blogAddress, 'https://...')
|
editTextField('Blog', 'blogAddress', blogAddress, 'https://...')
|
||||||
|
|
||||||
languagesListStr = _getSupportedLanguagesSorted(base_dir)
|
languagesListStr = _getSupportedLanguagesSorted(base_dir)
|
||||||
showLanguages = getActorLanguages(actorJson)
|
showLanguages = getActorLanguages(actor_json)
|
||||||
editProfileForm += \
|
editProfileForm += \
|
||||||
editTextField(translate['Languages'], 'showLanguages',
|
editTextField(translate['Languages'], 'showLanguages',
|
||||||
showLanguages, languagesListStr)
|
showLanguages, languagesListStr)
|
||||||
|
@ -2126,42 +2126,42 @@ def htmlEditProfile(cssCache: {}, translate: {}, base_dir: str, path: str,
|
||||||
ssbAddress = blogAddress = toxAddress = jamiAddress = ''
|
ssbAddress = blogAddress = toxAddress = jamiAddress = ''
|
||||||
cwtchAddress = briarAddress = manuallyApprovesFollowers = ''
|
cwtchAddress = briarAddress = manuallyApprovesFollowers = ''
|
||||||
|
|
||||||
actorJson = loadJson(actorFilename)
|
actor_json = loadJson(actorFilename)
|
||||||
if actorJson:
|
if actor_json:
|
||||||
if actorJson.get('movedTo'):
|
if actor_json.get('movedTo'):
|
||||||
movedTo = actorJson['movedTo']
|
movedTo = actor_json['movedTo']
|
||||||
donateUrl = getDonationUrl(actorJson)
|
donateUrl = getDonationUrl(actor_json)
|
||||||
websiteUrl = getWebsite(actorJson, translate)
|
websiteUrl = getWebsite(actor_json, translate)
|
||||||
xmppAddress = getXmppAddress(actorJson)
|
xmppAddress = getXmppAddress(actor_json)
|
||||||
matrixAddress = getMatrixAddress(actorJson)
|
matrixAddress = getMatrixAddress(actor_json)
|
||||||
ssbAddress = getSSBAddress(actorJson)
|
ssbAddress = getSSBAddress(actor_json)
|
||||||
blogAddress = getBlogAddress(actorJson)
|
blogAddress = getBlogAddress(actor_json)
|
||||||
toxAddress = getToxAddress(actorJson)
|
toxAddress = getToxAddress(actor_json)
|
||||||
briarAddress = getBriarAddress(actorJson)
|
briarAddress = getBriarAddress(actor_json)
|
||||||
jamiAddress = getJamiAddress(actorJson)
|
jamiAddress = getJamiAddress(actor_json)
|
||||||
cwtchAddress = getCwtchAddress(actorJson)
|
cwtchAddress = getCwtchAddress(actor_json)
|
||||||
emailAddress = getEmailAddress(actorJson)
|
emailAddress = getEmailAddress(actor_json)
|
||||||
EnigmaPubKey = getEnigmaPubKey(actorJson)
|
EnigmaPubKey = getEnigmaPubKey(actor_json)
|
||||||
PGPpubKey = getPGPpubKey(actorJson)
|
PGPpubKey = getPGPpubKey(actor_json)
|
||||||
PGPfingerprint = getPGPfingerprint(actorJson)
|
PGPfingerprint = getPGPfingerprint(actor_json)
|
||||||
if actorJson.get('name'):
|
if actor_json.get('name'):
|
||||||
if not isFiltered(base_dir, nickname, domain, actorJson['name']):
|
if not isFiltered(base_dir, nickname, domain, actor_json['name']):
|
||||||
displayNickname = actorJson['name']
|
displayNickname = actor_json['name']
|
||||||
if actorJson.get('summary'):
|
if actor_json.get('summary'):
|
||||||
bioStr = \
|
bioStr = \
|
||||||
actorJson['summary'].replace('<p>', '').replace('</p>', '')
|
actor_json['summary'].replace('<p>', '').replace('</p>', '')
|
||||||
if isFiltered(base_dir, nickname, domain, bioStr):
|
if isFiltered(base_dir, nickname, domain, bioStr):
|
||||||
bioStr = ''
|
bioStr = ''
|
||||||
if actorJson.get('manuallyApprovesFollowers'):
|
if actor_json.get('manuallyApprovesFollowers'):
|
||||||
if actorJson['manuallyApprovesFollowers']:
|
if actor_json['manuallyApprovesFollowers']:
|
||||||
manuallyApprovesFollowers = 'checked'
|
manuallyApprovesFollowers = 'checked'
|
||||||
else:
|
else:
|
||||||
manuallyApprovesFollowers = ''
|
manuallyApprovesFollowers = ''
|
||||||
if actorJson.get('type'):
|
if actor_json.get('type'):
|
||||||
if actorJson['type'] == 'Service':
|
if actor_json['type'] == 'Service':
|
||||||
isBot = 'checked'
|
isBot = 'checked'
|
||||||
isGroup = ''
|
isGroup = ''
|
||||||
elif actorJson['type'] == 'Group':
|
elif actor_json['type'] == 'Group':
|
||||||
isGroup = 'checked'
|
isGroup = 'checked'
|
||||||
isBot = ''
|
isBot = ''
|
||||||
accountDir = acctDir(base_dir, nickname, domain)
|
accountDir = acctDir(base_dir, nickname, domain)
|
||||||
|
@ -2266,7 +2266,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, base_dir: str, path: str,
|
||||||
editProfileForm += \
|
editProfileForm += \
|
||||||
_htmlEditProfileMain(base_dir, displayNickname, bioStr,
|
_htmlEditProfileMain(base_dir, displayNickname, bioStr,
|
||||||
movedTo, donateUrl, websiteUrl,
|
movedTo, donateUrl, websiteUrl,
|
||||||
blogAddress, actorJson, translate)
|
blogAddress, actor_json, translate)
|
||||||
|
|
||||||
# Option checkboxes
|
# Option checkboxes
|
||||||
editProfileForm += \
|
editProfileForm += \
|
||||||
|
|
|
@ -475,14 +475,14 @@ def htmlSkillsSearch(actor: str,
|
||||||
if not isAccountDir(f):
|
if not isAccountDir(f):
|
||||||
continue
|
continue
|
||||||
actorFilename = os.path.join(subdir, f)
|
actorFilename = os.path.join(subdir, f)
|
||||||
actorJson = loadJson(actorFilename)
|
actor_json = loadJson(actorFilename)
|
||||||
if actorJson:
|
if actor_json:
|
||||||
if actorJson.get('id') and \
|
if actor_json.get('id') and \
|
||||||
noOfActorSkills(actorJson) > 0 and \
|
noOfActorSkills(actor_json) > 0 and \
|
||||||
actorJson.get('name') and \
|
actor_json.get('name') and \
|
||||||
actorJson.get('icon'):
|
actor_json.get('icon'):
|
||||||
actor = actorJson['id']
|
actor = actor_json['id']
|
||||||
actorSkillsList = actorJson['hasOccupation']['skills']
|
actorSkillsList = actor_json['hasOccupation']['skills']
|
||||||
skills = getSkillsFromList(actorSkillsList)
|
skills = getSkillsFromList(actorSkillsList)
|
||||||
for skillName, skillLevel in skills.items():
|
for skillName, skillLevel in skills.items():
|
||||||
skillName = skillName.lower()
|
skillName = skillName.lower()
|
||||||
|
@ -496,8 +496,8 @@ def htmlSkillsSearch(actor: str,
|
||||||
skillLevelStr = '0' + skillLevelStr
|
skillLevelStr = '0' + skillLevelStr
|
||||||
indexStr = \
|
indexStr = \
|
||||||
skillLevelStr + ';' + actor + ';' + \
|
skillLevelStr + ';' + actor + ';' + \
|
||||||
actorJson['name'] + \
|
actor_json['name'] + \
|
||||||
';' + actorJson['icon']['url']
|
';' + actor_json['icon']['url']
|
||||||
if indexStr not in results:
|
if indexStr not in results:
|
||||||
results.append(indexStr)
|
results.append(indexStr)
|
||||||
break
|
break
|
||||||
|
@ -513,14 +513,14 @@ def htmlSkillsSearch(actor: str,
|
||||||
cachedActorJson = loadJson(actorFilename)
|
cachedActorJson = loadJson(actorFilename)
|
||||||
if cachedActorJson:
|
if cachedActorJson:
|
||||||
if cachedActorJson.get('actor'):
|
if cachedActorJson.get('actor'):
|
||||||
actorJson = cachedActorJson['actor']
|
actor_json = cachedActorJson['actor']
|
||||||
if actorJson.get('id') and \
|
if actor_json.get('id') and \
|
||||||
noOfActorSkills(actorJson) > 0 and \
|
noOfActorSkills(actor_json) > 0 and \
|
||||||
actorJson.get('name') and \
|
actor_json.get('name') and \
|
||||||
actorJson.get('icon'):
|
actor_json.get('icon'):
|
||||||
actor = actorJson['id']
|
actor = actor_json['id']
|
||||||
actorSkillsList = \
|
actorSkillsList = \
|
||||||
actorJson['hasOccupation']['skills']
|
actor_json['hasOccupation']['skills']
|
||||||
skills = getSkillsFromList(actorSkillsList)
|
skills = getSkillsFromList(actorSkillsList)
|
||||||
for skillName, skillLevel in skills.items():
|
for skillName, skillLevel in skills.items():
|
||||||
skillName = skillName.lower()
|
skillName = skillName.lower()
|
||||||
|
@ -534,8 +534,8 @@ def htmlSkillsSearch(actor: str,
|
||||||
skillLevelStr = '0' + skillLevelStr
|
skillLevelStr = '0' + skillLevelStr
|
||||||
indexStr = \
|
indexStr = \
|
||||||
skillLevelStr + ';' + actor + ';' + \
|
skillLevelStr + ';' + actor + ';' + \
|
||||||
actorJson['name'] + \
|
actor_json['name'] + \
|
||||||
';' + actorJson['icon']['url']
|
';' + actor_json['icon']['url']
|
||||||
if indexStr not in results:
|
if indexStr not in results:
|
||||||
results.append(indexStr)
|
results.append(indexStr)
|
||||||
break
|
break
|
||||||
|
|
|
@ -170,17 +170,17 @@ def getContentWarningButton(postID: str, translate: {},
|
||||||
'</div></details>\n'
|
'</div></details>\n'
|
||||||
|
|
||||||
|
|
||||||
def _setActorPropertyUrl(actorJson: {}, propertyName: str, url: str) -> None:
|
def _setActorPropertyUrl(actor_json: {}, propertyName: str, url: str) -> None:
|
||||||
"""Sets a url for the given actor property
|
"""Sets a url for the given actor property
|
||||||
"""
|
"""
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
actorJson['attachment'] = []
|
actor_json['attachment'] = []
|
||||||
|
|
||||||
propertyNameLower = propertyName.lower()
|
propertyNameLower = propertyName.lower()
|
||||||
|
|
||||||
# remove any existing value
|
# remove any existing value
|
||||||
propertyFound = None
|
propertyFound = None
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -190,7 +190,7 @@ def _setActorPropertyUrl(actorJson: {}, propertyName: str, url: str) -> None:
|
||||||
propertyFound = propertyValue
|
propertyFound = propertyValue
|
||||||
break
|
break
|
||||||
if propertyFound:
|
if propertyFound:
|
||||||
actorJson['attachment'].remove(propertyFound)
|
actor_json['attachment'].remove(propertyFound)
|
||||||
|
|
||||||
prefixes = getProtocolPrefixes()
|
prefixes = getProtocolPrefixes()
|
||||||
prefixFound = False
|
prefixFound = False
|
||||||
|
@ -207,7 +207,7 @@ def _setActorPropertyUrl(actorJson: {}, propertyName: str, url: str) -> None:
|
||||||
if ',' in url:
|
if ',' in url:
|
||||||
return
|
return
|
||||||
|
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -224,13 +224,13 @@ def _setActorPropertyUrl(actorJson: {}, propertyName: str, url: str) -> None:
|
||||||
"type": "PropertyValue",
|
"type": "PropertyValue",
|
||||||
"value": url
|
"value": url
|
||||||
}
|
}
|
||||||
actorJson['attachment'].append(newAddress)
|
actor_json['attachment'].append(newAddress)
|
||||||
|
|
||||||
|
|
||||||
def setBlogAddress(actorJson: {}, blogAddress: str) -> None:
|
def setBlogAddress(actor_json: {}, blogAddress: str) -> None:
|
||||||
"""Sets an blog address for the given actor
|
"""Sets an blog address for the given actor
|
||||||
"""
|
"""
|
||||||
_setActorPropertyUrl(actorJson, 'Blog', removeHtml(blogAddress))
|
_setActorPropertyUrl(actor_json, 'Blog', removeHtml(blogAddress))
|
||||||
|
|
||||||
|
|
||||||
def updateAvatarImageCache(signing_priv_key_pem: str,
|
def updateAvatarImageCache(signing_priv_key_pem: str,
|
||||||
|
@ -550,13 +550,13 @@ def htmlHeaderWithExternalStyle(cssFilename: str, instanceTitle: str,
|
||||||
|
|
||||||
|
|
||||||
def htmlHeaderWithPersonMarkup(cssFilename: str, instanceTitle: str,
|
def htmlHeaderWithPersonMarkup(cssFilename: str, instanceTitle: str,
|
||||||
actorJson: {}, city: str,
|
actor_json: {}, city: str,
|
||||||
content_license_url: str,
|
content_license_url: str,
|
||||||
lang='en') -> str:
|
lang='en') -> str:
|
||||||
"""html header which includes person markup
|
"""html header which includes person markup
|
||||||
https://schema.org/Person
|
https://schema.org/Person
|
||||||
"""
|
"""
|
||||||
if not actorJson:
|
if not actor_json:
|
||||||
htmlStr = \
|
htmlStr = \
|
||||||
htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None, lang)
|
htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None, lang)
|
||||||
return htmlStr
|
return htmlStr
|
||||||
|
@ -580,11 +580,11 @@ def htmlHeaderWithPersonMarkup(cssFilename: str, instanceTitle: str,
|
||||||
' },\n'
|
' },\n'
|
||||||
|
|
||||||
skillsMarkup = ''
|
skillsMarkup = ''
|
||||||
if actorJson.get('hasOccupation'):
|
if actor_json.get('hasOccupation'):
|
||||||
if isinstance(actorJson['hasOccupation'], list):
|
if isinstance(actor_json['hasOccupation'], list):
|
||||||
skillsMarkup = ' "hasOccupation": [\n'
|
skillsMarkup = ' "hasOccupation": [\n'
|
||||||
firstEntry = True
|
firstEntry = True
|
||||||
for skillDict in actorJson['hasOccupation']:
|
for skillDict in actor_json['hasOccupation']:
|
||||||
if skillDict['@type'] == 'Role':
|
if skillDict['@type'] == 'Role':
|
||||||
if not firstEntry:
|
if not firstEntry:
|
||||||
skillsMarkup += ',\n'
|
skillsMarkup += ',\n'
|
||||||
|
@ -650,19 +650,19 @@ def htmlHeaderWithPersonMarkup(cssFilename: str, instanceTitle: str,
|
||||||
firstEntry = False
|
firstEntry = False
|
||||||
skillsMarkup += '\n ],\n'
|
skillsMarkup += '\n ],\n'
|
||||||
|
|
||||||
description = removeHtml(actorJson['summary'])
|
description = removeHtml(actor_json['summary'])
|
||||||
nameStr = removeHtml(actorJson['name'])
|
nameStr = removeHtml(actor_json['name'])
|
||||||
domain_full = actorJson['id'].split('://')[1].split('/')[0]
|
domain_full = actor_json['id'].split('://')[1].split('/')[0]
|
||||||
handle = actorJson['preferredUsername'] + '@' + domain_full
|
handle = actor_json['preferredUsername'] + '@' + domain_full
|
||||||
|
|
||||||
personMarkup = \
|
personMarkup = \
|
||||||
' "about": {\n' + \
|
' "about": {\n' + \
|
||||||
' "@type" : "Person",\n' + \
|
' "@type" : "Person",\n' + \
|
||||||
' "name": "' + nameStr + '",\n' + \
|
' "name": "' + nameStr + '",\n' + \
|
||||||
' "image": "' + actorJson['icon']['url'] + '",\n' + \
|
' "image": "' + actor_json['icon']['url'] + '",\n' + \
|
||||||
' "description": "' + description + '",\n' + \
|
' "description": "' + description + '",\n' + \
|
||||||
cityMarkup + skillsMarkup + \
|
cityMarkup + skillsMarkup + \
|
||||||
' "url": "' + actorJson['id'] + '"\n' + \
|
' "url": "' + actor_json['id'] + '"\n' + \
|
||||||
' },\n'
|
' },\n'
|
||||||
|
|
||||||
profileMarkup = \
|
profileMarkup = \
|
||||||
|
@ -672,7 +672,7 @@ def htmlHeaderWithPersonMarkup(cssFilename: str, instanceTitle: str,
|
||||||
' "@type": "ProfilePage",\n' + \
|
' "@type": "ProfilePage",\n' + \
|
||||||
' "mainEntityOfPage": {\n' + \
|
' "mainEntityOfPage": {\n' + \
|
||||||
' "@type": "WebPage",\n' + \
|
' "@type": "WebPage",\n' + \
|
||||||
" \"@id\": \"" + actorJson['id'] + "\"\n" + \
|
" \"@id\": \"" + actor_json['id'] + "\"\n" + \
|
||||||
' },\n' + personMarkup + \
|
' },\n' + personMarkup + \
|
||||||
' "accountablePerson": {\n' + \
|
' "accountablePerson": {\n' + \
|
||||||
' "@type": "Person",\n' + \
|
' "@type": "Person",\n' + \
|
||||||
|
@ -683,7 +683,7 @@ def htmlHeaderWithPersonMarkup(cssFilename: str, instanceTitle: str,
|
||||||
' "name": "' + nameStr + '"\n' + \
|
' "name": "' + nameStr + '"\n' + \
|
||||||
' },\n' + \
|
' },\n' + \
|
||||||
' "name": "' + nameStr + '",\n' + \
|
' "name": "' + nameStr + '",\n' + \
|
||||||
' "image": "' + actorJson['icon']['url'] + '",\n' + \
|
' "image": "' + actor_json['icon']['url'] + '",\n' + \
|
||||||
' "description": "' + description + '",\n' + \
|
' "description": "' + description + '",\n' + \
|
||||||
' "license": "' + content_license_url + '"\n' + \
|
' "license": "' + content_license_url + '"\n' + \
|
||||||
' }\n' + \
|
' }\n' + \
|
||||||
|
@ -694,7 +694,7 @@ def htmlHeaderWithPersonMarkup(cssFilename: str, instanceTitle: str,
|
||||||
" <meta content=\"profile\" property=\"og:type\" />\n" + \
|
" <meta content=\"profile\" property=\"og:type\" />\n" + \
|
||||||
" <meta content=\"" + description + \
|
" <meta content=\"" + description + \
|
||||||
"\" name='description'>\n" + \
|
"\" name='description'>\n" + \
|
||||||
" <meta content=\"" + actorJson['url'] + \
|
" <meta content=\"" + actor_json['url'] + \
|
||||||
"\" property=\"og:url\" />\n" + \
|
"\" property=\"og:url\" />\n" + \
|
||||||
" <meta content=\"" + domain_full + \
|
" <meta content=\"" + domain_full + \
|
||||||
"\" property=\"og:site_name\" />\n" + \
|
"\" property=\"og:site_name\" />\n" + \
|
||||||
|
@ -702,19 +702,19 @@ def htmlHeaderWithPersonMarkup(cssFilename: str, instanceTitle: str,
|
||||||
")\" property=\"og:title\" />\n" + \
|
")\" property=\"og:title\" />\n" + \
|
||||||
" <meta content=\"" + description + \
|
" <meta content=\"" + description + \
|
||||||
"\" property=\"og:description\" />\n" + \
|
"\" property=\"og:description\" />\n" + \
|
||||||
" <meta content=\"" + actorJson['icon']['url'] + \
|
" <meta content=\"" + actor_json['icon']['url'] + \
|
||||||
"\" property=\"og:image\" />\n" + \
|
"\" property=\"og:image\" />\n" + \
|
||||||
" <meta content=\"400\" property=\"og:image:width\" />\n" + \
|
" <meta content=\"400\" property=\"og:image:width\" />\n" + \
|
||||||
" <meta content=\"400\" property=\"og:image:height\" />\n" + \
|
" <meta content=\"400\" property=\"og:image:height\" />\n" + \
|
||||||
" <meta content=\"summary\" property=\"twitter:card\" />\n" + \
|
" <meta content=\"summary\" property=\"twitter:card\" />\n" + \
|
||||||
" <meta content=\"" + handle + \
|
" <meta content=\"" + handle + \
|
||||||
"\" property=\"profile:username\" />\n"
|
"\" property=\"profile:username\" />\n"
|
||||||
if actorJson.get('attachment'):
|
if actor_json.get('attachment'):
|
||||||
ogTags = (
|
ogTags = (
|
||||||
'email', 'openpgp', 'blog', 'xmpp', 'matrix', 'briar',
|
'email', 'openpgp', 'blog', 'xmpp', 'matrix', 'briar',
|
||||||
'jami', 'cwtch', 'languages'
|
'jami', 'cwtch', 'languages'
|
||||||
)
|
)
|
||||||
for attachJson in actorJson['attachment']:
|
for attachJson in actor_json['attachment']:
|
||||||
if not attachJson.get('name'):
|
if not attachJson.get('name'):
|
||||||
continue
|
continue
|
||||||
if not attachJson.get('value'):
|
if not attachJson.get('value'):
|
||||||
|
|
|
@ -100,15 +100,15 @@ def htmlWelcomeProfile(base_dir: str, nickname: str, domain: str,
|
||||||
profileForm += '</center>\n'
|
profileForm += '</center>\n'
|
||||||
|
|
||||||
actorFilename = acctDir(base_dir, nickname, domain) + '.json'
|
actorFilename = acctDir(base_dir, nickname, domain) + '.json'
|
||||||
actorJson = loadJson(actorFilename)
|
actor_json = loadJson(actorFilename)
|
||||||
displayNickname = actorJson['name']
|
displayNickname = actor_json['name']
|
||||||
profileForm += '<div class="container">\n'
|
profileForm += '<div class="container">\n'
|
||||||
profileForm += \
|
profileForm += \
|
||||||
editTextField(translate['Nickname'], 'displayNickname',
|
editTextField(translate['Nickname'], 'displayNickname',
|
||||||
displayNickname)
|
displayNickname)
|
||||||
|
|
||||||
bioStr = \
|
bioStr = \
|
||||||
actorJson['summary'].replace('<p>', '').replace('</p>', '')
|
actor_json['summary'].replace('<p>', '').replace('</p>', '')
|
||||||
if not bioStr:
|
if not bioStr:
|
||||||
bioStr = translate['Your bio']
|
bioStr = translate['Your bio']
|
||||||
profileForm += ' <label class="labels">' + \
|
profileForm += ' <label class="labels">' + \
|
||||||
|
|
34
webfinger.py
34
webfinger.py
|
@ -279,12 +279,12 @@ def webfingerLookup(path: str, base_dir: str,
|
||||||
return wfJson
|
return wfJson
|
||||||
|
|
||||||
|
|
||||||
def _webfingerUpdateAvatar(wfJson: {}, actorJson: {}) -> bool:
|
def _webfingerUpdateAvatar(wfJson: {}, actor_json: {}) -> bool:
|
||||||
"""Updates the avatar image link
|
"""Updates the avatar image link
|
||||||
"""
|
"""
|
||||||
found = False
|
found = False
|
||||||
avatarUrl = actorJson['icon']['url']
|
avatarUrl = actor_json['icon']['url']
|
||||||
mediaType = actorJson['icon']['mediaType']
|
mediaType = actor_json['icon']['mediaType']
|
||||||
for link in wfJson['links']:
|
for link in wfJson['links']:
|
||||||
if not link.get('rel'):
|
if not link.get('rel'):
|
||||||
continue
|
continue
|
||||||
|
@ -306,18 +306,18 @@ def _webfingerUpdateAvatar(wfJson: {}, actorJson: {}) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def _webfingerAddBlogLink(wfJson: {}, actorJson: {}) -> bool:
|
def _webfingerAddBlogLink(wfJson: {}, actor_json: {}) -> bool:
|
||||||
"""Adds a blog link to webfinger if needed
|
"""Adds a blog link to webfinger if needed
|
||||||
"""
|
"""
|
||||||
found = False
|
found = False
|
||||||
if '/users/' in actorJson['id']:
|
if '/users/' in actor_json['id']:
|
||||||
blogUrl = \
|
blogUrl = \
|
||||||
actorJson['id'].split('/users/')[0] + '/blog/' + \
|
actor_json['id'].split('/users/')[0] + '/blog/' + \
|
||||||
actorJson['id'].split('/users/')[1]
|
actor_json['id'].split('/users/')[1]
|
||||||
else:
|
else:
|
||||||
blogUrl = \
|
blogUrl = \
|
||||||
actorJson['id'].split('/@')[0] + '/blog/' + \
|
actor_json['id'].split('/@')[0] + '/blog/' + \
|
||||||
actorJson['id'].split('/@')[1]
|
actor_json['id'].split('/@')[1]
|
||||||
for link in wfJson['links']:
|
for link in wfJson['links']:
|
||||||
if not link.get('rel'):
|
if not link.get('rel'):
|
||||||
continue
|
continue
|
||||||
|
@ -337,11 +337,11 @@ def _webfingerAddBlogLink(wfJson: {}, actorJson: {}) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def _webfingerUpdateFromProfile(wfJson: {}, actorJson: {}) -> bool:
|
def _webfingerUpdateFromProfile(wfJson: {}, actor_json: {}) -> bool:
|
||||||
"""Updates webfinger Email/blog/xmpp links from profile
|
"""Updates webfinger Email/blog/xmpp links from profile
|
||||||
Returns true if one or more tags has been changed
|
Returns true if one or more tags has been changed
|
||||||
"""
|
"""
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
|
@ -361,7 +361,7 @@ def _webfingerUpdateFromProfile(wfJson: {}, actorJson: {}) -> bool:
|
||||||
for name, alias in webfingerPropertyName.items():
|
for name, alias in webfingerPropertyName.items():
|
||||||
aliasesNotFound.append(alias)
|
aliasesNotFound.append(alias)
|
||||||
|
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
propertyName = propertyValue['name'].lower()
|
propertyName = propertyValue['name'].lower()
|
||||||
|
@ -411,10 +411,10 @@ def _webfingerUpdateFromProfile(wfJson: {}, actorJson: {}) -> bool:
|
||||||
wfJson['aliases'].remove(fullAlias)
|
wfJson['aliases'].remove(fullAlias)
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
if _webfingerUpdateAvatar(wfJson, actorJson):
|
if _webfingerUpdateAvatar(wfJson, actor_json):
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
if _webfingerAddBlogLink(wfJson, actorJson):
|
if _webfingerAddBlogLink(wfJson, actor_json):
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
return changed
|
return changed
|
||||||
|
@ -442,10 +442,10 @@ def webfingerUpdate(base_dir: str, nickname: str, domain: str,
|
||||||
return
|
return
|
||||||
|
|
||||||
actorFilename = base_dir + '/accounts/' + handle + '.json'
|
actorFilename = base_dir + '/accounts/' + handle + '.json'
|
||||||
actorJson = loadJson(actorFilename)
|
actor_json = loadJson(actorFilename)
|
||||||
if not actorJson:
|
if not actor_json:
|
||||||
return
|
return
|
||||||
|
|
||||||
if _webfingerUpdateFromProfile(wfJson, actorJson):
|
if _webfingerUpdateFromProfile(wfJson, actor_json):
|
||||||
if saveJson(wfJson, filename):
|
if saveJson(wfJson, filename):
|
||||||
storeWebfingerInCache(handle, wfJson, cached_webfingers)
|
storeWebfingerInCache(handle, wfJson, cached_webfingers)
|
||||||
|
|
20
xmpp.py
20
xmpp.py
|
@ -8,12 +8,12 @@ __status__ = "Production"
|
||||||
__module_group__ = "Profile Metadata"
|
__module_group__ = "Profile Metadata"
|
||||||
|
|
||||||
|
|
||||||
def getXmppAddress(actorJson: {}) -> str:
|
def getXmppAddress(actor_json: {}) -> str:
|
||||||
"""Returns xmpp address for the given actor
|
"""Returns xmpp address for the given actor
|
||||||
"""
|
"""
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
return ''
|
return ''
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
nameLower = propertyValue['name'].lower()
|
nameLower = propertyValue['name'].lower()
|
||||||
|
@ -34,7 +34,7 @@ def getXmppAddress(actorJson: {}) -> str:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
def setXmppAddress(actorJson: {}, xmppAddress: str) -> None:
|
def setXmppAddress(actor_json: {}, xmppAddress: str) -> None:
|
||||||
"""Sets an xmpp address for the given actor
|
"""Sets an xmpp address for the given actor
|
||||||
"""
|
"""
|
||||||
notXmppAddress = False
|
notXmppAddress = False
|
||||||
|
@ -47,12 +47,12 @@ def setXmppAddress(actorJson: {}, xmppAddress: str) -> None:
|
||||||
if '<' in xmppAddress:
|
if '<' in xmppAddress:
|
||||||
notXmppAddress = True
|
notXmppAddress = True
|
||||||
|
|
||||||
if not actorJson.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
actorJson['attachment'] = []
|
actor_json['attachment'] = []
|
||||||
|
|
||||||
# remove any existing value
|
# remove any existing value
|
||||||
propertyFound = None
|
propertyFound = None
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -63,11 +63,11 @@ def setXmppAddress(actorJson: {}, xmppAddress: str) -> None:
|
||||||
propertyFound = propertyValue
|
propertyFound = propertyValue
|
||||||
break
|
break
|
||||||
if propertyFound:
|
if propertyFound:
|
||||||
actorJson['attachment'].remove(propertyFound)
|
actor_json['attachment'].remove(propertyFound)
|
||||||
if notXmppAddress:
|
if notXmppAddress:
|
||||||
return
|
return
|
||||||
|
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actor_json['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
if not propertyValue.get('type'):
|
if not propertyValue.get('type'):
|
||||||
|
@ -86,4 +86,4 @@ def setXmppAddress(actorJson: {}, xmppAddress: str) -> None:
|
||||||
"type": "PropertyValue",
|
"type": "PropertyValue",
|
||||||
"value": xmppAddress
|
"value": xmppAddress
|
||||||
}
|
}
|
||||||
actorJson['attachment'].append(newXmppAddress)
|
actor_json['attachment'].append(newXmppAddress)
|
||||||
|
|
Loading…
Reference in New Issue