mirror of https://gitlab.com/bashrc2/epicyon
Remove unused webfinger aliases
parent
3bf910a9d4
commit
0c8b0964d7
17
webfinger.py
17
webfinger.py
|
@ -271,6 +271,10 @@ def _webfingerUpdateFromProfile(wfJson: {}, actorJson: {}) -> bool:
|
||||||
"tox": "toxId"
|
"tox": "toxId"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
aliasesNotFound = []
|
||||||
|
for name, _ in webfingerPropertyName.items():
|
||||||
|
aliasesNotFound.append(name)
|
||||||
|
|
||||||
for propertyValue in actorJson['attachment']:
|
for propertyValue in actorJson['attachment']:
|
||||||
if not propertyValue.get('name'):
|
if not propertyValue.get('name'):
|
||||||
continue
|
continue
|
||||||
|
@ -278,6 +282,8 @@ def _webfingerUpdateFromProfile(wfJson: {}, actorJson: {}) -> bool:
|
||||||
found = False
|
found = False
|
||||||
for name, alias in webfingerPropertyName.items():
|
for name, alias in webfingerPropertyName.items():
|
||||||
if name == propertyName:
|
if name == propertyName:
|
||||||
|
if name in aliasesNotFound:
|
||||||
|
aliasesNotFound.remove(name)
|
||||||
found = True
|
found = True
|
||||||
break
|
break
|
||||||
if not found:
|
if not found:
|
||||||
|
@ -308,6 +314,17 @@ def _webfingerUpdateFromProfile(wfJson: {}, actorJson: {}) -> bool:
|
||||||
else:
|
else:
|
||||||
wfJson['aliases'].append(newAlias)
|
wfJson['aliases'].append(newAlias)
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
|
# remove any aliases which are no longer in the actor profile
|
||||||
|
removeAlias = []
|
||||||
|
for name in aliasesNotFound:
|
||||||
|
for alias in wfJson['aliases']:
|
||||||
|
if alias.startswith(name + ':'):
|
||||||
|
removeAlias.append(alias)
|
||||||
|
for alias in removeAlias:
|
||||||
|
wfJson['aliases'].remove(alias)
|
||||||
|
changed = True
|
||||||
|
|
||||||
return changed
|
return changed
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue