diff --git a/donate.py b/donate.py index 4a57279d..fd53936f 100644 --- a/donate.py +++ b/donate.py @@ -51,6 +51,20 @@ def setDonationUrl(actorJson: {},donateUrl: str) -> None: if not donateName: return + # remove any existing value + propertyFound=None + for propertyValue in actorJson['attachment']: + if not propertyValue.get('name'): + continue + if not propertyValue.get('type'): + continue + if not propertyValue['name'].lower()!=donateName: + continue + propertyFound=propertyValue + break + if propertyFound: + actorJson['attachment'].remove(propertyFound) + donateValue=''+donateUrl+'' for propertyValue in actorJson['attachment']: diff --git a/matrix.py b/matrix.py index 017a85e6..61835f59 100644 --- a/matrix.py +++ b/matrix.py @@ -41,6 +41,20 @@ def setMatrixAddress(actorJson: {},matrixAddress: str) -> None: if not actorJson.get('attachment'): actorJson['attachment']=[] + # remove any existing value + propertyFound=None + for propertyValue in actorJson['attachment']: + if not propertyValue.get('name'): + continue + if not propertyValue.get('type'): + continue + if not propertyValue['name'].lower().startswith('matrix'): + continue + propertyFound=propertyValue + break + if propertyFound: + actorJson['attachment'].remove(propertyFound) + if '@' not in matrixAddress: return if not matrixAddress.startswith('@'): diff --git a/pgp.py b/pgp.py index d4a1ef81..62679319 100644 --- a/pgp.py +++ b/pgp.py @@ -58,6 +58,20 @@ def setEmailAddress(actorJson: {},emailAddress: str) -> None: if not actorJson.get('attachment'): actorJson['attachment']=[] + # remove any existing value + propertyFound=None + for propertyValue in actorJson['attachment']: + if not propertyValue.get('name'): + continue + if not propertyValue.get('type'): + continue + if not propertyValue['name'].lower().startswith('email'): + continue + propertyFound=propertyValue + break + if propertyFound: + actorJson['attachment'].remove(propertyFound) + if '@' not in emailAddress: return if '.' not in emailAddress: @@ -90,6 +104,20 @@ def setPGPpubKey(actorJson: {},PGPpubKey: str) -> None: if not actorJson.get('attachment'): actorJson['attachment']=[] + # remove any existing value + propertyFound=None + for propertyValue in actorJson['attachment']: + if not propertyValue.get('name'): + continue + if not propertyValue.get('type'): + continue + if not propertyValue['name'].lower().startswith('pgp'): + continue + propertyFound=propertyValue + break + if propertyFound: + actorJson['attachment'].remove(propertyValue) + if '--BEGIN PGP PUBLIC KEY' not in PGPpubKey: return diff --git a/xmpp.py b/xmpp.py index 667669cf..13b4e995 100644 --- a/xmpp.py +++ b/xmpp.py @@ -39,6 +39,21 @@ def setXmppAddress(actorJson: {},xmppAddress: str) -> None: if not actorJson.get('attachment'): actorJson['attachment']=[] + # remove any existing value + propertyFound=None + for propertyValue in actorJson['attachment']: + if not propertyValue.get('name'): + continue + if not propertyValue.get('type'): + continue + if not (propertyValue['name'].lower().startswith('xmpp') or \ + propertyValue['name'].lower().startswith('jabber')): + continue + propertyFound=propertyValue + break + if propertyFound: + actorJson['attachment'].remove(propertyFound) + if '@' not in xmppAddress: return if '.' not in xmppAddress: