Handle out-of-order Delete activity
This commit is contained in:
parent
23832574bc
commit
064921fdd1
5 changed files with 222 additions and 19 deletions
|
@ -36,6 +36,24 @@ def build_follow_activity(
|
|||
}
|
||||
|
||||
|
||||
def build_delete_activity(
|
||||
from_remote_actor: actor.RemoteActor | models.Actor,
|
||||
deleted_object_ap_id: str,
|
||||
outbox_public_id: str | None = None,
|
||||
) -> ap.RawObject:
|
||||
return {
|
||||
"@context": ap.AS_CTX,
|
||||
"type": "Delete",
|
||||
"id": (
|
||||
from_remote_actor.ap_id # type: ignore
|
||||
+ "/follow/"
|
||||
+ (outbox_public_id or uuid4().hex)
|
||||
),
|
||||
"actor": from_remote_actor.ap_id,
|
||||
"object": deleted_object_ap_id,
|
||||
}
|
||||
|
||||
|
||||
def build_accept_activity(
|
||||
from_remote_actor: actor.RemoteActor,
|
||||
for_remote_object: RemoteObject,
|
||||
|
@ -80,6 +98,19 @@ def build_note_object(
|
|||
}
|
||||
|
||||
|
||||
def build_create_activity(obj: ap.RawObject) -> ap.RawObject:
|
||||
return {
|
||||
"@context": ap.AS_EXTENDED_CTX,
|
||||
"actor": obj["attributedTo"],
|
||||
"to": obj.get("to", []),
|
||||
"cc": obj.get("cc", []),
|
||||
"id": obj["id"] + "/activity",
|
||||
"object": ap.remove_context(obj),
|
||||
"published": obj["published"],
|
||||
"type": "Create",
|
||||
}
|
||||
|
||||
|
||||
class BaseModelMeta:
|
||||
sqlalchemy_session = _Session
|
||||
sqlalchemy_session_persistence = "commit"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue