forked from indymedia/epicyon
Include the handle within the capability id. This improves the matching confidence for shared inbox
parent
18f29fb9b0
commit
1d820e2199
|
@ -12,6 +12,8 @@ import time
|
||||||
import json
|
import json
|
||||||
import commentjson
|
import commentjson
|
||||||
from auth import createPassword
|
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:
|
def getOcapFilename(baseDir :str,nickname: str,domain: str,actor :str,subdir: str) -> str:
|
||||||
if ':' in domain:
|
if ':' in domain:
|
||||||
|
@ -118,7 +120,12 @@ def capabilitiesAccept(baseDir: str,httpPrefix: str, \
|
||||||
ocapAccept=commentjson.load(fp)
|
ocapAccept=commentjson.load(fp)
|
||||||
# otherwise create a new capability
|
# otherwise create a new capability
|
||||||
if not ocapAccept:
|
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 = {
|
ocapAccept = {
|
||||||
"id": httpPrefix+"://"+fullDomain+"/caps/"+ocapId,
|
"id": httpPrefix+"://"+fullDomain+"/caps/"+ocapId,
|
||||||
"type": "Capability",
|
"type": "Capability",
|
||||||
|
|
13
inbox.py
13
inbox.py
|
@ -414,10 +414,11 @@ def runInboxQueue(baseDir: str,httpPrefix: str,sendThreads: [],postLog: [],cache
|
||||||
# get recipients list
|
# get recipients list
|
||||||
recipientsDict=inboxPostRecipients(baseDir,queueJson['post'],httpPrefix,domain,port)
|
recipientsDict=inboxPostRecipients(baseDir,queueJson['post'],httpPrefix,domain,port)
|
||||||
|
|
||||||
print('*************************************')
|
if debug:
|
||||||
print('Resolved recipients list:')
|
print('*************************************')
|
||||||
pprint(recipientsDict)
|
print('Resolved recipients list:')
|
||||||
print('*************************************')
|
pprint(recipientsDict)
|
||||||
|
print('*************************************')
|
||||||
|
|
||||||
if queueJson['post'].get('capability'):
|
if queueJson['post'].get('capability'):
|
||||||
if not isinstance(queueJson['post']['capability'], list):
|
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'):
|
if queueJson['post'].get('capability'):
|
||||||
capabilityIdList=queueJson['post']['capability']
|
capabilityIdList=queueJson['post']['capability']
|
||||||
# does the capability id list within the post contain the id
|
# 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 capsId in capabilityIdList:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: object capabilities passed')
|
print('DEBUG: object capabilities passed')
|
||||||
|
|
8
utils.py
8
utils.py
|
@ -8,7 +8,7 @@ __status__ = "Production"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import datetime
|
import datetime
|
||||||
from capabilities import isCapable
|
#from capabilities import isCapable
|
||||||
|
|
||||||
def getStatusNumber() -> (str,str):
|
def getStatusNumber() -> (str,str):
|
||||||
"""Returns the status number and published date
|
"""Returns the status number and published date
|
||||||
|
@ -50,9 +50,9 @@ def domainPermitted(domain: str, federationList: []):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def urlPermitted(url: str, federationList: [],ocapGranted: {},capability: str):
|
def urlPermitted(url: str, federationList: [],ocapGranted: {},capability: str):
|
||||||
if ocapGranted:
|
#if ocapGranted:
|
||||||
if not isCapable(url,ocapGranted,capability):
|
# if not isCapable(url,ocapGranted,capability):
|
||||||
return False
|
# return False
|
||||||
if len(federationList)==0:
|
if len(federationList)==0:
|
||||||
return True
|
return True
|
||||||
for domain in federationList:
|
for domain in federationList:
|
||||||
|
|
Loading…
Reference in New Issue