Force category watching based on group membership only once

סיכום מבוסס בינה מלאכותית

The discussion revolves around the topic “Force category watching based on group membership only once.” tophee is seeking a solution to make users watch a category based on their group membership only once, allowing them to unwatch the category later if desired. Currently, there is a plugin that forces users to watch a category based on group membership, but it does not allow users to unwatch the category.

tophee suggests modifying the existing plugin to achieve this functionality, possibly by maintaining a table to track which categories a user has watched. However, sam proposes a simpler solution, utilizing an event fired when a user is added to a group to perform a one-time addition, eliminating the need for complex tracking.

Continuing the discussion from Ability to force subscription to a category:

There is a solution for making all new users watch a category by default (and users can change that as they like).

There is also a solution to force users to watch a category based on their group membership (and users are not able to permanently unwatch that category as long as they are a member of the group that triggered the watching).

What I am missing is the ability to make users watch a category based on group membership once (i.e. when they join the group) but not enforce if they choose to untwatch. I suppose this would be a matter of extending this plugin to make sure that every user is forced into watching any particular category only once:

https://github.com/amical/discourse-watch-category

Or is there an easier way?

לייק 1

Another useful modification of this plugin would be to apply it only to each user’s primary group. How would I do that? @techAPJ @alehandrof

Oh, and here is another idea that does not require any code changes, but would it work? What if I include various private categories in default categories watching first post, will that entail that whenever a user first acquires access to that category (by joining a specific group) s/he will be made to watch that category?

This is going to require a plugin of sorts.

I talked about workflows here interestingly enough:

You are going to need a plugin for now.

לייק 1

I suspected that. And luckily, there is already one that makes people watch based on group membership. So what would it take to modify that so that when a users unwatch a force-watched category they will not be re-forced to watch it?

I suppose the plugin would have to maintain a table that keeps track of which categories a user has ever been watching and check against that table before making any user watch a particular category (if that user-category combination is in the table, don’t force-watch). Right?

I think we have an event that is fired when a user is added to a group so you would subscribe to that and just do the once off adding there. No need then to worry about tracking anything fancy to catch the 0.01% edge cases.

לייק 1