User group 'muted categories' not updating members category notifications

Whenever I update the muted categories on a user group and say yes to ‘update existing users?’, it does not seem to update. For instance, see this user, #8, who is a member of group #42, but is missing a lot of category_user rows:

SQL RESULTS
  • Confirm user #8’s group membership in #42
SELECT gu.*, g.name
FROM group_users gu
JOIN groups g ON gu.group_id = g.id
WHERE user_id=8 and gu.group_id = 42;
  id  | group_id | user_id |         created_at         |         updated_at         | owner | notification_level |     first_unread_pm_at     |       name        
------+----------+---------+----------------------------+----------------------------+-------+--------------------+----------------------------+-------------------
 4207 |       42 |       8 | 2023-07-03 11:36:43.828233 | 2023-07-03 11:36:43.828233 | f     |                  3 | 2023-12-29 22:52:43.371588 | japanese-learners
  • Show current user #8’s notification levels
SELECT cu.*, c.name, c.parent_category_id
FROM category_users cu
JOIN categories c ON cu.category_id = c.id
WHERE cu.user_id = 8;
  id   | category_id | user_id | notification_level | last_seen_at |     name      | parent_category_id 
-------+-------------+---------+--------------------+--------------+---------------+--------------------
 42289 |           1 |       8 |                  0 |              | Uncategorized |                   
  5981 |           5 |       8 |                  1 |              | Reading       |                  7
  7981 |           6 |       8 |                  1 |              | Watching      |                  7
   215 |           7 |       8 |                  1 |              | Japanese      |                   
  6981 |           9 |       8 |                  1 |              | Book Clubs    |                  5
   214 |          10 |       8 |                  0 |              | Korean        |                   
  2386 |          11 |       8 |                  0 |              | Reading       |                 10
  4384 |          12 |       8 |                  0 |              | Watching      |                 10
  3385 |          13 |       8 |                  0 |              | Book Clubs    |                 11
 36995 |          16 |       8 |                  0 |              | German        |                   
  • show notification levels from group #42 (way more)
SELECT gcnd.*, c.name, c.parent_category_id
FROM group_category_notification_defaults gcnd
JOIN categories c ON gcnd.category_id = c.id
WHERE group_id=42;
 id  | group_id | category_id | notification_level |     name      | parent_category_id 
-----+----------+-------------+--------------------+---------------+--------------------
   1 |       42 |          10 |                  0 | Korean        |                   
   8 |       42 |           7 |                  1 | Japanese      |                   
  11 |       42 |          13 |                  0 | Book Clubs    |                 11
  12 |       42 |          11 |                  0 | Reading       |                 10
  14 |       42 |          12 |                  0 | Watching      |                 10
  26 |       42 |           9 |                  1 | Book Clubs    |                  5
  27 |       42 |           6 |                  1 | Watching      |                  7
  28 |       42 |           5 |                  1 | Reading       |                  7
  97 |       42 |          16 |                  0 | German        |                   
 174 |       42 |          21 |                  0 | Book Clubs    |                 18
 177 |       42 |          18 |                  0 | Reading       |                 16
 178 |       42 |          22 |                  0 | Reading       |                 17
 179 |       42 |          23 |                  0 | Watching      |                 17
 180 |       42 |          17 |                  0 | Spanish       |                   
 181 |       42 |          19 |                  0 | Watching      |                 16
 182 |       42 |          25 |                  0 | Book Clubs    |                 22
 367 |       42 |           1 |                  0 | Uncategorized |                   

Is there a way I can run this ‘update_existing_users’ process manually in the rails console? I’m very unknowledgeable about rails, so I couldn’t find it in the code. I think it’d probably be good to try and run it manually and see if the issue is in the update process or if it’s in triggering the update process.

Let me know if anyone has any ideas or help!

Thanks

Extra info:
My site: https://forums.learnnatively.com/
Discourse Version: 3.2.0.beta4-dev (46eec95719)

So, upon further review, it seems the code will only update changes in default category notifications on a user group… see here for the change handling and here for the db update.

This means that if, for whatever reason, your initial update process to the group does not update the existing user objects, resaving the group (even with changes) doesn’t necessarily trigger the updates for the default category notifications for the group members.

I’m not entirely sure why my initial update process didn’t trigger, but since I used an api call, not the admin, I may have submitted an incorrect ‘update_existing_users’ parameter (i json dumped a python ‘True’ value).

Regardless, I did manage to resolve this issue.

Solution:

  1. Go to the user group admin, reset any category defaults which do not seem to be updated yet on users. (Ex: if group members don’t properly have a mute on a ‘Support’ category, then remove that category from the muted categories. If that category used to be in ‘normal’, then reset to ‘normal’)
  2. Save the group and say no to ‘update existing users’
  3. Change the group category notifications to the desired category notifications
  4. Save the group and say yes to ‘update existing users’

Voila, it should now be good!

FWIW, i have no judgement on if this behavior is the right behavior or not. However, it could probably be documented :slight_smile:

1 Like

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