Fix fetch_iri

This commit is contained in:
Thomas Sileo 2018-06-17 22:05:38 +02:00
parent 781ed8efe2
commit 986edbd35e
3 changed files with 10 additions and 2 deletions

View file

@ -21,7 +21,6 @@ from little_boxes import activitypub as ap
from little_boxes.backend import Backend from little_boxes.backend import Backend
from little_boxes.collection import parse_collection as ap_parse_collection from little_boxes.collection import parse_collection as ap_parse_collection
from little_boxes.errors import Error from little_boxes.errors import Error
from little_boxes.errors import ActivityNotFoundError
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -91,8 +90,14 @@ class MicroblogPubBackend(Backend):
# Check if the activity is owned by this server # Check if the activity is owned by this server
if iri.startswith(BASE_URL): if iri.startswith(BASE_URL):
is_a_note = False
if iri.endswith('/activity'):
iri = iri.replace('/activity', '')
is_a_note = True
data = DB.outbox.find_one({"remote_id": iri}) data = DB.outbox.find_one({"remote_id": iri})
if data: if data:
if is_a_note:
return data['activity']['object']
return data["activity"] return data["activity"]
else: else:
# Check if the activity is stored in the inbox # Check if the activity is stored in the inbox

1
app.py
View file

@ -60,6 +60,7 @@ from little_boxes.errors import ActivityNotFoundError
from little_boxes.errors import Error from little_boxes.errors import Error
from little_boxes.errors import NotFromOutboxError from little_boxes.errors import NotFromOutboxError
from little_boxes.httpsig import HTTPSigAuth from little_boxes.httpsig import HTTPSigAuth
# from little_boxes.httpsig import verify_request # from little_boxes.httpsig import verify_request
from little_boxes.webfinger import get_actor_url from little_boxes.webfinger import get_actor_url
from little_boxes.webfinger import get_remote_follow_template from little_boxes.webfinger import get_remote_follow_template

View file

@ -84,7 +84,9 @@ JWT = JSONWebSignatureSerializer(JWT_SECRET)
def _admin_jwt_token() -> str: def _admin_jwt_token() -> str:
return JWT.dumps({"me": "ADMIN", "ts": datetime.now().timestamp()}).decode( # type: ignore return JWT.dumps(
{"me": "ADMIN", "ts": datetime.now().timestamp()}
).decode( # type: ignore
"utf-8" "utf-8"
) )