Skip to content

Commit fe0e59b

Browse files
gavinbunneyseratch
authored andcommitted
Add threadTs to BlockActionPayload.Container
1 parent fac13fc commit fe0e59b

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

slack-app-backend/src/main/java/com/slack/api/app_backend/interactive_components/payload/BlockActionPayload.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public static class Container {
7878
@SerializedName("is_app_unfurl")
7979
private boolean appUnfurl;
8080
private String appUnfurlUrl;
81+
private String threadTs;
8182
}
8283

8384
@Data

slack-app-backend/src/test/java/test_locally/app_backend/interactive_components/payload/BlockActionPayloadTest.java

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,4 +322,79 @@ public void deserialize_app_unfurl() {
322322
}
323323

324324

325+
326+
String jsonInThread = "{\n" +
327+
" \"type\": \"block_actions\",\n" +
328+
" \"user\": {\n" +
329+
" \"id\": \"U111\",\n" +
330+
" \"username\": \"seratch\",\n" +
331+
" \"name\": \"seratch\",\n" +
332+
" \"team_id\": \"T111\"\n" +
333+
" },\n" +
334+
" \"api_app_id\": \"A111\",\n" +
335+
" \"token\": \"xxx\",\n" +
336+
" \"container\": {\n" +
337+
" \"type\": \"message\",\n" +
338+
" \"message_ts\": \"1693635296.000500\",\n" +
339+
" \"thread_ts\": \"1693616242.466609\",\n" +
340+
" \"channel_id\": \"C111\",\n" +
341+
" \"is_ephemeral\": true\n" +
342+
" },\n" +
343+
" \"trigger_id\": \"111.222.xxx\",\n" +
344+
" \"team\": {\n" +
345+
" \"id\": \"T111\",\n" +
346+
" \"domain\": \"xxx\"\n" +
347+
" },\n" +
348+
" \"channel\": {\n" +
349+
" \"id\": \"C111\",\n" +
350+
" \"name\": \"random\"\n" +
351+
" },\n" +
352+
" \"state\": {\n" +
353+
" \"values\": {\n" +
354+
" \"block_1\": {\n" +
355+
" \"action_1\": {\n" +
356+
" \"type\": \"external_select\",\n" +
357+
" \"selected_option\": {\n" +
358+
" \"text\": {\n" +
359+
" \"type\": \"plain_text\",\n" +
360+
" \"text\": \"Schedule\",\n" +
361+
" \"emoji\": true\n" +
362+
" },\n" +
363+
" \"value\": \"schedule\"\n" +
364+
" }\n" +
365+
" }\n" +
366+
" }\n" +
367+
" }\n" +
368+
" },\n" +
369+
" \"response_url\": \"https://hooks.slack.com/actions/T111/111/xxx\",\n" +
370+
" \"actions\": [\n" +
371+
" {\n" +
372+
" \"action_id\": \"save\",\n" +
373+
" \"block_id\": \"block_1\",\n" +
374+
" \"text\": {\n" +
375+
" \"type\": \"plain_text\",\n" +
376+
" \"text\": \"Save\",\n" +
377+
" \"emoji\": true\n" +
378+
" },\n" +
379+
" \"value\": \"1\",\n" +
380+
" \"type\": \"button\",\n" +
381+
" \"action_ts\": \"1606455407.603639\"\n" +
382+
" }\n" +
383+
" ]\n" +
384+
"}";
385+
386+
@Test
387+
public void threaded_message() {
388+
BlockActionPayload payload = GSON.fromJson(jsonInThread, BlockActionPayload.class);
389+
assertThat(payload.getType(), is("block_actions"));
390+
assertThat(payload.getActions().size(), is(1));
391+
assertThat(payload.getContainer().getMessageTs(), is("1693635296.000500"));
392+
assertThat(payload.getContainer().getThreadTs(), is("1693616242.466609"));
393+
394+
assertThat(payload.getState().getValues()
395+
.get("block_1")
396+
.get("action_1")
397+
.getSelectedOption().getValue(),
398+
is("schedule"));
399+
}
325400
}

0 commit comments

Comments
 (0)