main
Bob Mottram 2021-08-12 22:16:43 +01:00
parent b27fa065b4
commit 9c6db7be11
2 changed files with 4 additions and 18 deletions

View File

@ -4839,11 +4839,8 @@ class PubServer(BaseHTTPRequestHandler):
# change website
currentWebsite = \
getWebsite(actorJson, self.server.translate)
print('websiteUrl: 0')
if fields.get('websiteUrl'):
print('websiteUrl: 1 ' + fields['websiteUrl'])
if fields['websiteUrl'] != currentWebsite:
print('websiteUrl: 2 ' + fields['websiteUrl'])
setWebsite(actorJson,
fields['websiteUrl'],
self.server.translate)

View File

@ -49,7 +49,7 @@ def getWebsite(actorJson: {}, translate: {}) -> str:
if not actorJson.get('attachment'):
return ''
matchStrings = _getWebsiteStrings()
matchStrings.append(translate['Website'])
matchStrings.append(translate['Website'].lower())
for propertyValue in actorJson['attachment']:
if not propertyValue.get('name'):
continue
@ -133,6 +133,7 @@ def setDonationUrl(actorJson: {}, donateUrl: str) -> None:
def setWebsite(actorJson: {}, websiteUrl: str, translate: {}) -> None:
"""Sets a web address
"""
websiteUrl = websiteUrl.strip()
notUrl = False
if '.' not in websiteUrl:
notUrl = True
@ -147,7 +148,7 @@ def setWebsite(actorJson: {}, websiteUrl: str, translate: {}) -> None:
actorJson['attachment'] = []
matchStrings = _getWebsiteStrings()
matchStrings.append(translate['Website'])
matchStrings.append(translate['Website'].lower())
# remove any existing value
propertyFound = None
@ -156,7 +157,7 @@ def setWebsite(actorJson: {}, websiteUrl: str, translate: {}) -> None:
continue
if not propertyValue.get('type'):
continue
if not propertyValue['name'].lower() not in matchStrings:
if propertyValue['name'].lower() not in matchStrings:
continue
propertyFound = propertyValue
break
@ -165,18 +166,6 @@ def setWebsite(actorJson: {}, websiteUrl: str, translate: {}) -> None:
if notUrl:
return
for propertyValue in actorJson['attachment']:
if not propertyValue.get('name'):
continue
if not propertyValue.get('type'):
continue
if not propertyValue['name'].lower() not in matchStrings:
continue
if propertyValue['type'] != 'PropertyValue':
continue
propertyValue['value'] = websiteUrl
return
newEntry = {
"name": 'Website',
"type": "PropertyValue",