Skip to content

Commit

Permalink
Add threadTs to BlockActionPayload.Container
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinbunney authored and seratch committed Sep 4, 2023
1 parent fac13fc commit fe0e59b
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public static class Container {
@SerializedName("is_app_unfurl")
private boolean appUnfurl;
private String appUnfurlUrl;
private String threadTs;
}

@Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,4 +322,79 @@ public void deserialize_app_unfurl() {
}



String jsonInThread = "{\n" +
" \"type\": \"block_actions\",\n" +
" \"user\": {\n" +
" \"id\": \"U111\",\n" +
" \"username\": \"seratch\",\n" +
" \"name\": \"seratch\",\n" +
" \"team_id\": \"T111\"\n" +
" },\n" +
" \"api_app_id\": \"A111\",\n" +
" \"token\": \"xxx\",\n" +
" \"container\": {\n" +
" \"type\": \"message\",\n" +
" \"message_ts\": \"1693635296.000500\",\n" +
" \"thread_ts\": \"1693616242.466609\",\n" +
" \"channel_id\": \"C111\",\n" +
" \"is_ephemeral\": true\n" +
" },\n" +
" \"trigger_id\": \"111.222.xxx\",\n" +
" \"team\": {\n" +
" \"id\": \"T111\",\n" +
" \"domain\": \"xxx\"\n" +
" },\n" +
" \"channel\": {\n" +
" \"id\": \"C111\",\n" +
" \"name\": \"random\"\n" +
" },\n" +
" \"state\": {\n" +
" \"values\": {\n" +
" \"block_1\": {\n" +
" \"action_1\": {\n" +
" \"type\": \"external_select\",\n" +
" \"selected_option\": {\n" +
" \"text\": {\n" +
" \"type\": \"plain_text\",\n" +
" \"text\": \"Schedule\",\n" +
" \"emoji\": true\n" +
" },\n" +
" \"value\": \"schedule\"\n" +
" }\n" +
" }\n" +
" }\n" +
" }\n" +
" },\n" +
" \"response_url\": \"https://hooks.slack.com/actions/T111/111/xxx\",\n" +
" \"actions\": [\n" +
" {\n" +
" \"action_id\": \"save\",\n" +
" \"block_id\": \"block_1\",\n" +
" \"text\": {\n" +
" \"type\": \"plain_text\",\n" +
" \"text\": \"Save\",\n" +
" \"emoji\": true\n" +
" },\n" +
" \"value\": \"1\",\n" +
" \"type\": \"button\",\n" +
" \"action_ts\": \"1606455407.603639\"\n" +
" }\n" +
" ]\n" +
"}";

@Test
public void threaded_message() {
BlockActionPayload payload = GSON.fromJson(jsonInThread, BlockActionPayload.class);
assertThat(payload.getType(), is("block_actions"));
assertThat(payload.getActions().size(), is(1));
assertThat(payload.getContainer().getMessageTs(), is("1693635296.000500"));
assertThat(payload.getContainer().getThreadTs(), is("1693616242.466609"));

assertThat(payload.getState().getValues()
.get("block_1")
.get("action_1")
.getSelectedOption().getValue(),
is("schedule"));
}
}

0 comments on commit fe0e59b

Please sign in to comment.