Make the hold method configurable in the dashboard
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9a56fc5b48
commit
6b9bf3cd5f
40 files changed
+815
-134
No files matched your search
@@ -1,5 +1,6 @@
|
||||
using Flypaper.Core;
|
||||
using Flypaper.Core.Settings;
|
||||
using Flypaper.Core.Strategies;
|
||||
using Flypaper.Http;
|
||||
using Flypaper.Storage;
|
||||
using Flypaper.Storage.Entities;
|
||||
@@ -64,11 +65,10 @@ public sealed class SettingsOverrideTests : IDisposable
|
||||
var options = host.Services.GetRequiredService<IOptionsMonitor<FlypaperOptions>>();
|
||||
var store = host.Services.GetRequiredService<RuntimeSettingsStore>();
|
||||
|
||||
await store.SaveAsync(new RuntimeSettings(50, 4, TimeSpan.FromMinutes(10), 90, false));
|
||||
await store.SaveAsync(new RuntimeSettings(50, 4, 90, false));
|
||||
|
||||
options.CurrentValue.MaxConnections.ShouldBe(50);
|
||||
options.CurrentValue.MaxConnectionsPerIp.ShouldBe(4);
|
||||
options.CurrentValue.MaxHoldDuration.ShouldBe(TimeSpan.FromMinutes(10));
|
||||
options.CurrentValue.IgnorePrivateNetworks.ShouldBeFalse();
|
||||
(await store.HasOverridesAsync()).ShouldBeTrue();
|
||||
|
||||
@@ -79,6 +79,36 @@ public sealed class SettingsOverrideTests : IDisposable
|
||||
(await store.HasOverridesAsync()).ShouldBeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Hold_method_is_saved_and_reset_separately_from_general_settings()
|
||||
{
|
||||
var host = BuildHost();
|
||||
await host.Services.MigrateFlypaperDatabaseAsync();
|
||||
var core = host.Services.GetRequiredService<IOptionsMonitor<FlypaperOptions>>();
|
||||
var drip = host.Services.GetRequiredService<IOptionsMonitor<DripOptions>>();
|
||||
var store = host.Services.GetRequiredService<RuntimeSettingsStore>();
|
||||
string[] holdKeys = [.. SettingKeys.HoldMethod];
|
||||
|
||||
await store.SaveAsync(new HoldMethodSettings(DripContent.Text, TimeSpan.FromMilliseconds(200), TimeSpan.FromSeconds(2), 8, 16, TimeSpan.FromMinutes(5)));
|
||||
await store.SaveAsync(new RuntimeSettings(50, 4, 90, true));
|
||||
|
||||
drip.CurrentValue.Content.ShouldBe(DripContent.Text);
|
||||
drip.CurrentValue.MinDelay.ShouldBe(TimeSpan.FromMilliseconds(200));
|
||||
drip.CurrentValue.MaxChunkSize.ShouldBe(16);
|
||||
core.CurrentValue.MaxHoldDuration.ShouldBe(TimeSpan.FromMinutes(5));
|
||||
core.CurrentValue.MaxConnections.ShouldBe(50);
|
||||
(await store.HasOverridesAsync(holdKeys)).ShouldBeTrue();
|
||||
|
||||
await store.ResetAsync(holdKeys);
|
||||
|
||||
drip.CurrentValue.Content.ShouldBe(DripContent.Html);
|
||||
drip.CurrentValue.MinDelay.ShouldBe(TimeSpan.FromMilliseconds(50));
|
||||
core.CurrentValue.MaxHoldDuration.ShouldBe(TimeSpan.FromHours(1));
|
||||
core.CurrentValue.MaxConnections.ShouldBe(50);
|
||||
(await store.HasOverridesAsync(holdKeys)).ShouldBeFalse();
|
||||
(await store.HasOverridesAsync()).ShouldBeTrue();
|
||||
}
|
||||
|
||||
private IHost BuildHost()
|
||||
{
|
||||
var builder = Host.CreateApplicationBuilder(new HostApplicationBuilderSettings { DisableDefaults = true });
|
||||
|
||||
Reference in new issue
Block a user