mirror of https://gitlab.com/bashrc2/epicyon
Resolve instance actor
parent
c178105164
commit
2ee6673dc0
20
daemon.py
20
daemon.py
|
@ -10268,7 +10268,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
enableSharedInbox: bool) -> bool:
|
||||
"""Shows the instance actor
|
||||
"""
|
||||
print('Instance actor requested by ' + callingDomain)
|
||||
if debug:
|
||||
print('Instance actor requested by ' + callingDomain)
|
||||
actorJson = personLookup(domain, path, baseDir)
|
||||
if not actorJson:
|
||||
print('ERROR: no instance actor found')
|
||||
|
@ -10282,8 +10283,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
else:
|
||||
actorDomainUrl = httpPrefix + '://' + domainFull
|
||||
actorUrl = actorDomainUrl + '/users/Actor'
|
||||
del actorJson['icon']
|
||||
del actorJson['image']
|
||||
removeFields = ('icon', 'image', 'tts', 'shares')
|
||||
for r in removeFields:
|
||||
if actorJson.get(r):
|
||||
del actorJson[r]
|
||||
actorJson['endpoints'] = {}
|
||||
if enableSharedInbox:
|
||||
actorJson['endpoints'] = {
|
||||
|
@ -11062,7 +11065,6 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
return True
|
||||
|
||||
def do_GET(self):
|
||||
print('actor test 0: ' + self.path)
|
||||
callingDomain = self.server.domainFull
|
||||
if self.headers.get('Host'):
|
||||
callingDomain = decodedHost(self.headers['Host'])
|
||||
|
@ -11080,12 +11082,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._400()
|
||||
return
|
||||
|
||||
print('actor test 1: ' + self.path)
|
||||
if self._blockedUserAgent(callingDomain):
|
||||
self._400()
|
||||
return
|
||||
|
||||
print('actor test 2: ' + self.path)
|
||||
GETstartTime = time.time()
|
||||
GETtimings = {}
|
||||
|
||||
|
@ -11100,7 +11100,6 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._benchmarkGETtimings(GETstartTime, GETtimings,
|
||||
'start', '_nodeinfo[callingDomain]')
|
||||
|
||||
print('actor test 3: ' + self.path)
|
||||
if self.path == '/logout':
|
||||
if not self.server.newsInstance:
|
||||
msg = \
|
||||
|
@ -11157,13 +11156,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
'/users/' + nickname + '/statuses/')
|
||||
|
||||
# instance actor
|
||||
print('actor test 4: ' + self.path)
|
||||
if self.path == '/actor' or \
|
||||
self.path == '/users/actor' or \
|
||||
self.path == '/Actor' or \
|
||||
self.path == '/users/Actor':
|
||||
self.path = '/users/inbox'
|
||||
print('actor test 4: ' + self.path)
|
||||
print('actor test 1: ' + self.path)
|
||||
if self._showInstanceActor(callingDomain, self.path,
|
||||
self.server.baseDir,
|
||||
self.server.httpPrefix,
|
||||
|
@ -11176,10 +11174,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.proxyType,
|
||||
None, self.server.debug,
|
||||
self.server.enableSharedInbox):
|
||||
print('actor test success')
|
||||
print('actor test 2: ' + self.path)
|
||||
return
|
||||
else:
|
||||
print('actor test failed')
|
||||
print('actor test 3: ' + self.path)
|
||||
self._404()
|
||||
return
|
||||
|
||||
|
|
|
@ -718,7 +718,7 @@ def personLookup(domain: str, path: str, baseDir: str) -> {}:
|
|||
isSharedInbox = False
|
||||
if path == '/inbox' or path == '/users/inbox' or path == '/sharedInbox':
|
||||
# shared inbox actor on @domain@domain
|
||||
path = '/users/' + domain
|
||||
path = '/users/inbox'
|
||||
isSharedInbox = True
|
||||
else:
|
||||
notPersonLookup = ('/inbox', '/outbox', '/outboxarchive',
|
||||
|
|
22
tests.py
22
tests.py
|
@ -1444,6 +1444,25 @@ def testSharedItemsFederation():
|
|||
assert ctr <= 60
|
||||
time.sleep(1)
|
||||
|
||||
signingPrivateKeyPem = None
|
||||
sessionClient = createSession(proxyType)
|
||||
|
||||
# Get Bob's instance actor
|
||||
print('\n\n*********************************************************')
|
||||
print("Test Bob's instance actor")
|
||||
profileStr = 'https://www.w3.org/ns/activitystreams'
|
||||
testHeaders = {
|
||||
'host': bobAddress,
|
||||
'Accept': 'application/ld+json; profile="' + profileStr + '"'
|
||||
}
|
||||
bobInstanceActorJson = \
|
||||
getJson(signingPrivateKeyPem, sessionClient,
|
||||
'http://' + bobAddress + '/@actor', testHeaders, {}, True,
|
||||
__version__, 'http', 'somedomain.or.other', 10, True)
|
||||
assert bobInstanceActorJson
|
||||
pprint(bobInstanceActorJson)
|
||||
assert bobInstanceActorJson['name'] == 'ACTOR'
|
||||
|
||||
# In the beginning all was calm and there were no follows
|
||||
|
||||
print('\n\n*********************************************************')
|
||||
|
@ -1469,7 +1488,6 @@ def testSharedItemsFederation():
|
|||
aliceCachedWebfingers = {}
|
||||
alicePostLog = []
|
||||
bobActor = httpPrefix + '://' + bobAddress + '/users/bob'
|
||||
signingPrivateKeyPem = None
|
||||
sendResult = \
|
||||
sendFollowRequest(sessionAlice, aliceDir,
|
||||
'alice', aliceDomain, alicePort, httpPrefix,
|
||||
|
@ -1520,7 +1538,6 @@ def testSharedItemsFederation():
|
|||
assert os.path.isfile(bobDir + '/ontology/foodTypes.json')
|
||||
assert os.path.isfile(bobDir + '/ontology/toolTypes.json')
|
||||
assert os.path.isfile(bobDir + '/ontology/clothesTypes.json')
|
||||
sessionBob = createSession(proxyType)
|
||||
sharedItemName = 'cheddar'
|
||||
sharedItemDescription = 'Some cheese'
|
||||
sharedItemImageFilename = 'logo.png'
|
||||
|
@ -1532,6 +1549,7 @@ def testSharedItemsFederation():
|
|||
sharedItemPrice = "1.30"
|
||||
sharedItemCurrency = "EUR"
|
||||
signingPrivateKeyPem = None
|
||||
sessionBob = createSession(proxyType)
|
||||
shareJson = \
|
||||
sendShareViaServer(bobDir, sessionBob,
|
||||
'bob', bobPassword,
|
||||
|
|
Loading…
Reference in New Issue