Skip to content

Commit

Permalink
fix: use correct host in URL construction
Browse files Browse the repository at this point in the history
This catches us often in tasks, defaulting to `localhost`.

Signed-off-by: Mike Fiedler <[email protected]>
  • Loading branch information
miketheman committed Dec 30, 2024
1 parent b2b680f commit 90395a3
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions warehouse/observations/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,25 @@ def report_observation_to_helpscout(task, request: Request, model_id: UUID) -> N
# Maybe need a mapping of ObservationType and the name we want to use.
target_name = model.related.name

warehouse_domain = request.registry.settings.get("warehouse.domain")

# Add new Conversation to HelpScout for tracking purposes
convo_text = dedent(
f"""
Kind: {model.kind}
Summary: {model.summary}
Model Name: {model.__class__.__name__}
Project URL: {request.route_url('packaging.project', name=target_name)}
Project URL: {request.route_url(
'packaging.project', name=target_name, _host=warehouse_domain
)}
"""
)
for owner in model.related.owners:
username = owner.username
owner_url = request.route_url("admin.user.detail", username=username)
owner_url = request.route_url(
"admin.user.detail", username=username, _host=warehouse_domain
)
convo_text += f"Owner: {username}\n"
convo_text += f"Owner URL: {owner_url}\n"

Expand All @@ -102,7 +108,7 @@ def report_observation_to_helpscout(task, request: Request, model_id: UUID) -> N
Malware Reports URL: {request.route_url(
"admin.malware_reports.project.list",
project_name=target_name,
_host=request.registry.settings.get("warehouse.domain"),
_host=warehouse_domain,
)}
"""
)
Expand Down

0 comments on commit 90395a3

Please sign in to comment.