Store updated profile in memory cache

master
Bob Mottram 2019-08-22 18:33:04 +01:00
parent 5891f2ae12
commit 49d087a911
1 changed files with 3 additions and 1 deletions

View File

@ -609,7 +609,7 @@ def personReceiveUpdate(baseDir: str,nickname: str,domain: str,port: int, \
print('WARN: Public key does not match cached actor when updating') print('WARN: Public key does not match cached actor when updating')
return False return False
# save to cache in memory # save to cache in memory
personCache[personJson['id']]=personJson storePersonInCache(baseDir,personJson['id'],personJson,personCache)
# save to cache on file # save to cache on file
with open(actorFilename, 'w') as fp: with open(actorFilename, 'w') as fp:
commentjson.dump(personJson, fp, indent=4, sort_keys=False) commentjson.dump(personJson, fp, indent=4, sort_keys=False)
@ -648,6 +648,8 @@ 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'])
nickname=getNicknameFromActor(messageJson['actor'])
if personReceiveUpdate(baseDir,nickname,domain,port, \ if personReceiveUpdate(baseDir,nickname,domain,port, \
messageJson['object'], \ messageJson['object'], \
personCache,debug): personCache,debug):