parent
537ad3a5f8
commit
b27114eaad
@ -206,6 +206,9 @@ public class Server : GlobalBase
|
||||
case "Settings/customRequestLimit":
|
||||
SendResponse(HttpStatusCode.OK, response, settings.requestLimits);
|
||||
break;
|
||||
case "Settings/AprilFoolsMode":
|
||||
SendResponse(HttpStatusCode.OK, response, settings.aprilFoolsMode);
|
||||
break;
|
||||
case "NotificationConnectors":
|
||||
SendResponse(HttpStatusCode.OK, response, notificationConnectors);
|
||||
break;
|
||||
@ -405,6 +408,16 @@ public class Server : GlobalBase
|
||||
settings.UpdateDownloadLocation(downloadLocation, moveFiles);
|
||||
SendResponse(HttpStatusCode.Accepted, response);
|
||||
break;
|
||||
case "Settings/AprilFoolsMode":
|
||||
if (!requestVariables.TryGetValue("enabled", out string? aprilFoolsModeEnabledStr) ||
|
||||
bool.TryParse(aprilFoolsModeEnabledStr, out bool aprilFoolsModeEnabled))
|
||||
{
|
||||
SendResponse(HttpStatusCode.BadRequest, response);
|
||||
break;
|
||||
}
|
||||
settings.UpdateAprilFoolsMode(aprilFoolsModeEnabled);
|
||||
SendResponse(HttpStatusCode.Accepted, response);
|
||||
break;
|
||||
/*case "Settings/UpdateWorkingDirectory":
|
||||
if (!requestVariables.TryGetValue("workingDirectory", out string? workingDirectory))
|
||||
{
|
||||
|
@ -73,10 +73,23 @@ public partial class Tranga : GlobalBase
|
||||
{
|
||||
while (keepRunning)
|
||||
{
|
||||
jobBoss.CheckJobs();
|
||||
if(!settings.aprilFoolsMode & !IsAprilFirst())
|
||||
jobBoss.CheckJobs();
|
||||
else
|
||||
Log("April Fools Mode in Effect");
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
});
|
||||
t.Start();
|
||||
}
|
||||
|
||||
private bool IsAprilFirst()
|
||||
{
|
||||
//UTC 01 Apr +-12hrs
|
||||
DateTime start = new DateTime(DateTime.Now.Year, 03, 31, 12, 0, 0, DateTimeKind.Utc);
|
||||
DateTime end = new DateTime(DateTime.Now.Year, 04, 02, 12, 0, 0, DateTimeKind.Utc);
|
||||
if (DateTime.UtcNow > start && DateTime.UtcNow < end)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
@ -20,7 +20,8 @@ public class TrangaSettings
|
||||
[JsonIgnore] public string jobsFolderPath => Path.Join(workingDirectory, "jobs");
|
||||
[JsonIgnore] public string coverImageCache => Path.Join(workingDirectory, "imageCache");
|
||||
[JsonIgnore] internal static readonly string DefaultUserAgent = $"Tranga ({Enum.GetName(Environment.OSVersion.Platform)}; {(Environment.Is64BitOperatingSystem ? "x64" : "")}) / 1.0";
|
||||
public ushort? version { get; set; } = 1;
|
||||
public ushort? version { get; } = 1;
|
||||
public bool aprilFoolsMode { get; private set; } = true;
|
||||
[JsonIgnore]internal static readonly Dictionary<RequestType, int> DefaultRequestLimits = new ()
|
||||
{
|
||||
{RequestType.MangaInfo, 250},
|
||||
@ -102,6 +103,12 @@ public class TrangaSettings
|
||||
})!;
|
||||
}
|
||||
|
||||
public void UpdateAprilFoolsMode(bool enabled)
|
||||
{
|
||||
this.aprilFoolsMode = enabled;
|
||||
ExportSettings();
|
||||
}
|
||||
|
||||
public void UpdateDownloadLocation(string newPath, bool moveFiles = true)
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
|
Loading…
Reference in New Issue
Block a user