mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-12-22 05:04:27 +00:00
Some tests are passing
This commit is contained in:
parent
2c53573b7e
commit
781ed8efe2
3 changed files with 15 additions and 15 deletions
|
@ -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,10 +92,9 @@ 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")
|
||||
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:
|
||||
|
@ -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
10
app.py
|
@ -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)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
git+https://github.com/tsileo/little-boxes.git
|
||||
pytest
|
||||
requests
|
||||
html2text
|
||||
|
|
Loading…
Reference in a new issue