Repository navigation
Adding PreviousMessage to MessageDeleted, UserTeam and SourceTeam to message events, and MetadataJson to MessageUpdate - #264
Merged
soxtoby merged 3 commits intoOct 13, 2026
Conversation
Owner
|
Thanks again, @we4sz - looks good. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three fields that Slack sends or accepts have no property in SlackNet 0.18.0. I ran into them building an app on SlackNet: the first two I read through
Event.ExtraProperties, the third by callingchat.updatethroughISlackApiClient.Postwith the arguments ofChatApi.Updatecopied in. This models them. It is three commits, each one builds and passes the tests.MessageDeleted.PreviousMessage(previous_message), the same propertyMessageChangedhas. It is how an app tells who wrote a message that was deleted.MessageEventBase.UserTeam(user_team) andSourceTeam(source_team), next to the existingTeam. They appear on messages from a channel that is shared between workspaces, and tell which workspace the sender belongs to.MessageEvent,MessageChanged's two messages,MessageDeletedandAppMentionall inherit them.MessageUpdate.MetadataJsonandMetadataObject, the same two propertiesMessagehas, sent byChatApi.Updateasmetadata. Slack'schat.updateacceptsmetadata, so today an edit can't set or replace a message's metadata.Compatibility
Additive only. The new properties default to null, and
ChatApi.Updatesendsmetadataonly when one of the two is set, so an existing call produces the same request as before.MetadataJsontakes precedence overMetadataObject, as it does onMessage.Testing
The tests follow the existing patterns: event deserialization from Slack-shaped JSON (with and without the new fields, and the field no longer landing in
ExtraProperties), and the request body ofChatApi.Updatewith no metadata, withMetadataJson, withMetadataObject, and with both. The whole suite passes exceptUtilsTests.ToDateTime_FromTimestampString_ValidTimestamp_ReturnsDateTime, which fails on an untouched v0.18.0 here as well.I built an app against a local pack of this branch and its tests pass with the three properties replacing the workarounds.
Not verified: I did not capture these payloads from a live workspace for this PR, so the JSON in the tests follows the shapes the app already handles and what the documentation says, which is limited:
chat.updatedocuments themetadataargument (a JSON object withevent_typeandevent_payload). Omitted, the message's previous metadata is retained; an empty object removes it. This commit only adds a way to send it.message_deleteddoesn't listprevious_message.MessageChangedalready models it, so I modelled it the same way;PreviousMessageis null when Slack sends none, and a test covers that.user_teamorsource_teamdescribed on the message event pages or the Slack Connect pages. slack-go models both on itsAppMentionEventwith the comment "When Message comes from a channel that is shared between workspaces". I couldn't tell from the documentation what separates the two, so the doc comments only say when they are sent.