Some tests are passing

This commit is contained in:
Thomas Sileo 2018-06-17 21:54:16 +02:00
parent 2c53573b7e
commit 781ed8efe2
3 changed files with 15 additions and 15 deletions

View file

@ -79,7 +79,7 @@ class MicroblogPubBackend(Backend):
DB.outbox.find_one(
{
"type": ap.ActivityType.BLOCK.value,
"activity.object": as_actor.id,
"activity.object": actor_id,
"meta.undo": False,
}
)
@ -92,14 +92,13 @@ class MicroblogPubBackend(Backend):
# Check if the activity is owned by this server
if iri.startswith(BASE_URL):
data = DB.outbox.find_one({"remote_id": iri})
if not data:
raise ActivityNotFoundError(f"{iri} not found on this server")
return data["activity"]
# Check if the activity is stored in the inbox
data = DB.inbox.find_one({"remote_id": iri})
if data:
return data["activity"]
if data:
return data["activity"]
else:
# Check if the activity is stored in the inbox
data = DB.inbox.find_one({"remote_id": iri})
if data:
return data["activity"]
# Fetch the URL via HTTP
return super().fetch_iri(iri)
@ -142,7 +141,7 @@ class MicroblogPubBackend(Backend):
@ensure_it_is_me
def new_following(self, as_actor: ap.Person, follow: ap.Follow) -> None:
remote_actor = follow.get_actor().id
remote_actor = follow.get_object().id
if DB.following.find({"remote_actor": remote_actor}).count() == 0:
DB.following.insert_one({"remote_actor": remote_actor})

10
app.py
View file

@ -384,7 +384,7 @@ def authorize_follow():
if DB.following.find({"remote_actor": actor}).count() > 0:
return redirect("/following")
follow = activitypub.Follow(actor=MY_PERSON, object=actor)
follow = activitypub.Follow(actor=MY_PERSON.id, object=actor)
OUTBOX.post(follow)
return redirect("/following")
@ -1182,7 +1182,7 @@ def api_upload():
content = request.args.get("content")
to = request.args.get("to")
note = ap.Note(
actor=MY_PERSON,
attributedTo=MY_PERSON.id,
cc=[ID + "/followers"],
to=[to if to else ap.AS_PUBLIC],
content=content, # TODO(tsileo): handle markdown
@ -1225,7 +1225,7 @@ def api_new_note():
cc.append(tag["href"])
note = ap.Note(
actor=MY_PERSON,
attributedTo=MY_PERSON.id,
cc=list(set(cc)),
to=[to if to else ap.AS_PUBLIC],
content=content,
@ -1261,7 +1261,7 @@ def api_block():
if existing:
return _user_api_response(activity=existing["activity"]["id"])
block = ap.Block(actor=MY_PERSON, object=actor)
block = ap.Block(actor=MY_PERSON.id, object=actor)
OUTBOX.post(block)
return _user_api_response(activity=block.id)
@ -1276,7 +1276,7 @@ def api_follow():
if existing:
return _user_api_response(activity=existing["activity"]["id"])
follow = ap.Follow(actor=MY_PERSON, object=actor)
follow = ap.Follow(actor=MY_PERSON.id, object=actor)
OUTBOX.post(follow)
return _user_api_response(activity=follow.id)

View file

@ -1,3 +1,4 @@
git+https://github.com/tsileo/little-boxes.git
pytest
requests
html2text