Closed KeesCBakker closed 2 years ago
When I do the following, it seems to work and the data is showing up:
public class PostMessageRequest<T> : PostMessageRequest
{
[JsonProperty("metadata", DefaultValueHandling = DefaultValueHandling.Ignore)]
public MetaData<T>? MetaData { get; set; }
}
public class UpdateMessageRequest<T> : UpdateMessageRequest
{
[JsonProperty("metadata", DefaultValueHandling = DefaultValueHandling.Ignore)]
public MetaData<T>? MetaData { get; set; }
}
public class MetaData<T>
{
[JsonProperty("event_type")]
public string EventType { get; set; } = String.Empty;
[JsonProperty("event_payload")]
public T? EventPayLoad { get; set; }
}
Look like it is showing up when I click on the button of a block:
https://user-images.githubusercontent.com/583193/184470097-be25c63d-38bd-43cb-8598-889331956467.mp4
Hi @KeesCBakker - on my phone so I'll try and put links in later, but as metadata is an open beta, it's only available in the pre-release versions of the library.
If you update to any beta version since the feature was announced, you should see a Metadata property has been added to the relevant objects and web API methods
Appreciate you reaching out. I need to get a better change log in place now the library is big enough so this kind of thing is more discoverable, will add it to my list 👍
Back on my laptop now 😁
So the MessageMetadata
class is what I've added:
https://github.com/stoiveyp/Slack.NetStandard/blob/beta/Slack.NetStandard/Messages/MessageMetadata.cs
That's on the Message object for the data returned: https://github.com/stoiveyp/Slack.NetStandard/blob/beta/Slack.NetStandard/Messages/Message.cs#L84
And for sending it out, I think all the chat methods rely on MessageRequestBase
which has Metadata here:
https://github.com/stoiveyp/Slack.NetStandard/blob/beta/Slack.NetStandard/WebApi/Chat/MessageRequestBase.cs#L46
Now interestingly one thing that was lacking when the feature was first announced was the schema for the metadata events such as message_metadata_updated
( https://api.slack.com/events/message_metadata_updated ) and that looks like that's been corrected now - so I'm going to keep this open until I've had chance to update the event API classes 👍
I've looked at the beta package, but it looks like the Metadata
property is missing from the UpdateMessageRequest
: https://github.com/stoiveyp/Slack.NetStandard/blob/beta/Slack.NetStandard/WebApi/Chat/UpdateMessageRequest.cs
It does not inherit from MessageRequestBase
(PostMessageRequest
does).
Both the metadata events and the UpdateMessageRequest have been updated as of v5.2.0-beta4 Thanks for raising this 👍
The chat postMessage and update Slack API endpoints now includes a new metadata field. This field can be used to attach more information to your chat messages. Will these fields be added to the package as wel?
Keep up the good work!
API docs: https://api.slack.com/methods/chat.postMessage https://api.slack.com/methods/chat.update
More info on metadata: https://api.slack.com/metadata https://api.slack.com/metadata/publishing#defining-metadata-defining