Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(conversation): fixing bookmarks without resource.name #5793

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions src/dispatch/conversation/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,14 +405,22 @@ def add_conversation_bookmark(
title: str | None = None,
):
"""Adds a conversation bookmark."""
if not resource or not hasattr(resource, "name"):
if not resource:
log.warning("No conversation bookmark added since no resource available for subject.")
return

if not subject.conversation:
log.warning(
f"Conversation bookmark {resource.name.lower()} not added. No conversation available."
resource_name = (
resource.name.lower()
if hasattr(resource, "name")
else (
deslug_and_capitalize_resource_type(resource.resource_type)
if hasattr(resource, "resource_type")
else title if title else "untitled resource"
)
)

if not subject.conversation:
log.warning(f"Conversation bookmark {resource_name} not added. No conversation available.")
return

plugin = plugin_service.get_active_instance(
Expand All @@ -422,7 +430,7 @@ def add_conversation_bookmark(
)
if not plugin:
log.warning(
f"Conversation bookmark {resource.name.lower()} not added. No conversation plugin enabled."
f"Conversation bookmark {resource_name} not added. No conversation plugin enabled."
)
return

Expand All @@ -437,15 +445,15 @@ def add_conversation_bookmark(
)
if resource
else log.warning(
f"{resource.name} bookmark not added. No {resource.name.lower()} available for subject.."
f"{resource_name} bookmark not added. No {resource_name} available for subject.."
)
)
except Exception as e:
event_service.log_subject_event(
subject=subject,
db_session=db_session,
source="Dispatch Core App",
description=f"Adding the {resource.name.lower()} bookmark failed. Reason: {e}",
description=f"Adding the {resource_name} bookmark failed. Reason: {e}",
)
log.exception(e)

Expand Down
Loading