Skip to content

Commit

Permalink
Fixes access to local variable 'thread_conversation_weblink' (#5244)
Browse files Browse the repository at this point in the history
* Fixes access to local variable 'thread_conversation_weblink'

* Fixes additional access to local variables.
  • Loading branch information
metroid-samus authored Sep 25, 2024
1 parent d03afae commit f0f9979
Showing 1 changed file with 54 additions and 53 deletions.
107 changes: 54 additions & 53 deletions src/dispatch/conversation/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,61 +121,62 @@ def create_case_conversation(
description=f"Case conversation has migrated from thread [{thread_conversation_weblink}] to channel[{case.conversation.weblink}].",
case_id=case.id,
)
try:
plugin.instance.update_thread(
case=case,
conversation_id=thread_conversation_channel_id,
ts=thread_conversation_thread_id,
)
except Exception as e:
event_service.log_subject_event(
subject=case,
db_session=db_session,
source="Dispatch Core App",
description=f"Updating thread message failed. Reason: {e}",
)
log.exception(e)

# Inform users in the case thread that the conversation has migrated to a channel
try:
plugin.instance.send(
thread_conversation_channel_id,
"Notify Case conversation migration",
[],
MessageType.case_notification,
blocks=messages.create_case_thread_migration_message(
channel_weblink=conversation.get("weblink")
),
ts=thread_conversation_thread_id,
)
except Exception as e:
event_service.log_subject_event(
subject=case,
db_session=db_session,
source="Dispatch Core App",
description=f"Failed to send message to original Case thread. Reason: {e}",
)
log.exception(e)
try:
plugin.instance.update_thread(
case=case,
conversation_id=thread_conversation_channel_id,
ts=thread_conversation_thread_id,
)
except Exception as e:
event_service.log_subject_event(
subject=case,
db_session=db_session,
source="Dispatch Core App",
description=f"Updating thread message failed. Reason: {e}",
)
log.exception(e)

# Provide users in the case channel which thread the conversation originated from.
try:
plugin.instance.send(
case.conversation.channel_id,
"Maintain Case conversation context",
[],
MessageType.case_notification,
blocks=messages.create_case_channel_migration_message(
thread_weblink=thread_conversation_weblink
),
)
except Exception as e:
event_service.log_subject_event(
subject=case,
db_session=db_session,
source="Dispatch Core App",
description=f"Failed to send message to dedicated Case channel. Reason: {e}",
)
log.exception(e)
# Inform users in the case thread that the conversation has migrated to a channel
try:
plugin.instance.send(
thread_conversation_channel_id,
"Notify Case conversation migration",
[],
MessageType.case_notification,
blocks=messages.create_case_thread_migration_message(
channel_weblink=conversation.get("weblink")
),
ts=thread_conversation_thread_id,
)
except Exception as e:
event_service.log_subject_event(
subject=case,
db_session=db_session,
source="Dispatch Core App",
description=f"Failed to send message to original Case thread. Reason: {e}",
)
log.exception(e)

# Provide users in the case channel which thread the conversation originated from.
try:
plugin.instance.send(
case.conversation.channel_id,
"Maintain Case conversation context",
[],
MessageType.case_notification,
blocks=messages.create_case_channel_migration_message(
thread_weblink=thread_conversation_weblink
),
)
except Exception as e:
event_service.log_subject_event(
subject=case,
db_session=db_session,
source="Dispatch Core App",
description=f"Failed to send message to dedicated Case channel. Reason: {e}",
)
log.exception(e)

db_session.add(case)
db_session.commit()
Expand Down

0 comments on commit f0f9979

Please sign in to comment.