from __future__ import annotations

import logging

from sqlalchemy.ext.asyncio import AsyncSession

from shared.events import register_activity_handler
from shared.models.federation import APActivity

log = logging.getLogger(__name__)


async def on_order_created(activity: APActivity, session: AsyncSession) -> None:
    log.info("order.created: order_id=%s", activity.object_data.get("order_id"))


async def on_order_paid(activity: APActivity, session: AsyncSession) -> None:
    log.info("order.paid: order_id=%s", activity.object_data.get("order_id"))


register_activity_handler("Create", on_order_created, object_type="rose:Order")
register_activity_handler("rose:OrderPaid", on_order_paid)
