Members not receiving emails from Watched category

Hi. Is there a way to override the existing users deliberate choice ?

I tried UserOption.update_all(default_categories_watching: <id>) and UserOption.update_all(watched_categories: <id>) but these are not user options…

EDIT and solution: User.all.each do |user| CategoryUser.batch_set(user, :watching, [<id>]) end

1 Like

It is possible to do it through the rails console (and also the API too), but I would consider carefully whether you should or not. If a user has deliberately made a choice to Watch or Mute a category (or tag or topic) then overriding that choice is likely going to be undesired. They can also simply flick it back to what it was, so you may not gain anything.

2 Likes

Thanks for the answer. I fully agree. Though in our case, it is to solve a current issue I described here: Favor activity summary posts from certain category.

The idea is to roll back the new default setting (watching a certain category) and then let people change it as they wish.

I noticed now that the above command User.all.each do |user| CategoryUser.batch_set(user, :watching, [<id>]) end somehow did not work to change the preferences for all users. Any idea why ? Even better would be to append the new tracking preference to the existing user tracking preferences…

P.S. we’re a tiny community and I know that only an even smaller fraction took the time to adjust their preferences (;

1 Like

For anyone who hasn’t specifically set a category at a notification level, resetting the default category watching and applying it historically should reset those to normal levels.

If the numbers are small, using the UI or API may be a safer bet than the rails console. How many people are we talking about?

1 Like

For understanding, the category in question is named Announcements and its ID is 22.

I did exactly this before also trying the command. But still after both, at a new post in Announcements, only some users get sent an email.
What could have happened is that users unsubscribed from the email notifications because the digest email only contained “minor” activity (i.e. no posts from Announcements as described in the related issue linked to previously)

60

1 Like

Do you have the data explorer installed? If so, have you got a query to see how many of your users don’t have the right tracking and/or email preference?

2 Likes

Good idea. I’ll do that when having a bit more time !

Smaller in immediate effort, a rails script to reset the necessary parameters for all users would make me happy as well.

1 Like

I think we need to know a little more detail before working out a solution. The category_users table only keeps a record of active category notification levels, so if someone doesn’t have one then the data won’t be in the table to change via the rails console. (for instance, if I add #site-feedback to the default categories watching admin setting it will add a record in category_users for each user, and when I reset the setting it will delete those records again).

2 Likes

I can confirm that User.all.each do |user| CategoryUser.batch_set(user, :watching, [22]) changed the tracking preferences of all users to watch the desired category (22 | Announcements); as this query lists all the users:

SELECT *
FROM category_users 
WHERE category_id = '22' AND notification_level = '3'

And this query lists only 1 user:

SELECT *
FROM user_options uo
WHERE uo.email_level = '2'

The question is now, why so many users don’t get an email sent when there’s a new post in category 22 “Announcements” :thinking:

P.S. I tinker around for the SQL queries and don’t know how to join them.

Hi. I did not find a solution yet. I can’t get my head around of the necessary user preferences to receive post notification emails for watched topics. Any idea ? Thx !