From 9c6db7be11be30c4e21c9a931451a07da3dfcfaa Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 12 Aug 2021 22:16:43 +0100 Subject: [PATCH] Simplify --- daemon.py | 3 --- donate.py | 19 ++++--------------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/daemon.py b/daemon.py index e53a8afbc..b43680769 100644 --- a/daemon.py +++ b/daemon.py @@ -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) diff --git a/donate.py b/donate.py index 2df6e928f..a8f4e26d3 100644 --- a/donate.py +++ b/donate.py @@ -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",