Creating a topic or a post sends the user_updated webhook

AI-generated summary

A bug was reported where creating a topic or post triggers the user_updated webhook, which users like codinghorror and simon found unexpected — they expected it to fire only when user preferences are changed, ideally by the user themselves. watchmanmonitor suggested it should also trigger for badge and group membership changes, which simon agreed would be useful. codinghorror labeled this a regression and asked tgxworld to investigate. tgxworld traced the issue to a Rails 5-related change that broadened the user_updated trigger to any column change, and proposed filtering against UserUpdated::OPTION_ATTR. zogstrip clarified that the group-tracker plugin only needed primary_group_id, so the constant would need updating. The issue was resolved in commit 19f3b81 and a corresponding fix in the group-tracker plugin commit 36fd0de. Additional observations included webhooks firing on login/logout and SSO user creation (sending three webhooks: user_created, then two user_updated events).

If a User Event webhook is activated, creating a topic or a post sends the user_updated webhook. Tested on the latest Discourse.

3 curtidas

Well I guess we are assuming that something like “last posted at” just changed and pushing that across.

3 curtidas

That is a very odd interpretation of the meaning, I would expect only a user preference was updated. Possibly by the user only.

1 curtida

I’d also expect a webhook when badge & group memberships are changed.

1 curtida

This is how it used to work.

This would be very useful.

1 curtida

Hmm this is a regression then – who touched webhooks last @tgxworld?

1 curtida

Not me, Rails 5 touched it :stuck_out_tongue:

I’ll have a look

5 curtidas

A user webhook is also being sent when a user logs in or out. Creating a user through SSO is sending 3 user webhooks. First a user_created one for the new user. Then user_updated for the same user, then user_updated for the discobot. This is tested on a live version of Discourse.

It looks like the behavior of the user_updated event was changed in

https://github.com/discourse/discourse/commit/519b70ea4692834638e4b95c92b81a2160621681

which triggers as long as a column on the user is changed. @zogstrip Do we need all the columns to trigger the event? If not I’ll add a a filter that checks the columns which have changed against the UserUpdated::OPTION_ATTR constant.

5 curtidas

I needed it for the group-tracker plugin

In that case I only need the primary_group_id so UserUpdater::OPTION_ATTR will have to be updated.

4 curtidas

Fixed in

https://github.com/discourse/discourse/commit/19f3b8116150c3692e8bd4349cdb3708621a2ddd
https://github.com/discourse/discourse-group-tracker/commit/36fd0ded022ab7b62dba6d840658576f64d57a7b

7 curtidas