Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,10 @@ async def __call__(self) -> Optional[AssistantThreadContext]:
if self.thread_context_loaded is True:
return self._thread_context

if self.payload.get("assistant_thread") is not None:
thread = self.payload.get("assistant_thread")
if thread is not None and thread.get("context", {}).get("channel_id") is not None:
Comment thread
srtaalej marked this conversation as resolved.
Outdated
# assistant_thread_started
thread = self.payload["assistant_thread"]
self._thread_context = (
AssistantThreadContext(thread["context"])
if thread.get("context", {}).get("channel_id") is not None
else None
)
self._thread_context = AssistantThreadContext(thread["context"])
# for this event, the context will never be changed
self.thread_context_loaded = True
elif self.payload.get("channel") is not None and self.payload.get("thread_ts") is not None:
Expand Down
10 changes: 3 additions & 7 deletions slack_bolt/context/get_thread_context/get_thread_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,10 @@ def __call__(self) -> Optional[AssistantThreadContext]:
if self.thread_context_loaded is True:
return self._thread_context

if self.payload.get("assistant_thread") is not None:
thread = self.payload.get("assistant_thread")
if thread is not None and thread.get("context", {}).get("channel_id") is not None:
Comment thread
srtaalej marked this conversation as resolved.
Outdated
# assistant_thread_started
thread = self.payload["assistant_thread"]
self._thread_context = (
AssistantThreadContext(thread["context"])
if thread.get("context", {}).get("channel_id") is not None
else None
)
self._thread_context = AssistantThreadContext(thread["context"])
# for this event, the context will never be changed
self.thread_context_loaded = True
elif self.payload.get("channel") is not None and self.payload.get("thread_ts") is not None:
Expand Down
2 changes: 1 addition & 1 deletion tests/scenario_tests/test_events_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def build_payload(event: dict) -> dict:
"channel": "D111",
"event_ts": "1726133700.887259",
"channel_type": "im",
"assistant_thread": {"XXX": "YYY"},
"assistant_thread": {"action_token": "10647138185092.960436384805.afce3599"},
}
)

Expand Down
2 changes: 1 addition & 1 deletion tests/scenario_tests_async/test_events_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def build_payload(event: dict) -> dict:
"channel": "D111",
"event_ts": "1726133700.887259",
"channel_type": "im",
"assistant_thread": {"XXX": "YYY"},
"assistant_thread": {"action_token": "10647138185092.960436384805.afce3599"},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about leaving the old test cases untouched and adding new ones for this logic?

}
)

Expand Down