Skip to content

Commit

Permalink
feat: add owner details to observation reports (#17324)
Browse files Browse the repository at this point in the history
  • Loading branch information
miketheman authored Dec 30, 2024
1 parent 114b846 commit b2b680f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion tests/unit/observations/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
)

from ...common.db.accounts import UserFactory
from ...common.db.packaging import ProjectFactory
from ...common.db.packaging import ProjectFactory, RoleFactory


def test_execute_observation_report(app_config):
Expand Down Expand Up @@ -55,6 +55,9 @@ def test_report_observation_to_helpscout(
user = UserFactory.create()
db_request.user = user
project = ProjectFactory.create()
project_owner = UserFactory.create()
RoleFactory.create(project=project, user=project_owner, role_name="Owner")

observation = project.record_observation(
request=db_request,
kind=kind,
Expand Down
7 changes: 6 additions & 1 deletion warehouse/observations/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,14 @@ def report_observation_to_helpscout(task, request: Request, model_id: UUID) -> N
Summary: {model.summary}
Model Name: {model.__class__.__name__}
Project URL: https://pypi.org/project/{target_name}/
Project URL: {request.route_url('packaging.project', name=target_name)}
"""
)
for owner in model.related.owners:
username = owner.username
owner_url = request.route_url("admin.user.detail", username=username)
convo_text += f"Owner: {username}\n"
convo_text += f"Owner URL: {owner_url}\n"

if OBSERVATION_KIND_MAP[model.kind] == ObservationKind.IsMalware:
convo_text += dedent(
Expand Down

0 comments on commit b2b680f

Please sign in to comment.