Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 644
shakeel Avatar asked Jan 28 '23 06:01

shakeel


2 Answers

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"
        }
    ]
}
like image 69
Anthony B Avatar answered May 16 '23 06:05

Anthony B


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.

like image 39
Erik Kalkoken Avatar answered May 16 '23 08:05

Erik Kalkoken