mirror of
https://github.com/kuhyx/signal-bot.git
synced 2026-11-11 12:57:32 +01:00
fix: the release preview sends the app's User-Agent, which Commons requires
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ba54092e0a
commit
a79506c18f
@ -33,6 +33,7 @@ from typing import Final
|
||||
import httpx
|
||||
|
||||
from signal_bot.announce import render
|
||||
from signal_bot.app import HTTP_TIMEOUT_SECONDS, USER_AGENT
|
||||
from signal_bot.changelog import load, since
|
||||
from signal_bot.config_env import load_config
|
||||
from signal_bot.http_client import ImageFetcher
|
||||
@ -109,9 +110,16 @@ async def send_preview(group: str, ordinal: int, *, print_only: bool) -> None:
|
||||
if print_only:
|
||||
sys.stdout.write("== not sent (--print-only)\n")
|
||||
return
|
||||
sys.stdout.flush()
|
||||
|
||||
config = load_config()
|
||||
async with httpx.AsyncClient(timeout=60.0) as client:
|
||||
# The app's client, headers and all: Wikimedia answers 403 to httpx's
|
||||
# default User-Agent, so a bare client here would fail exactly where the
|
||||
# bot succeeds -- which is the opposite of what a preview is for.
|
||||
async with httpx.AsyncClient(
|
||||
timeout=HTTP_TIMEOUT_SECONDS,
|
||||
headers={"User-Agent": USER_AGENT},
|
||||
) as client:
|
||||
group_id = await group_id_for(client, config.groups_url, group)
|
||||
portraits = PortraitCache(ImageFetcher(client), config.commons_api_url)
|
||||
image = await portraits.get_base64(pope)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user