Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions json-logs/samples/events/LinkSharedPayload.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
}
],
"is_bot_user_member": false,
"unfurl_id": "",
"source": "",
"event_ts": ""
}
}
2 changes: 2 additions & 0 deletions json-logs/samples/rtm/LinkSharedEvent.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@
}
],
"is_bot_user_member": false,
"unfurl_id": "",
"source": "",
"event_ts": ""
}
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,7 @@ public static FormBody.Builder toForm(ChatUnfurlRequest req) {
setIfNotNull("user_auth_message", req.getUserAuthMessage(), form);
setIfNotNull("user_auth_blocks", req.getUserAuthBlocks(), form);
setIfNotNull("user_auth_url", req.getUserAuthUrl(), form);
setIfNotNull("unfurl_id", req.getUnfurlId(), form);
return form;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public class ChatUnfurlRequest implements SlackApiRequest {
*/
private String channel;

// https://api.slack.com/changelog/2021-08-changes-to-unfurls
private String unfurlId;

// https://api.slack.com/docs/message-link-unfurling#unfurls_parameter
@Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@ public class LinkSharedEvent implements Event {
public static final String TYPE_NAME = "link_shared";

private final String type = TYPE_NAME;
private String channel;
private String channel; // This can be "COMPOSER"
private String user;
private String messageTs;
private String threadTs;
private List<Link> links;
@SerializedName("is_bot_user_member")
private boolean botUserMember;

// https://api.slack.com/changelog/2021-08-changes-to-unfurls
private String unfurlId;
// https://api.slack.com/changelog/2021-08-changes-to-unfurls
private String source; // "composer" / "conversations_history"

private String eventTs;

@Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,34 @@ public void serialize() {
assertThat(generatedJson, is(expectedJson));
}

@Test
public void newUnfurls_2021_08() {
// https://api.slack.com/changelog/2021-08-changes-to-unfurls
String json = "{\n" +
" \"type\": \"link_shared\",\n" +
" \"channel\": \"COMPOSER\",\n" +
" \"is_bot_user_member\": true,\n" +
" \"user\": \"Uxxxxxxx\",\n" +
" \"message_ts\": \"Uxxxxxxx-909b5454-75f8-4ac4-b325-1b40e230bbd8-gryl3kb80b3wm49ihzoo35fyqoq08n2y\",\n" +
" \"unfurl_id\": \"Uxxxxxxx-909b5454-75f8-4ac4-b325-1b40e230bbd8-gryl3kb80b3wm49ihzoo35fyqoq08n2y\",\n" +
" \"source\": \"composer\",\n" +
" \"links\": [\n" +
" {\n" +
" \"domain\": \"example.com\",\n" +
" \"url\": \"https://example.com/12345\"\n" +
" },\n" +
" {\n" +
" \"domain\": \"example.com\",\n" +
" \"url\": \"https://example.com/67890\"\n" +
" },\n" +
" {\n" +
" \"domain\": \"another-example.com\",\n" +
" \"url\": \"https://yet.another-example.com/v/abcde\"\n" +
" }\n" +
" ]\n" +
"}\n";
LinkSharedEvent event = GsonFactory.createSnakeCase().fromJson(json, LinkSharedEvent.class);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

FYI: This GsonFactory (for testing) detects unknown fields. If there is some, the test fails. Adding unfurlId & source made this test successful.

assertThat(event.getType(), is("link_shared"));
}

}