Start support for processing transient object

This commit is contained in:
Thomas Sileo 2022-07-15 08:40:07 +02:00
parent 8dc0e1877b
commit 4f16e3b940
3 changed files with 35 additions and 3 deletions

View file

@ -836,6 +836,20 @@ async def _process_note_object(
db_session.add(notif)
async def _process_transient_object(
db_session: AsyncSession,
raw_object: ap.RawObject,
from_actor: models.Actor,
) -> None:
ap_type = raw_object["type"]
if ap_type in ["Add", "Remove"]:
logger.info(f"Dropping unsupported {ap_type} object")
else:
logger.warning(f"Received unknown {ap_type} object")
return None
async def save_to_inbox(
db_session: AsyncSession,
raw_object: ap.RawObject,
@ -847,6 +861,10 @@ async def save_to_inbox(
logger.exception("Failed to fetch actor")
return
if "id" not in raw_object:
await _process_transient_object(db_session, raw_object, actor)
return None
raw_object_id = ap.get_id(raw_object)
# Ensure forwarded activities have a valid LD sig