shakeel
shakeel

Reputation: 901

How can i disable the close icon on attachments?

I am trying to post messages to slack https://api.slack.com/methods/chat.postMessage/test

i am adding attachment [{"pretext": "pre-hello", "text": "text-world"}]

but in slack channel UI i am seeing close icon, if i click close icon i can able to remove attachment

enter image description here

How can i disable close icon, so that no one can't delete attachments?

Upvotes: 5

Views: 964

Answers (2)

Anthony B
Anthony B

Reputation: 96

There is a workaround if you remove "text" node, attachments can't be deleted. So you can put "pretext" on first attachment to have same behavior.

Here you can delete attachements (Sample)

{
    "text": "Hello",
    "attachments": [
        {
            "text": "Hello World"
        },
        {
            "text": "Hello World"
        }
    ]
}

Here, you have the same message but without close icons this time (Sample)

{
    "attachments": [
        {
            "pretext": "Hello",
            "text": "Hello World"
        },
        {
            "text": "Hello World"
        }
    ]
}

Upvotes: 7

Erik Kalkoken
Erik Kalkoken

Reputation: 32852

You can not disable the close icon for attachments. But: Only those members will actually see the close icon, which also have the permission to delete the whole message. Depending on workspace settings only the message owner and members with admin / owner role can delete a message.

So, most Slack users will not be able to delete attachments posted by your app.

Upvotes: 2

Related Questions