Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: do not downgrade trust level if all requirements are met #25953

Merged
merged 1 commit into from Mar 3, 2024

Conversation

lis2
Copy link
Contributor

@lis2 lis2 commented Feb 29, 2024

Currently, the trust level method is calculating trust level based on maximum value from:

  • locked trust level
  • group automatic trust level
  • previously granted trust level by admin

https://github.com/discourse/discourse/blob/main/lib/trust_level.rb#L33

Let's say the user belongs to groups with automatic trust level 1 and in the meantime meets all criteria to get trust level 2.

Each time, a user is removed from a group with automatic trust_level 1, they will be downgraded to trust_level 1 and immediately promoted to trust_level 2

user.update_column(:trust_level, TrustLevel[granted_trust_level])

This will cause duplicated promotion messages.

Therefore, we have to check if the user meets the criteria, before downgrading.

Currently, the trust level method  is calculating trust level based on maximum value from:
- locked trust level
- group automatic trust level
- previously granted trust level by admin

https://github.com/discourse/discourse/blob/main/lib/trust_level.rb#L33

Let's say the user belongs to groups with automatic trust level 1 and in the meantime meets all criteria to get trust level 2.

Each time, a user is removed from a group with automatic trust_level 1, they will be downgraded to trust_level 1 and promoted to trust_level 2

https://github.com/discourse/discourse/blob/120a2f70a9ea3b08a39fc1fbb251f59ecf968cde/lib/promotion.rb#L142

This will cause duplicated promotion messages.

Therefore, we have to check if the user meets the criteria, before downgrading.
@lis2 lis2 changed the title FIX: down downgrade trust level if all requirements are met. FIX: do not downgrade trust level if all requirements are met Feb 29, 2024
Copy link
Contributor

@martin-brennan martin-brennan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one thanks!

@lis2 lis2 merged commit 41f78b3 into discourse:main Mar 3, 2024
16 checks passed
@lis2 lis2 deleted the protect-trust-level branch March 3, 2024 22:30
VeroFess added a commit to VeroFess/discourse_path_s3_support that referenced this pull request Mar 3, 2024
FIX: down downgrade trust level if all requirements are met. (discourse#25953)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants