Include the handle within the capability id. This improves the matching confidence for shared inbox

master
Bob Mottram 2019-07-09 09:39:50 +01:00
parent 18f29fb9b0
commit 1d820e2199
3 changed files with 20 additions and 10 deletions

View File

@ -12,6 +12,8 @@ import time
import json
import commentjson
from auth import createPassword
from utils import getNicknameFromActor
from utils import getDomainFromActor
def getOcapFilename(baseDir :str,nickname: str,domain: str,actor :str,subdir: str) -> str:
if ':' in domain:
@ -118,7 +120,12 @@ def capabilitiesAccept(baseDir: str,httpPrefix: str, \
ocapAccept=commentjson.load(fp)
# otherwise create a new capability
if not ocapAccept:
ocapId=createPassword(32)
acceptedActorNickname=getNicknameFromActor(acceptedActor)
acceptedActorDomain,acceptedActorPort=getDomainFromActor(acceptedActor)
if acceptedActorPort:
ocapId=acceptedActorNickname+'@'+acceptedActorDomain+':'+str(acceptedActorPort)+'#'+createPassword(32)
else:
ocapId=acceptedActorNickname+'@'+acceptedActorDomain+'#'+createPassword(32)
ocapAccept = {
"id": httpPrefix+"://"+fullDomain+"/caps/"+ocapId,
"type": "Capability",

View File

@ -414,10 +414,11 @@ def runInboxQueue(baseDir: str,httpPrefix: str,sendThreads: [],postLog: [],cache
# get recipients list
recipientsDict=inboxPostRecipients(baseDir,queueJson['post'],httpPrefix,domain,port)
print('*************************************')
print('Resolved recipients list:')
pprint(recipientsDict)
print('*************************************')
if debug:
print('*************************************')
print('Resolved recipients list:')
pprint(recipientsDict)
print('*************************************')
if queueJson['post'].get('capability'):
if not isinstance(queueJson['post']['capability'], list):
@ -433,7 +434,9 @@ def runInboxQueue(baseDir: str,httpPrefix: str,sendThreads: [],postLog: [],cache
if queueJson['post'].get('capability'):
capabilityIdList=queueJson['post']['capability']
# does the capability id list within the post contain the id
# of one of the recipients?
# of the recipient with this handle?
# Here the capability id begins with the handle, so this could also
# be matched separately, but it's probably not necessary
if capsId in capabilityIdList:
if debug:
print('DEBUG: object capabilities passed')

View File

@ -8,7 +8,7 @@ __status__ = "Production"
import os
import datetime
from capabilities import isCapable
#from capabilities import isCapable
def getStatusNumber() -> (str,str):
"""Returns the status number and published date
@ -50,9 +50,9 @@ def domainPermitted(domain: str, federationList: []):
return False
def urlPermitted(url: str, federationList: [],ocapGranted: {},capability: str):
if ocapGranted:
if not isCapable(url,ocapGranted,capability):
return False
#if ocapGranted:
# if not isCapable(url,ocapGranted,capability):
# return False
if len(federationList)==0:
return True
for domain in federationList: