Skip to content

Commit 27b34e1

Browse files
authored
fix(chat): use adapter to parse channel id (#286)
* fix(chat): use adapter to parse channel id * test: fix cases use adapter to parse channel id * chore: update changeset
1 parent 2d6a7e6 commit 27b34e1

6 files changed

Lines changed: 15 additions & 12 deletions

File tree

.changeset/thin-sloths-joke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"chat": patch
3+
---
4+
5+
Use adapter to parse channel id for `thread.channelId`

packages/chat/src/chat.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,10 +2077,8 @@ export class Chat<
20772077
initialMessage: Message,
20782078
isSubscribedContext = false
20792079
): Thread<TState> {
2080-
// Parse thread ID to get channel info
2081-
// Format: "adapter:channel:thread"
2082-
const parts = threadId.split(":");
2083-
const channelId = parts[1] || "";
2080+
// Parse thread ID to get channel ID with adapter
2081+
const channelId = adapter.channelIdFromThreadId(threadId);
20842082

20852083
// Check if this is a DM
20862084
const isDM = adapter.isDM?.(threadId) ?? false;

packages/integration-tests/src/replay-actions-reactions.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ describe("Replay Tests - Actions & Reactions", () => {
7070
userId: "U00FAKEUSER1",
7171
userName: "testuser",
7272
adapterName: "slack",
73-
channelId: "C00FAKECHAN1",
73+
channelId: "slack:C00FAKECHAN1",
7474
isDM: false,
7575
});
7676

@@ -91,7 +91,7 @@ describe("Replay Tests - Actions & Reactions", () => {
9191
added: true,
9292
userId: "U00FAKEUSER1",
9393
adapterName: "slack",
94-
channelId: "C00FAKECHAN1",
94+
channelId: "slack:C00FAKECHAN1",
9595
messageId: "1767326126.896109",
9696
isDM: false,
9797
});
@@ -110,7 +110,7 @@ describe("Replay Tests - Actions & Reactions", () => {
110110
userId: "U00FAKEUSER1",
111111
userName: "testuser",
112112
adapterName: "slack",
113-
channelId: "C00FAKECHAN1",
113+
channelId: "slack:C00FAKECHAN1",
114114
isDM: false,
115115
});
116116

@@ -129,7 +129,7 @@ describe("Replay Tests - Actions & Reactions", () => {
129129
userId: "U00FAKEUSER1",
130130
userName: "testuser",
131131
adapterName: "slack",
132-
channelId: "C00FAKECHAN1",
132+
channelId: "slack:C00FAKECHAN1",
133133
isDM: false,
134134
});
135135

packages/integration-tests/src/replay-channel.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ describe("Replay Tests - Channel", () => {
116116
userId: "U00FAKEUSER1",
117117
userName: "testuser",
118118
adapterName: "slack",
119-
channelId: "C00FAKECHAN1",
119+
channelId: "slack:C00FAKECHAN1",
120120
isDM: false,
121121
});
122122
});

packages/integration-tests/src/replay-modal-private-metadata.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describe("Replay Tests - Modal privateMetadata", () => {
6464
userId: "U0A8WUV28QM",
6565
userName: "sd0a90bkva4s_user",
6666
adapterName: "slack",
67-
channelId: "C0A9D9RTBMF",
67+
channelId: "slack:C0A9D9RTBMF",
6868
isDM: false,
6969
});
7070

packages/integration-tests/src/replay-modals.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ describe("Replay Tests - Modals", () => {
8080
userId: "U00FAKEUSER2",
8181
userName: "jane.smith",
8282
adapterName: "slack",
83-
channelId: "C00FAKECHAN2",
83+
channelId: "slack:C00FAKECHAN2",
8484
isDM: false,
8585
});
8686

@@ -254,7 +254,7 @@ describe("Replay Tests - Modals", () => {
254254
expect(capturedAction?.threadId).toBe(
255255
"slack:C00FAKECHAN3:1771126602.612659"
256256
);
257-
expect(capturedAction?.thread?.channelId).toBe("C00FAKECHAN3");
257+
expect(capturedAction?.thread?.channelId).toBe("slack:C00FAKECHAN3");
258258
});
259259

260260
it("should allow editing relatedMessage from ephemeral modal submission", async () => {

0 commit comments

Comments
 (0)