Skip to content

Adding PreviousMessage to MessageDeleted, UserTeam and SourceTeam to message events, and MetadataJson to MessageUpdate - #264

Merged
soxtoby merged 3 commits into
soxtoby:masterfrom
we4sz:message-event-gaps-and-update-metadata
Oct 13, 2026
Merged

soxtoby merged 3 commits into
soxtoby:masterfrom
we4sz:message-event-gaps-and-update-metadata

Conversation

@we4sz

@we4sz we4sz commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

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 calling chat.update through ISlackApiClient.Post with the arguments of ChatApi.Update copied in. This models them. It is three commits, each one builds and passes the tests.

  1. MessageDeleted.PreviousMessage (previous_message), the same property MessageChanged has. It is how an app tells who wrote a message that was deleted.
  2. MessageEventBase.UserTeam (user_team) and SourceTeam (source_team), next to the existing Team. 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, MessageDeleted and AppMention all inherit them.
  3. MessageUpdate.MetadataJson and MetadataObject, the same two properties Message has, sent by ChatApi.Update as metadata. Slack's chat.update accepts metadata, so today an edit can't set or replace a message's metadata.

Compatibility

Additive only. The new properties default to null, and ChatApi.Update sends metadata only when one of the two is set, so an existing call produces the same request as before. MetadataJson takes precedence over MetadataObject, as it does on Message.

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 of ChatApi.Update with no metadata, with MetadataJson, with MetadataObject, and with both. The whole suite passes except UtilsTests.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.update documents the metadata argument (a JSON object with event_type and event_payload). Omitted, the message's previous metadata is retained; an empty object removes it. This commit only adds a way to send it.
  • The reference example for message_deleted doesn't list previous_message. MessageChanged already models it, so I modelled it the same way; PreviousMessage is null when Slack sends none, and a test covers that.
  • I couldn't find user_team or source_team described on the message event pages or the Slack Connect pages. slack-go models both on its AppMentionEvent with 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.

@soxtoby

soxtoby commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Thanks again, @we4sz - looks good.

@soxtoby
soxtoby merged commit 9f5c0fd into soxtoby:master Oct 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants