Limit trust_levels on specified group

Why do you want it?

I founded the first genuine crypto trading community in Latam, and we left Discord three years ago — that was our usual space.

Most of our users never understood the reason for the change until they saw that other Discord servers were closed (legally and without explanations or data sent).

Today, Discourse is at least three times simpler for them, because of the improvements the team introduced in AI, UI/UX, themes like Horizon, components like this or this one and my effort to simplify what nobody in our community used or will use (for us, less is better).

So, active users need motivation and/or to be forced to ‘start again’. That’s where the ‘lurkers’ group appears:

What I’m looking for?

A plugin to limit lurkers, aka users reading but not contributing to a specific trust level, in order to force them to share.

That is what some of us on the internet know as ‘ratio’ and it keeps P2P file sharing more than three decades alive.

What do you have to start with?

Sorry devs, this is an AI draft and, of course, it will not fit the criteria for being considered a working starter template.

# name: trust-level-limiter
# about: Limit trust levels for users in specific groups
# version: 0.1
# authors: YourName

enabled_site_setting :trust_level_limiter_enabled

after_initialize do
  
  module ::TrustLevelLimiter
    class Engine < ::Rails::Engine
      engine_name "trust_level_limiter"
      isolate_namespace TrustLevelLimiter
    end
  end
  
  # Monitor group membership changes
  DiscourseEvent.on(:user_added_to_group) do |user, group|
    if SiteSetting.trust_level_limiter_enabled
      # Check if this group has trust level limitations
      max_tl = PluginStore.get("trust_level_limiter", "group_#{group.id}_max_tl")
      
      if max_tl && user.trust_level > max_tl.to_i
        user.trust_level = max_tl.to_i
        user.save!
      end
    end
  end
  
  # Prevent trust level promotion for limited groups
  User.class_eval do
    alias_method :original_change_trust_level!, :change_trust_level!
    
    def change_trust_level!(level, opts = {})
      if SiteSetting.trust_level_limiter_enabled
        # Check if user is in any limited groups
        limited_groups = self.groups.map do |group|
          max_tl = PluginStore.get("trust_level_limiter", "group_#{group.id}_max_tl")
          max_tl ? max_tl.to_i : nil
        end.compact
        
        if limited_groups.any? && level > limited_groups.min
          return false
        end
      end
      
      original_change_trust_level!(level, opts)
    end
  end
end

I wish the overall idea could inspire and be useful for something; otherwise, please mention it to me, and you can dismiss it.

How much will you pay?

You tell me. Currently, we have almost no traffic, and the plugin should be open-source.

If it’s easy for you to develop and you want to work on it for love, go ahead! I will test it, use it and share all my experience.

If it’s not easy or you need money for it, tell me a reasonable quote and we can continue like this.

We are in Latam, and I supported the community on my own.

Real crypto isn’t for everyone, and I have no marketing, so I’m afraid I’m not the client you could do your month with.

Just a random guy working for a change :slight_smile: