Download services/click/protocol.py from paisaly/backend: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/spaces/paisaly/backend/resolve/main/services/click/protocol.py
- Command line
-
hf download hf://spaces/paisaly/backend/services/click/protocol.py
-
curl -L -o protocol.py https://huggingface.co/spaces/paisaly/backend/resolve/main/services/click/protocol.py
1.13 kB
| """ClickHandler protocol and ClickContext dataclass.""" | |
| from __future__ import annotations | |
| from dataclasses import dataclass | |
| from datetime import datetime | |
| from typing_extensions import Protocol | |
| from app.infrastructure.cache.url_cache import UrlCacheData | |
| class ClickContext: | |
| """All metadata available at click time, passed to the active handler.""" | |
| url_data: UrlCacheData | |
| short_code: str | |
| client_ip: str | |
| redirect_ms: int | |
| user_agent: str | |
| referrer: str | None | |
| # When the visitor clicked, not when a worker got round to it. | |
| clicked_at: datetime | |
| is_emoji: bool = False | |
| cf_city: str | None = None | |
| # Campaign tags from the short link's query string (already sanitised | |
| # by ClickEvent). Recorded by the v2 handler; legacy ignores them. | |
| utm_source: str | None = None | |
| utm_medium: str | None = None | |
| utm_campaign: str | None = None | |
| variant_index: int | None = None | |
| class ClickHandler(Protocol): | |
| """Minimal protocol every click handler must satisfy.""" | |
| async def handle(self, context: ClickContext) -> None: ... | |