Skip to content

Commit

Permalink
disambiguates between incident threads, case threads, and incident me…
Browse files Browse the repository at this point in the history
…ssages (#3663)

* check for missing conversation after trying to pull

* Actually fix the incident ban threads
  • Loading branch information
wssheldon authored Aug 3, 2023
1 parent 11825f5 commit 00e7192
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions src/dispatch/conversation/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,21 @@ def get_by_channel_id_ignoring_channel_type(
"""
channel_id_without_type = channel_id[1:]

# For cases
if thread_id:
conversation = (
db_session.query(Conversation)
.filter(Conversation.channel_id.contains(channel_id_without_type))
.filter(Conversation.thread_id == thread_id)
.filter(Conversation.case_id.isnot(None))
.one_or_none()
)
# For incidents
else:
conversation = (
db_session.query(Conversation)
.filter(Conversation.channel_id.contains(channel_id_without_type))
.one_or_none()
)
conversation = None

query = db_session.query(Conversation).filter(
Conversation.channel_id.contains(channel_id_without_type)
)

# The code below disambiguates between incident threads, case threads, and incident messages
if not thread_id:
conversation = query.one_or_none()

if not conversation:
conversation = query.filter(Conversation.thread_id == thread_id).one_or_none()

if not conversation:
conversation = query.one_or_none()

if conversation:
if channel_id[0] != conversation.channel_id[0]:
Expand Down

0 comments on commit 00e7192

Please sign in to comment.