Skip to content

Commit 3f8060b

Browse files
committed
fix(assistant): get_thread_context falls through to store.find() for user_message events
1 parent 5a153e6 commit 3f8060b

File tree

4 files changed

+8
-16
lines changed

4 files changed

+8
-16
lines changed

slack_bolt/context/get_thread_context/async_get_thread_context.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,10 @@ async def __call__(self) -> Optional[AssistantThreadContext]:
3131
if self.thread_context_loaded is True:
3232
return self._thread_context
3333

34-
if self.payload.get("assistant_thread") is not None:
34+
thread = self.payload.get("assistant_thread")
35+
if thread is not None and thread.get("context", {}).get("channel_id") is not None:
3536
# assistant_thread_started
36-
thread = self.payload["assistant_thread"]
37-
self._thread_context = (
38-
AssistantThreadContext(thread["context"])
39-
if thread.get("context", {}).get("channel_id") is not None
40-
else None
41-
)
37+
self._thread_context = AssistantThreadContext(thread["context"])
4238
# for this event, the context will never be changed
4339
self.thread_context_loaded = True
4440
elif self.payload.get("channel") is not None and self.payload.get("thread_ts") is not None:

slack_bolt/context/get_thread_context/get_thread_context.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,10 @@ def __call__(self) -> Optional[AssistantThreadContext]:
3131
if self.thread_context_loaded is True:
3232
return self._thread_context
3333

34-
if self.payload.get("assistant_thread") is not None:
34+
thread = self.payload.get("assistant_thread")
35+
if thread is not None and thread.get("context", {}).get("channel_id") is not None:
3536
# assistant_thread_started
36-
thread = self.payload["assistant_thread"]
37-
self._thread_context = (
38-
AssistantThreadContext(thread["context"])
39-
if thread.get("context", {}).get("channel_id") is not None
40-
else None
41-
)
37+
self._thread_context = AssistantThreadContext(thread["context"])
4238
# for this event, the context will never be changed
4339
self.thread_context_loaded = True
4440
elif self.payload.get("channel") is not None and self.payload.get("thread_ts") is not None:

tests/scenario_tests/test_events_assistant.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def build_payload(event: dict) -> dict:
186186
"channel": "D111",
187187
"event_ts": "1726133700.887259",
188188
"channel_type": "im",
189-
"assistant_thread": {"XXX": "YYY"},
189+
"assistant_thread": {"action_token": "10647138185092.960436384805.afce3599"},
190190
}
191191
)
192192

tests/scenario_tests_async/test_events_assistant.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def build_payload(event: dict) -> dict:
200200
"channel": "D111",
201201
"event_ts": "1726133700.887259",
202202
"channel_type": "im",
203-
"assistant_thread": {"XXX": "YYY"},
203+
"assistant_thread": {"action_token": "10647138185092.960436384805.afce3599"},
204204
}
205205
)
206206

0 commit comments

Comments
 (0)