diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-05-31 12:57:57 -0500 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2021-05-31 12:57:57 -0500 |
| commit | c683927bd76acea7f28813ef7c80520aebdc85d8 (patch) | |
| tree | b243bf045b867c8f9c28dba08befb38d987b27a8 /src/slskd/Core/Peer/Domain | |
| parent | e6326c6d27c9e6aca60fed2e313d5e62c46ca5d2 (diff) | |
| download | slskd-c683927bd76acea7f28813ef7c80520aebdc85d8.tar.gz | |
implement peer functionality through PeerService
Diffstat (limited to 'src/slskd/Core/Peer/Domain')
| -rw-r--r-- | src/slskd/Core/Peer/Domain/Info.cs (renamed from src/slskd/Core/Peer/Domain/Peer.cs) | 26 | ||||
| -rw-r--r-- | src/slskd/Core/Peer/Domain/Status.cs | 36 |
2 files changed, 54 insertions, 8 deletions
diff --git a/src/slskd/Core/Peer/Domain/Peer.cs b/src/slskd/Core/Peer/Domain/Info.cs index 2899c24c..b2d17c8a 100644 --- a/src/slskd/Core/Peer/Domain/Peer.cs +++ b/src/slskd/Core/Peer/Domain/Info.cs @@ -1,4 +1,4 @@ -// <copyright file="Peer.cs" company="slskd Team"> +// <copyright file="Info.cs" company="slskd Team"> // Copyright (c) slskd Team. All rights reserved. // // This program is free software: you can redistribute it and/or modify @@ -19,10 +19,9 @@ namespace slskd.Peer { using System; using System.ComponentModel.DataAnnotations; - using System.Net; - using UserPresence = Soulseek.UserPresence; + using Soulseek; - public class Peer + public class Info { [Key] public string Username { get; init; } @@ -32,10 +31,21 @@ namespace slskd.Peer public byte[] Picture { get; init; } public int QueueLength { get; init; } public int UploadSlots { get; init; } - public bool IsPrivileged { get; init; } - public UserPresence Presence { get; init; } - public IPAddress IPAddress { get; init; } - public int Port { get; init; } public DateTime UpdatedAt { get; init; } + + public static Info FromSoulseekUserInfo(string username, UserInfo info) + { + return new Info() + { + Username = username, + Description = info.Description, + HasFreeUploadSlot = info.HasFreeUploadSlot, + HasPicture = info.HasPicture, + Picture = info.Picture, + QueueLength = info.QueueLength, + UploadSlots = info.UploadSlots, + UpdatedAt = DateTime.UtcNow, + }; + } } } diff --git a/src/slskd/Core/Peer/Domain/Status.cs b/src/slskd/Core/Peer/Domain/Status.cs new file mode 100644 index 00000000..4db4e859 --- /dev/null +++ b/src/slskd/Core/Peer/Domain/Status.cs @@ -0,0 +1,36 @@ +// <copyright file="Status.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.Peer +{ + using Soulseek; + + public class Status + { + public bool IsPrivileged { get; init; } + public UserPresence Presence { get; init; } + + public static Status FromSoulseekUserStatus(UserStatus status) + { + return new Status() + { + IsPrivileged = status.IsPrivileged, + Presence = status.Presence, + }; + } + } +} |
