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.

3 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 !

Hi @JammyDodger

Just in case, I’m still inquiring and trying to solve this issue. I isolated the settings of one of our users which has the default settings of watching a certain category (‘Announcements’) but who does not receive e-mail notifications for new posts:

user mailing_list_mode email_digests external_links_in_new_tab enable_quoting dynamic_favicon automatically_unpin_topics digest_after_minutes auto_track_topics_after_msecs new_topic_duration_minutes last_redirected_to_top_at email_previous_replies email_in_reply_to like_notification_frequency mailing_list_mode_frequency include_tl0_in_digests notification_level_when_replying theme_key_seq allow_private_messages homepage theme_ids hide_profile_and_presence text_size_key text_size_seq email_level email_messages_level title_count_mode_key enable_defer timezone enable_allowed_pm_users dark_scheme skip_new_user_tips color_scheme default_calendar oldest_search_log_date chat_enabled only_chat_push_notifications chat_sound dismissed_channel_retention_reminder dismissed_dm_retention_reminder bookmark_auto_delete_preference ignore_channel_wide_mention chat_email_frequency enable_experimental_sidebar seen_popups chat_header_indicator_preference sidebar_link_to_filtered_list sidebar_show_count_of_new_items watched_precedence_over_muted chat_separate_sidebar_mode topics_unread_when_closed show_thread_title_prompts
JohnDoe false true true true false true 10080 240000 2880 2023-06-13T08:25:13.000Z 1 false 1 1 true 2 0 true NULL {} false 0 0 1 1 0 false Europe/Somwhere false NULL false NULL 0 NULL true NULL NULL NULL NULL 3 NULL 1 false {1,2,3,4,5} 0 false false NULL 0 true true

I really can’t see why this issue arises because this is the user’s line when I query the users watching category ‘Announcements’:

id category user notification_level last_seen_at
123 Announcements JohnDoe 3 NULL

Are there any other settings I am missing ? Could it be that the user clicked unsubscribe in one of the notification emails and that changed their email settings ?

Thanks !

Clicking the “unsubscribe” link from a notification email takes a user to a page where they can alter their notification preferences. For example:

If a user selected either the “stop watching all topics in the <category_name> category” or the “Don’t send me any mail from Discourse” options, you will see the changes on their preferences page. Either the category will have been removed from their watched category list, or their email preferences will be changed so that all settings on their email page will be set to “never”.

It’s more difficult to see the change if the user selected the “stop watching this topic” option. In that case, you could impersonate the user from their admin page, then visit the topic to see if their notification level for the topic has changed from “watching” to “tracking”. You can also get the information about their notification level for the topic from the Rails console:

Before getting too caught up in this, go to the site’s Skipped Email Logs page. You can navigate to it from the admin sidebar. Enter the user’s email into the “To Address” field that’s at the top of the page. It might show you details about why the particular email was not sent to the user.

3 Likes

Thanks for the reply.

I checked the skipped email section. There are only “User was seen recently”, “Mailing list notifications disabled for user’s own posts” and “Exceeded bounce_score_threshold” cases.

I was wondering if there’s a possibility to change the settings for all users along one of the following ways:

  • Change the setting of all users “as if” they just signed up.
  • or: I make a new test user and use these settings to paste them to all other existing users.

There is the “default categories watching” site setting. If you change it, you’ll be given the option to apply the changes historically. Selecting that option will update the preferences for all users except for users who have explicitly configured their preference for that category on their preferences page. I think that’s the issue you are trying to get around. You could probably deal with that from the Rails console, but I’d probably avoid that approach.

You could just create a new category for announcements and add that category to your site’s “default categories watching” site setting. You could then tidy up the site by moving topics from the old announcements category to the new one. If you want to keep the category name “announcements”, start by renaming the original “announcements” category to something else. I realize this is a bit of a hack, but it’s a way to resolve the issue without touching the Rails console.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.