Extra checks when receiving actor update

master
Bob Mottram 2019-08-22 18:49:57 +01:00
parent 49d087a911
commit 7ca21555a3
1 changed files with 19 additions and 7 deletions

View File

@ -569,7 +569,9 @@ def receiveUndo(session,baseDir: str,httpPrefix: str, \
debug) debug)
return False return False
def personReceiveUpdate(baseDir: str,nickname: str,domain: str,port: int, \ def personReceiveUpdate(baseDir: str, \
domain: str,port: int, \
updateNickname: str,updateDomain: str,updatePort: int, \
personJson: {},personCache: {},debug: bool) -> bool: personJson: {},personCache: {},debug: bool) -> bool:
"""Changes an actor. eg: avatar or preferred name change """Changes an actor. eg: avatar or preferred name change
""" """
@ -579,10 +581,18 @@ def personReceiveUpdate(baseDir: str,nickname: str,domain: str,port: int, \
if port: if port:
if port!=80 and port!=443: if port!=80 and port!=443:
domainFull=domain+':'+str(port) domainFull=domain+':'+str(port)
actor=domainFull+'/users/'+nickname updateDomainFull=domain
if actor in personJson['id']: if updatePort:
if updatePort!=80 and updatePort!=443:
updateDomainFull=updateDomain+':'+str(updatePort)
actor=updateDomainFull+'/users/'+updateNickname
if actor not in personJson['id']:
if debug: if debug:
print('DEBUG: Cannot receive update activity for your own actor') print('DEBUG: Actor does not match id')
return False
if updateDomainFull==domainFull:
if debug:
print('DEBUG: You can only receive actor updates for domains other than your own')
return False return False
if not personJson.get('publicKey'): if not personJson.get('publicKey'):
if debug: if debug:
@ -648,9 +658,11 @@ def receiveUpdate(session,baseDir: str, \
if messageJson['object']['type']=='Person': if messageJson['object']['type']=='Person':
if messageJson['object'].get('url') and messageJson['object'].get('id'): if messageJson['object'].get('url') and messageJson['object'].get('id'):
domain,tempPort=getDomainFromActor(messageJson['actor']) updateDomain,updatePort=getDomainFromActor(messageJson['actor'])
nickname=getNicknameFromActor(messageJson['actor']) updateNickname=getNicknameFromActor(messageJson['actor'])
if personReceiveUpdate(baseDir,nickname,domain,port, \ if personReceiveUpdate(baseDir, \
domain,port, \
updateNickname,updateDomain,updatePort, \
messageJson['object'], \ messageJson['object'], \
personCache,debug): personCache,debug):
if debug: if debug: