diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2022-02-25 09:47:06 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-25 09:47:06 -0600 |
| commit | 8c7861a0dfc2fd25379e03e1f23b4ae561206fc3 (patch) | |
| tree | 6a3ae3d3cb2cc7d68f81a4cdd82d76f31516d0af /src/slskd/Users/Extensions.cs | |
| parent | da7589fb77be63657b69209386743a008b2ae3d3 (diff) | |
| parent | 38bb2f3a021120963be657cf2b363b25bfaa4043 (diff) | |
| download | slskd-8c7861a0dfc2fd25379e03e1f23b4ae561206fc3.tar.gz | |
Merge pull request #364 from slskd/privileges
Identify privileged users
Diffstat (limited to 'src/slskd/Users/Extensions.cs')
| -rw-r--r-- | src/slskd/Users/Extensions.cs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/slskd/Users/Extensions.cs b/src/slskd/Users/Extensions.cs new file mode 100644 index 00000000..846fd125 --- /dev/null +++ b/src/slskd/Users/Extensions.cs @@ -0,0 +1,51 @@ +// <copyright file="Extensions.cs" company="slskd Team"> +// Copyright (c) slskd Team. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see https://www.gnu.org/licenses/. +// </copyright> + +namespace slskd.Users +{ + using Soulseek; + + /// <summary> + /// Users extensions. + /// </summary> + public static class Extensions + { + /// <summary> + /// Converts <see cref="Soulseek.UserStatistics"/> to <see cref="Statistics"/>. + /// </summary> + /// <param name="u">The UserStatistics instance to convert.</param> + /// <returns>The converted instance.</returns> + public static Statistics ToStatistics(this UserStatistics u) => new() + { + AverageSpeed = u.AverageSpeed, + DirectoryCount = u.DirectoryCount, + FileCount = u.FileCount, + UploadCount = u.UploadCount, + }; + + /// <summary> + /// Converts <see cref="Soulseek.UserStatus"/> to <see cref="Status"/>. + /// </summary> + /// <param name="s">The UserStatus instance to convert.</param> + /// <returns>The converted instance.</returns> + public static Status ToStatus(this UserStatus s) => new() + { + IsPrivileged = s.IsPrivileged, + Presence = s.Presence, + }; + } +} |
