-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: expose network connectivity in the REST API
- expoe network connectivity details in the rest api - allow rest clients to forcefully re-check the network connectivity - add a last changed timestamp for when the last network availability change were detected. - changed the scheduled job to use the interface instead of the implementation.
- Loading branch information
Showing
8 changed files
with
112 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
using System; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
using Shoko.Plugin.Abstractions.Enums; | ||
using Shoko.Plugin.Abstractions.Services; | ||
|
||
namespace Shoko.Server.API.v3.Models.Common; | ||
|
||
public class ConnectivityDetails | ||
{ | ||
/// <summary> | ||
/// Current network availibility. | ||
/// </summary> | ||
[JsonConverter(typeof(StringEnumConverter))] | ||
public readonly NetworkAvailability NetworkAvailability; | ||
|
||
/// <summary> | ||
/// When the last network change was detected. | ||
/// </summary> | ||
[JsonConverter(typeof(IsoDateTimeConverter))] | ||
public readonly DateTime LastChangedAt; | ||
|
||
/// <summary> | ||
/// Is the AniDB UDP API currently reachable? | ||
/// </summary> | ||
public readonly bool IsAniDBUdpReachable; | ||
|
||
/// <summary> | ||
/// Are we currently banned from using the AniDB HTTP API? | ||
/// </summary> | ||
public readonly bool IsAniDBHttpBanned; | ||
|
||
/// <summary> | ||
/// Are we currently banned from using the AniDB UDP API? | ||
/// </summary> | ||
public readonly bool IsAniDBUdpBanned; | ||
|
||
public ConnectivityDetails(IConnectivityService service) | ||
{ | ||
NetworkAvailability = service.NetworkAvailability; | ||
LastChangedAt = service.LastChangedAt.ToUniversalTime(); | ||
IsAniDBUdpReachable = service.IsAniDBUdpReachable; | ||
IsAniDBHttpBanned = service.IsAniDBHttpBanned; | ||
IsAniDBUdpBanned = service.IsAniDBUdpBanned; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters