Removing existing values from profile

merge-requests/6/head
Bob Mottram 2019-12-17 23:35:59 +00:00
parent 29d0a8dcc6
commit 4594a92508
4 changed files with 71 additions and 0 deletions

View File

@ -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='<a href="'+donateUrl+'" rel="me nofollow noopener noreferrer" target="_blank">'+donateUrl+'</a>'
for propertyValue in actorJson['attachment']:

View File

@ -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('@'):

28
pgp.py
View File

@ -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

15
xmpp.py
View File

@ -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: