diff options
| author | JP Dillingham <jp@dillingham.me> | 2022-06-29 17:54:45 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-29 17:54:45 -0500 |
| commit | 610582ea53ace5c309b18df5570b12c73a43541a (patch) | |
| tree | 84248ffd4e3b5c261e2fdbd8f52ddc767e469418 /src/slskd/Core/State.cs | |
| parent | 77df3572c381150dc60454be03ca3176a940a628 (diff) | |
| parent | 6fd167cca6be37e2c88c811cdbcfa64081aeb268 (diff) | |
| download | slskd-610582ea53ace5c309b18df5570b12c73a43541a.tar.gz | |
Merge pull request #538 from slskd/privileges
Track user privileges
Diffstat (limited to 'src/slskd/Core/State.cs')
| -rw-r--r-- | src/slskd/Core/State.cs | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/slskd/Core/State.cs b/src/slskd/Core/State.cs index b15ce7fa..e009805a 100644 --- a/src/slskd/Core/State.cs +++ b/src/slskd/Core/State.cs @@ -34,6 +34,7 @@ namespace slskd public bool PendingReconnect { get; init; } public bool PendingRestart { get; init; } public ServerState Server { get; init; } = new ServerState(); + public UserState User { get; init; } = new UserState(); public DistributedNetworkState DistributedNetwork { get; init; } = new DistributedNetworkState(); public ShareState Shares { get; init; } = new ShareState(); public string[] Rooms { get; init; } = Array.Empty<string>(); @@ -57,13 +58,32 @@ namespace slskd [JsonConverter(typeof(IPEndPointConverter))] public IPEndPoint IPEndPoint { get; init; } public SoulseekClientStates State { get; init; } - public string Username { get; init; } - public UserStatistics Statistics { get; init; } public bool IsConnected => State.HasFlag(SoulseekClientStates.Connected); public bool IsLoggedIn => State.HasFlag(SoulseekClientStates.LoggedIn); public bool IsTransitioning => State.HasFlag(SoulseekClientStates.Connecting) || State.HasFlag(SoulseekClientStates.Disconnecting) || State.HasFlag(SoulseekClientStates.LoggingIn); } + public record UserState + { + public string Username { get; init; } + public UserPrivilegeState Privileges { get; init; } = new UserPrivilegeState(); + public UserStatisticsState Statistics { get; init; } = new UserStatisticsState(); + } + + public record UserPrivilegeState + { + public bool IsPrivileged { get; init; } + public int PrivilegesRemaining { get; init; } + } + + public record UserStatisticsState + { + public int AverageSpeed { get; init; } + public int DirectoryCount { get; init; } + public int FileCount { get; init; } + public long UploadCount { get; init; } + } + public record DistributedNetworkState { public int BranchLevel { get; init; } |
