Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
:warning: This plugin is NOT offical and has been replaced with the [discourse-auto-deactivate
plugin](https://github.com/discourse/discourse-auto-deactivate)

# discourse-auto-suspend
A plugin for Discourse which automatically suspends users after a defined period of inactivity.

[How to install a plugin](https://meta.discourse.org/t/install-a-plugin/19157)

The plugin is disabled by default, make sure to enable it in your site settings.
The plugin is disabled by default, make sure to enable it in your site settings.
5 changes: 4 additions & 1 deletion plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ class AutoSuspendUsers < Jobs::Scheduled
def execute(args)
return if !SiteSetting.auto_suspend_enabled?

to_suspend = User.where("last_seen_at < ?", SiteSetting.auto_suspend_after_days.days.ago).where('suspended_till IS NULL OR suspended_till < ?', Time.zone.now)
auto_suspend_days = SiteSetting.auto_suspend_after_days.days.ago
to_suspend = User.where("last_seen_at IS NULL OR last_seen_at < ? AND created_at < ?", auto_suspend_days, auto_suspend_days)
.where('suspended_till IS NULL OR suspended_till < ?', Time.zone.now)
.real

for user in to_suspend do
safe_groups = SiteSetting.auto_suspend_safe_groups
Expand Down