feat(channels): add auto-disable-only channel test mode (#6728)

This commit is contained in:
Seefs
2026-08-10 12:47:44 +08:00
committed by GitHub
parent 823e26304a
commit 5d3423bec1
13 changed files with 146 additions and 11 deletions
+3
View File
@@ -1049,6 +1049,9 @@ func selectChannelsForAutomaticTest(channels []*model.Channel, mode string) []*m
if channel.Status == common.ChannelStatusManuallyDisabled {
continue
}
if mode == operation_setting.ChannelTestModeAutoBanOnly && !channel.GetAutoBan() {
continue
}
if mode == operation_setting.ChannelTestModePassiveRecovery && channel.Status != common.ChannelStatusAutoDisabled {
continue
}
+18
View File
@@ -312,6 +312,24 @@ func TestSelectChannelsForAutomaticTestScheduledSkipsManualDisabled(t *testing.T
require.Equal(t, 2, selected[1].Id)
}
func TestSelectChannelsForAutomaticTestAutoBanOnlyUsesEligibleChannels(t *testing.T) {
autoBanEnabled := 1
autoBanDisabled := 0
channels := []*model.Channel{
{Id: 1, Status: common.ChannelStatusEnabled, AutoBan: &autoBanEnabled},
{Id: 2, Status: common.ChannelStatusEnabled, AutoBan: &autoBanDisabled},
{Id: 3, Status: common.ChannelStatusAutoDisabled, AutoBan: &autoBanEnabled},
{Id: 4, Status: common.ChannelStatusManuallyDisabled, AutoBan: &autoBanEnabled},
{Id: 5, Status: common.ChannelStatusEnabled},
}
selected := selectChannelsForAutomaticTest(channels, operation_setting.ChannelTestModeAutoBanOnly)
require.Len(t, selected, 2)
require.Equal(t, 1, selected[0].Id)
require.Equal(t, 3, selected[1].Id)
}
func TestTestAllChannelsRejectsExistingActiveTask(t *testing.T) {
db := setupModelListControllerTestDB(t)
require.NoError(t, db.AutoMigrate(&model.SystemTask{}, &model.SystemTaskLock{}))