Webhooks don't function properly when moderator approval is enabled

AI-generated summary

The discussion revolves around an issue with webhooks not functioning properly when moderator approval is enabled on a Discourse forum. jordan1909 encountered this problem, where webhooks on post or topic actions do not fire 99.9% of the time when moderator approval is enabled for users with a trust level (TL) of 2 or less. However, when a TL 3 user creates or edits a post, a webhook is triggered immediately.

simon tested this in their development environment and found that when a post is approved, it sends a Post Event webhook, and when a topic is approved, it sends a Topic and a Post Event webhook. jordan1909 shared screenshots of their webhook settings and confirmed that they are not seeing any errors in the events list.

simon asked if there were any errors in the Discourse logs, but jordan1909 found none. codinghorror inquired about the Discourse version, which is v1.9.0.beta17 +80.

jordan1909 performed tests, which showed that the issue is directly tied to topics that require approval. tgxworld ultimately fixed the issue in two commits to the Discourse GitHub repository.

Related Commits:

I am using webhooks as I’ve mentioned in other threads here.

I’ve noticed a bug however in this and I’d like to understand if its by design or other.

On our install we use moderator approval on posts if the TL is 2 or less. In my testing however I have noticed that with this feature enabled, the webhooks on post or topic actions do not fire 99.9% of the time.

The biggest confusion for me is a few randomly fire but the bulk majority do not. I could potentially wrap my head around all not going or all going but a few here or there going and the rest not is confusing me.

Can anyone think of a reason webhooks wouldn’t fire when we approve moderated posts? I’ve tried all variations including send me everything to no success.

Which webhook are you looking for? Topic creation?

I was testing this in my development environment yesterday. When a post is approved it is sending a Post Event webhook, when a topic is approved it is sending a Topic and a Post Event webhook. This is working consistently for me. Are you seeing any errors in the events list for the webhook?

3 « J'aime »

@simon @codinghorror

Sorry for the delay, I went afk for the holidays. I am still able to replicate this. When I get a chance I will make a quick video in the hopes someone spots a mistake.

Basically nothing is being triggered after approving topic. I am seeing no errors in the events list for the webhook either.

As you can see below I have pretty much set it to send me everything though I have tried limiting to just topic and post actions as well.

When I checked today the last webhook event that executed since 12/22 was for a ping that I sent using the ping button. Though the site has been pretty active since then.

When I can I will create a video of this in action. In the hopes someone has an idea why they are missing.

1 « J'aime »

After you approve a topic or a post, do you see any errors in the Discourse logs? (Admin/Logs/Error Logs)

Literally nothing, its almost as if they aren’t enabled but they definitely are. I can actually replicate this in my development and production environments.

What version of Discourse are you on? View source to see.

I was thinking that the issue was the webhook not being sent after a post or topic is approved, but it sounds as though the issue is affecting all webhook events on your forum. What happens when a TL 3 user creates or edits a post? If you reset the moderator approval settings to their defaults, does the problem go away?

I am on v1.9.0.beta17 +80


If a user of TL 3 or higher creates or edits a post a webhook is triggered immediately. If I reset moderator approval it does in fact go away. So it seems to be directly tied into topics that require approval.

Tests:

Tests were done with a moderation required level of 2 or less.


Test Moderation Required Successful
Create topic with TL > 3 No Yes. Webhook successfully triggered.
Create Topic with TL < 3 Yes Sporadically. This was strange but out of 10 runs
3 successfully triggered a webhook but the rest did not.
Reply to Topic with TL >= 3 No Yes. Webhook successfully triggered.
Reply to Topic with TL < 3 Yes No. No webhook is triggered.
Private Message (any TL) No Yes. Webhook successfully triggered.
Topic deleted No Yes. Webhook successfully triggered.
Topic edited TL >= 3 No Yes. Webhook successfully triggered.
Topic edited TL <= 3 No Yes. Webhook successfully triggered.

Videos:

  1. Creating a topic with TL of 3 or higher.




2. Creating a topic with TL of 2 or less.

  1. Replying with a topic of TL of 3 or higher
  1. Replying with a topic of TL of 2 or less



EDIT: Not sure why my videos are being wonky but they work when you paste them directly.

3 « J'aime »

@tgxworld can you have a look at this?

3 « J'aime »

Fixed in

https://github.com/discourse/discourse/commit/ad024373580531021e64ef1d695d9c1b8e1bdc61

and I also found another bug while looking through the code

https://github.com/discourse/discourse/commit/9644569a289ac9244c67ae9de5a1e183d669b133

8 « J'aime »

This topic was automatically closed after 3 days. New replies are no longer allowed.