I’ve read the topic, Group trust level where it is said,
As well as this older topic, Should losing group membership unlock trust level?
Where the situation described largely meets with my experience,
But, what I have found in my own testing instance of Discourse is this…
With all Trust Level settings at default, I have a TL1 account (U) and a group named tl3 which grants Trust_Level_3
.
- Starting conditions
- Trust Level:
1: basic user
Unlocked - Automatic Groups:
trust_level_0
,trust_level_1
- Custom Groups: None
- Trust Level:
- Add U to tl3
- Trust Level:
3: Regular
Unlocked - Automatic Groups:
trust_level_0
,trust_level_1
,trust_level_2
,trust_level_3
- Custom Groups: tl3
- Trust Level:
- Remove U from tl3
- Trust Level:
2: Member
Unlocked - Automatic Groups:
trust_level_0
,trust_level_1
,trust_level_2
,trust_level_3
- Custom Groups: None
- NOTE: Despite having a trust level of 2, the user is still in the automatic group
trust_level_3
. With the understanding a user cannot be demoted to TL1 without a locked trust level, the expected outcome here is the user should immediately lose membership in thetrust_level_2
automatic group.
- Trust Level:
- Lock U’s trust level
- Trust Level:
2: Member
Locked - Automatic Groups:
trust_level_0
,trust_level_1
,trust_level_2
,trust_level_3
- Custom Groups: None
- NOTE: Despite having a Trust Level of
2: Member
, the user is still in the automatic grouptrust_level_3
.
- Trust Level:
- Unock U’s trust level
- Trust Level:
1: Basic
Unlocked - Automatic Groups:
trust_level_0
,trust_level_1
- Custom Groups: None
- Trust Level:
So, when unenrolling a user from a group the Trust Level is recalculated automatically and instantly, but the automatic group membership is not recalculated unless the user’s trust level experiences an unlock event.
My assumption is that automatic group memberships are computed systemwide for all users once per day and the automatic group memberships will be rectified at that point. But it feels as though automatic group memberships should be either triggered upon removal from a group with a trust level effect or triggered immediately upon any change in trust level, not just on an increase of trust level.
So the backend API call to,
POST {{site}}/admin/users/{{userId}}/groups
updates the automatic group memberships, but
DELETE {{site}}/admin/users/{{usedId}}/groups/{{groupId}}
does not, which feels like a bug, especially if you are using automatic trust level groups for access control.
And, for completeness, obviously calls to,
PUT {{site}}/admin/users/{{userId}}/trust_level
which are invoked when manually changing a user’s trust level in the admin interface, immediately recompute the automatic group memberships as expected.