# Webhook not triggered on delete event

**URL:** https://meta.discourse.org/t/webhook-not-triggered-on-delete-event/80260
**Category:** Bug
**Created:** [February 10, 2018, 2:40pm UTC](https://meta.discourse.org/t/webhook-not-triggered-on-delete-event/80260 "2018-02-10T14:40:22Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [February 10, 2018, 2:40pm UTC](https://meta.discourse.org/t/webhook-not-triggered-on-delete-event/80260/1 "2018-02-10T14:40:22Z")

</div>

Hi.  
The description of the Post Event is:

> When there is a new reply, edit, deleted or recovered.

However, while it is triggered when adding or editing a reply, the webhook is not triggered when a reply is deleted. Am I missing something?

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [February 10, 2018, 3:47pm UTC](https://meta.discourse.org/t/webhook-not-triggered-on-delete-event/80260/2 "2018-02-10T15:47:39Z")

</div>

(We are on the same team).

Small precision: Discourse 2.0.0.beta2 ; and it would seem `post_recovered` works.

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [February 10, 2018, 3:49pm UTC](https://meta.discourse.org/t/webhook-not-triggered-on-delete-event/80260/3 "2018-02-10T15:49:00Z")

</div>

Name of the post delete event is `post_destroyed`. I guess you are wrongly expecting to receive the webhook for `post_deleted` event.

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [February 10, 2018, 4:06pm UTC](https://meta.discourse.org/t/webhook-not-triggered-on-delete-event/80260/4 "2018-02-10T16:06:53Z")

</div>

Thanks for your answer, I’m not well familiar with Discourse.

Is the webhook should fire `post_destroyed` event once clicked on `delete this post` button? If so, it’s not triggered. `post_recovered` works fine though.

Right now I’m admin and `delete removed posts after` option is set to 0.

Am I missing something?

EDIT: Tried with a regular user and deleting its own post, and nothing happens as well.

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [February 10, 2018, 4:25pm UTC](https://meta.discourse.org/t/webhook-not-triggered-on-delete-event/80260/5 "2018-02-10T16:25:37Z")

</div>

> <https://github.com/discourse/discourse/blob/main/lib/post_destroyer.rb#L49-L54>

As per the above code it should work. Please check recheck your code. If the problem persist I can investigate it on Monday.

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [February 10, 2018, 4:31pm UTC](https://meta.discourse.org/t/webhook-not-triggered-on-delete-event/80260/6 "2018-02-10T16:31:29Z")

</div>

I’ve seen the code, and I’m quite confused as well.

Right now, I’m not checking through some code, I’m looking directly at the Discourse events list.  
I’ve tried many times to make sure I did not miss it, but really nothing happens on post deletion.

Let me know If I can do something to help!

EDIT: I’ve tried to disable any code linked to Discourse (wordpress extension) since I was not sure you would get an event if it fails. I got an event for all except deletion. Not sure what’s happening.

EDIT2: I tried on fresh installation and it still happens, here some screenshots:

 ![image](https://global.discourse-cdn.com/meta/original/3X/1/8/18f803bdec49bc0fd7c87d9ca3cffcd4b3d99ebb.png)  
 ![image](https://global.discourse-cdn.com/meta/original/3X/e/d/ede7460eca4b6444874f161993b56c49a8ac1e34.png)

Event 2, 3, topic creation and first message:

 ![image](https://global.discourse-cdn.com/meta/original/3X/b/7/b7053c9d37dcf9105e162a10478700243f8df564.png)  
 ![image](https://global.discourse-cdn.com/meta/original/3X/e/c/ecd74e2152bffa90ccbc6c0743717b9819e6a31e.png)

A second message:

 ![image](https://global.discourse-cdn.com/meta/original/3X/5/c/5cbd9cc9ea4151086fb4730de78d749ecdfa56ac.png)

Edited the second message:

 ![image](https://global.discourse-cdn.com/meta/original/3X/3/9/39bc4d629891916922cfb5b25cac4162036ca007.png)

I deleted the message as showed in the first screenshot and as you can see, nothing happened.

Once I restored it:

 ![image](https://global.discourse-cdn.com/meta/original/3X/b/8/b8efbf5fead9051473363dc4d424515f01e6616c.png)

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [February 12, 2018, 8:10pm UTC](https://meta.discourse.org/t/webhook-not-triggered-on-delete-event/80260/7 "2018-02-12T20:10:30Z")

</div>

It is now fixed as per the below commit. Can you please confirm by testing it with latest version of code.

[https://github.com/discourse/discourse/commit/e700e3e8821e999e9a989a1d7bc66e4520473031](https://github.com/discourse/discourse/commit/e700e3e8821e999e9a989a1d7bc66e4520473031)

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [February 12, 2018, 9:43pm UTC](https://meta.discourse.org/t/webhook-not-triggered-on-delete-event/80260/8 "2018-02-12T21:43:17Z")

</div>

Thanks, Vinoth! 😀

I’m glad I was not crazy. Finally, I see the event:

 ![image](https://global.discourse-cdn.com/meta/original/3X/f/0/f0eb9fe951683b7a02f06a2906b630d1fcc88863.png)

How it’s possible that no one reported this before!

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [February 12, 2018, 10:55pm UTC](https://meta.discourse.org/t/webhook-not-triggered-on-delete-event/80260/9 "2018-02-12T22:55:32Z")

</div>


