Category Watched/Tracked by default


(Daniela) #1

In admin > settings > user preference I set a list of categories that are watched by default.
After a few days I change settings and I moved the list in “default categories tracking”.

In User Profile I can see the list of categories is still under “watched” and not “tracking”.

The change is not real-time?


Default tags watching/tracking/muted
How to disable watched/tracked category on users profile?
(Régis Hanol) #2

Nope. It’s not retro-active either. It’s only for new users.


(Daniela) #3

It’s very bad.
I thought it’s not retro-active only for posts and topics created under categories watched/tracked as long as they are watched or tracked.

So, all my old users continued to receive emails from the same categories… until they do not change settings in their profiles :scream:

You want to kill me… :notsureif:


(Albert Westra) #4

Is there a way we can reapply those options to the current users? Our discourse site has a NSFW category and I need to apply it as a default muted category.


(Régis Hanol) #5

You will have to do it via the rails console.


(Albert Westra) #6

I’m a complete nood with it comes to the rails console and ruby in general. So could you expand on how I can do this?


(Régis Hanol) #7

SSH into your server (as root) and then

cd /var/discourse
./launcher enter app
rails c

You are now inside the rails console on your server.

# find the category you're interested in
nsfw_category = Category.find_by(name: "name of your category")
# mute this category for all users
CategoryUser.where(category: nsfw_category).update_all(notification_level: TopicUser.notification_levels[:muted])

Override existing user preferences
(Albert Westra) #8

Thank you, this really help me a bunch!


(Felix Freiberger) #9

I think this no longer works (or never worked) because the category_users table is blank by default, so the CategoryUser.where finds only users who manually changed the level before.

How can I insert the necessary entries?


(Felix Freiberger) #10

To self-answer my question: I ended up running

User.all.each do |user| CategoryUser.set_notification_level_for_category(user, CategoryUser.notification_levels[:watching], announce_category.id) end

(Nick Putman) #11

I have tried both methods above to add categories to all users ‘Tracked’ settings, without success, getting different errors in the rails console. I am wondering what needs to change to get this working?