stoiveyp / Slack.NetStandard

.NET Core package that helps with Slack interactions
MIT License
41 stars 16 forks source link

Support legacy attachments #10

Closed stoiveyp closed 4 years ago

stoiveyp commented 4 years ago

It's legacy - and I'd rather just keep support for blocks, but it feels like it may be required https://api.slack.com/reference/messaging/attachments

rasmuskl commented 4 years ago

This is a blocker for me. Attachments is unfortunately the only way of getting the left side colored line in messages that's so wide spread.

The even went so far as to support attachments inside blocks now, so I'm guessing it's not going away any time soon.

stoiveyp commented 4 years ago

Hi @rasmuskl

Not sure I recognise the colored line you're mentioning in your message, certainly not something I rely on in any of my slack groups. Could you post an example image when you get the opportunity? Be good to understand your use case.

I must admit at the moment I rely on https://api.slack.com/methods/files.upload and the equivalent in the library to get attachments into messages. Certainly the files block element isn't reliant on secondary attachments to work, but it's good to know that there's an interest in getting it supported.

Definitely bumps it up my list of outstanding issues, so thank you for reaching out 👍

rasmuskl commented 4 years ago

The green line on the left of this message is made with an attachment and can't be made with blocks.

Example from the link you provided.

image

I was able to work around it by using your client directly with a class like this:

public class PostMessageAttachmentRequest : PostMessageRequest
{
    [JsonProperty("attachments", NullValueHandling = NullValueHandling.Ignore)]
    public List<Attachment> Attachments { get; set; } = new List<Attachment>();
}

public class Attachment
{
    [JsonProperty("color", NullValueHandling = NullValueHandling.Ignore)]
    public string Color { get; set; }

    [JsonProperty("blocks", NullValueHandling = NullValueHandling.Ignore)]
    public List<IMessageBlock> Blocks { get; set; } = new List<IMessageBlock>();
}
stoiveyp commented 4 years ago

That's a great example - thank you @rasmuskl! Not something I've ever noticed, but if you rely on it then that'd be a big difference certainly.

Appreciate you taking the time, thank you :+1:

stoiveyp commented 4 years ago

Fixed in 2.1.0