-
Notifications
You must be signed in to change notification settings - Fork 228
Description
We've recently upgraded our Slack SDK client from version 1.7.1 to the latest version, 1.43.1, and observed some changes in the behavior of the previous_message field within the MessageChangedEvent.
Previously, we could access the user for messages with a tombstone subtype using:
message.getEvent().getPreviousMessage().getUser()
However, in the new version, we are now required to fetch the user like this:
message.getEvent().getPreviousMessage().getMessage().getUser()
The issue is that the previous_message object within the Slack event payload doesn’t contain a Message object directly, which impacts our current implementation.
Below is a sample event payload for your reference:
{
"context_team_id": "T06SV65C",
"event_id": "Ev07RF",
"authorizations": [
{
"enterprise_id": null,
"team_id": "T06SV6",
"user_id": "U06SSJ",
"is_bot": true,
"is_enterprise_install": false
}
],
"api_app_id": "A01JP",
"team_id": "T06SV6",
"event": {
"type": "message",
"subtype": "message_changed",
"message": {
"subtype": "tombstone",
"text": "This message was deleted.",
"user": "USLACKBOT",
"hidden": true,
"type": "message",
"thread_ts": "1728639839.746989",
"reply_count": 1,
"reply_users_count": 1,
"latest_reply": "1728639845.335099",
"reply_users": ["U06SSK"],
"is_locked": false,
"ts": "1728639839.746989"
},
"previous_message": {
"user": "U06TFGNC",
"type": "message",
"ts": "1728639839.746989",
"client_msg_id": "22b850d7_f2f3bd548f9e",
"text": "need help with VPN",
"team": "T06SCC",
"thread_ts": "1728639839.746989",
"reply_count": 1,
"reply_users_count": 1,
"latest_reply": "1728639845.335099",
"reply_users": ["U0UK"],
"is_locked": false,
"subscribed": true,
"last_read": "1728639845.335099",
"blocks": [
{
"type": "rich_text",
"block_id": "x18EO",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "need help with VPN"
}
]
}
]
}
]
},
"channel": "D0697V",
"hidden": true,
"ts": "1728639909.003400",
"event_ts": "1728639909.003400",
"channel_type": "im"
},
"type": "event_callback",
"event_context": "4-eyJldCI6Im1lc3NhZ2UiLCJ0aW",
"is_ext_shared_channel": false,
"context_enterprise_id": null,
"event_time": 1728639909,
"token": "Wd",
"applicationImpl": {},
"tp": "00-b967128fd27ab440b35c880f8120cfe1-5b92cc62c18764b1-00",
"trace_id": "b967128fd27ab440b35c880f8120cfe1"
}In the above payload, the previous_message should have the message object, which we are not receiving
Additionally, here is the MessageChangedEvent class for context:
public class MessageChangedEvent implements Event {
public static final String TYPE_NAME = "message";
public static final String SUBTYPE_NAME = "message_changed";
private final String type = "message";
private final String subtype = "message_changed";
private String channel;
private boolean hidden;
private Message message;
private PreviousMessage previousMessage;
private String eventTs;
private String ts;
private String channelType;
public static class PreviousMessage {
private Message message;
public static class Message {
private String clientMsgId;
private final String type = "message";
private String subtype;
private String user;
private String team;
private String botId;
private BotProfile botProfile;
private MessageEvent.Edited edited;
private String text;
private List<LayoutBlock> blocks;
private List<Attachment> attachments;
}
}
}Could you provide further guidance on handling these changes, and whether there are updated methods to access user data in previous_message more effectively?