diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-06-14 20:03:36 -0500 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2021-06-14 20:03:36 -0500 |
| commit | 050be311e68bb316cfc40fbd23bfd5a812e1a060 (patch) | |
| tree | 1476cba9e90845f224bbc0a380e4633697e1306e /src/slskd/API/DTO | |
| parent | 4cf8f8fa862b08131e9cc51c4bad3d6c9838342b (diff) | |
| download | slskd-050be311e68bb316cfc40fbd23bfd5a812e1a060.tar.gz | |
move stuff around
Diffstat (limited to 'src/slskd/API/DTO')
| -rw-r--r-- | src/slskd/API/DTO/ConnectRequest.cs | 27 | ||||
| -rw-r--r-- | src/slskd/API/DTO/LoginRequest.cs | 25 | ||||
| -rw-r--r-- | src/slskd/API/DTO/PrivateMessageResponse.cs | 74 | ||||
| -rw-r--r-- | src/slskd/API/DTO/QueueDownloadRequest.cs | 37 | ||||
| -rw-r--r-- | src/slskd/API/DTO/RoomInfoResponse.cs | 60 | ||||
| -rw-r--r-- | src/slskd/API/DTO/RoomMessageResponse.cs | 62 | ||||
| -rw-r--r-- | src/slskd/API/DTO/RoomResponse.cs | 75 | ||||
| -rw-r--r-- | src/slskd/API/DTO/SearchRequest.cs | 116 | ||||
| -rw-r--r-- | src/slskd/API/DTO/TokenResponse.cs | 67 | ||||
| -rw-r--r-- | src/slskd/API/DTO/Transfer.cs | 148 | ||||
| -rw-r--r-- | src/slskd/API/DTO/UserDataResponse.cs | 85 |
11 files changed, 0 insertions, 776 deletions
diff --git a/src/slskd/API/DTO/ConnectRequest.cs b/src/slskd/API/DTO/ConnectRequest.cs deleted file mode 100644 index 155db2da..00000000 --- a/src/slskd/API/DTO/ConnectRequest.cs +++ /dev/null @@ -1,27 +0,0 @@ -// <copyright file="ConnectRequest.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.API.DTO -{ - public class ConnectRequest - { - public string Address { get; set; } - public int? Port { get; set; } - public string Username { get; set; } - public string Password { get; set; } - } -} diff --git a/src/slskd/API/DTO/LoginRequest.cs b/src/slskd/API/DTO/LoginRequest.cs deleted file mode 100644 index 9f3ccf2e..00000000 --- a/src/slskd/API/DTO/LoginRequest.cs +++ /dev/null @@ -1,25 +0,0 @@ -// <copyright file="LoginRequest.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.API.DTO -{ - public class LoginRequest - { - public string Username { get; set; } - public string Password { get; set; } - } -} diff --git a/src/slskd/API/DTO/PrivateMessageResponse.cs b/src/slskd/API/DTO/PrivateMessageResponse.cs deleted file mode 100644 index 9794d762..00000000 --- a/src/slskd/API/DTO/PrivateMessageResponse.cs +++ /dev/null @@ -1,74 +0,0 @@ -// <copyright file="PrivateMessageResponse.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.API.DTO -{ - using slskd.Messaging; - using System; - - public class PrivateMessageResponse - { - /// <summary> - /// A value indicating whether the message has been acknowledged. - /// </summary> - public bool Acknowledged { get; set; } = false; - - /// <summary> - /// The unique message id, used to acknowledge receipt. - /// </summary> - public int Id { get; set; } - - /// <summary> - /// The message. - /// </summary> - public string Message { get; set; } - - /// <summary> - /// A value indicating whether the message was replayed. - /// </summary> - public bool Replayed { get; set; } - - /// <summary> - /// The UTC timestamp of the message. - /// </summary> - public DateTime Timestamp { get; set; } = DateTime.UtcNow; - - /// <summary> - /// The username of the user who sent the message. - /// </summary> - public string Username { get; set; } - - /// <summary> - /// A value indicating whether this message was sent by the currently logged in user. - /// </summary> - public bool? Self { get; set; } - - public static PrivateMessageResponse FromPrivateMessage(PrivateMessage privateMessage, bool self = false) - { - return new PrivateMessageResponse() - { - Id = privateMessage.Id, - Timestamp = privateMessage.Timestamp, - Username = privateMessage.Username, - Message = privateMessage.Message, - Acknowledged = privateMessage.Acknowledged, - Replayed = privateMessage.Replayed, - Self = self ? self : (bool?)null, - }; - } - } -} diff --git a/src/slskd/API/DTO/QueueDownloadRequest.cs b/src/slskd/API/DTO/QueueDownloadRequest.cs deleted file mode 100644 index a849fefa..00000000 --- a/src/slskd/API/DTO/QueueDownloadRequest.cs +++ /dev/null @@ -1,37 +0,0 @@ -// <copyright file="QueueDownloadRequest.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.API.DTO -{ - public class QueueDownloadRequest - { - /// <summary> - /// Gets or sets the filename to download. - /// </summary> - public string Filename { get; set; } - - /// <summary> - /// Gets or sets the size of the file. - /// </summary> - public long? Size { get; set; } - - /// <summary> - /// Gets or sets the optional transfer token. - /// </summary> - public int? Token { get; set; } - } -} diff --git a/src/slskd/API/DTO/RoomInfoResponse.cs b/src/slskd/API/DTO/RoomInfoResponse.cs deleted file mode 100644 index 6f135d56..00000000 --- a/src/slskd/API/DTO/RoomInfoResponse.cs +++ /dev/null @@ -1,60 +0,0 @@ -// <copyright file="RoomInfoResponse.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.API.DTO -{ - using Soulseek; - - public class RoomInfoResponse - { - /// <summary> - /// Gets the room name. - /// </summary> - public string Name { get; init; } - - /// <summary> - /// Gets the number of users in the room. - /// </summary> - public int UserCount { get; init; } - - /// <summary> - /// Gets a value indicating whether the room is private. - /// </summary> - public bool IsPrivate { get; init; } - - /// <summary> - /// Gets a value indicating whether the room is owned by the currently logged in user. - /// </summary> - public bool IsOwned { get; init; } - - /// <summary> - /// Gets a value indicating whether the room is moderated by the currently logged in user. - /// </summary> - public bool IsModerated { get; set; } - - public static RoomInfoResponse FromRoomInfo(RoomInfo info, bool isPrivate = false, bool isOwned = false) - { - return new RoomInfoResponse() - { - Name = info.Name, - UserCount = info.UserCount, - IsPrivate = isPrivate, - IsOwned = isOwned, - }; - } - } -} diff --git a/src/slskd/API/DTO/RoomMessageResponse.cs b/src/slskd/API/DTO/RoomMessageResponse.cs deleted file mode 100644 index 48a77f51..00000000 --- a/src/slskd/API/DTO/RoomMessageResponse.cs +++ /dev/null @@ -1,62 +0,0 @@ -// <copyright file="RoomMessageResponse.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.API.DTO -{ - using slskd.Messaging; - using System; - - public class RoomMessageResponse - { - /// <summary> - /// The timestamp of the message. - /// </summary> - public DateTime Timestamp { get; set; } = DateTime.UtcNow; - - /// <summary> - /// The username of the user who sent the message. - /// </summary> - public string Username { get; set; } - - /// <summary> - /// The message. - /// </summary> - public string Message { get; set; } - - /// <summary> - /// The room to which the message pertains. - /// </summary> - public string RoomName { get; set; } - - /// <summary> - /// A value indicating whether this user data belongs to the currently logged in user. - /// </summary> - public bool? Self { get; set; } - - public static RoomMessageResponse FromRoomMessage(RoomMessage roomMessage, bool self = false) - { - return new RoomMessageResponse() - { - Timestamp = roomMessage.Timestamp, - Username = roomMessage.Username, - Message = roomMessage.Message, - RoomName = roomMessage.RoomName, - Self = self ? self : (bool?)null, - }; - } - } -} diff --git a/src/slskd/API/DTO/RoomResponse.cs b/src/slskd/API/DTO/RoomResponse.cs deleted file mode 100644 index 552cb7f5..00000000 --- a/src/slskd/API/DTO/RoomResponse.cs +++ /dev/null @@ -1,75 +0,0 @@ -// <copyright file="RoomResponse.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.API.DTO -{ - using slskd.Messaging; - using System.Collections.Generic; - using System.Linq; - - public class RoomResponse - { - /// <summary> - /// The room name. - /// </summary> - public string Name { get; set; } - - /// <summary> - /// A value indicating whether the room is private. - /// </summary> - public bool IsPrivate { get; set; } - - /// <summary> - /// The number of operators in the room, if private. - /// </summary> - public int? OperatorCount { get; set; } - - /// <summary> - /// The operators in the room, if private. - /// </summary> - public IList<string> Operators { get; set; } - - /// <summary> - /// The owner of the room, if private. - /// </summary> - public string Owner { get; set; } - - /// <summary> - /// The list of users in the room. - /// </summary> - public IEnumerable<UserDataResponse> Users { get; set; } = new List<UserDataResponse>(); - - /// <summary> - /// The list of messages. - /// </summary> - public IEnumerable<RoomMessageResponse> Messages { get; set; } = new List<RoomMessageResponse>(); - - public static RoomResponse FromRoom(Room room) - { - return new RoomResponse() - { - Name = room.Name, - IsPrivate = room.IsPrivate, - OperatorCount = room.OperatorCount, - Operators = room.Operators?.ToList(), - Owner = room.Owner, - Users = new List<UserDataResponse>(), - Messages = new List<RoomMessageResponse>(), - }; - } - } -} diff --git a/src/slskd/API/DTO/SearchRequest.cs b/src/slskd/API/DTO/SearchRequest.cs deleted file mode 100644 index 147eb205..00000000 --- a/src/slskd/API/DTO/SearchRequest.cs +++ /dev/null @@ -1,116 +0,0 @@ -// <copyright file="SearchRequest.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.API.DTO -{ - using System; - using Soulseek; - - /// <summary> - /// A search request. - /// </summary> - public class SearchRequest - { - /// <summary> - /// Gets or sets the unique search identifier. - /// </summary> - public Guid? Id { get; set; } - - /// <summary> - /// Gets or sets the maximum number of file results to accept before the search is considered complete. (Default = 10,000). - /// </summary> - public int? FileLimit { get; set; } - - /// <summary> - /// Gets or sets a value indicating whether responses are to be filtered. (Default = true). - /// </summary> - public bool? FilterResponses { get; set; } - - /// <summary> - /// Gets or sets the maximum queue depth a peer may have in order for a response to be processed. (Default = 1000000). - /// </summary> - public int? MaximumPeerQueueLength { get; set; } - - /// <summary> - /// Gets or sets the minimum number of free upload slots a peer must have in order for a response to be processed. - /// (Default = 0). - /// </summary> - public int? MinimumPeerFreeUploadSlots { get; set; } - - /// <summary> - /// Gets or sets the minimum upload speed a peer must have in order for a response to be processed. (Default = 0). - /// </summary> - public int? MinimumPeerUploadSpeed { get; set; } - - /// <summary> - /// Gets or sets the minimum number of files a response must contain in order to be processed. (Default = 1). - /// </summary> - public int? MinimumResponseFileCount { get; set; } - - /// <summary> - /// Gets or sets the maximum number of search results to accept before the search is considered complete. (Default = 100). - /// </summary> - public int? ResponseLimit { get; set; } - - /// <summary> - /// Gets or sets the search text. - /// </summary> - public string SearchText { get; set; } - - /// <summary> - /// Gets or sets the search timeout value, in seconds, used to determine when the search is complete. (Default = 15). - /// </summary> - /// <remarks>The timeout duration is from the time of the last response.</remarks> - public int? SearchTimeout { get; set; } - - /// <summary> - /// Gets or sets the search token. - /// </summary> - public int? Token { get; set; } - - /// <summary> - /// Maps to a new instance of <see cref="SearchOptions"/>. - /// </summary> - /// <param name="responseFilter"></param> - /// <param name="fileFilter"></param> - /// <param name="stateChanged"></param> - /// <param name="responseReceived"></param> - /// <returns></returns> - public SearchOptions ToSearchOptions( - Func<SearchResponse, bool> responseFilter = null, - Func<File, bool> fileFilter = null, - Action<SearchStateChangedEventArgs> stateChanged = null, - Action<SearchResponseReceivedEventArgs> responseReceived = null) - { - var def = new SearchOptions(); - - return new SearchOptions( - searchTimeout: SearchTimeout ?? def.SearchTimeout, - responseLimit: ResponseLimit ?? def.ResponseLimit, - fileLimit: FileLimit ?? def.FileLimit, - filterResponses: FilterResponses ?? def.FilterResponses, - minimumResponseFileCount: MinimumResponseFileCount ?? def.MinimumResponseFileCount, - minimumPeerFreeUploadSlots: MinimumPeerFreeUploadSlots ?? def.MinimumPeerFreeUploadSlots, - maximumPeerQueueLength: MaximumPeerQueueLength ?? def.MaximumPeerQueueLength, - minimumPeerUploadSpeed: MinimumPeerUploadSpeed ?? def.MinimumPeerUploadSpeed, - responseFilter: responseFilter, - fileFilter: fileFilter, - responseReceived: responseReceived, - stateChanged: stateChanged); - } - } -}
\ No newline at end of file diff --git a/src/slskd/API/DTO/TokenResponse.cs b/src/slskd/API/DTO/TokenResponse.cs deleted file mode 100644 index c20e325c..00000000 --- a/src/slskd/API/DTO/TokenResponse.cs +++ /dev/null @@ -1,67 +0,0 @@ -// <copyright file="TokenResponse.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.API.DTO -{ - using System; - using System.IdentityModel.Tokens.Jwt; - using System.Linq; - using System.Security.Claims; - using System.Text.Json.Serialization; - using Microsoft.AspNetCore.Authentication.JwtBearer; - - public class TokenResponse - { - public TokenResponse(JwtSecurityToken jwtSecurityToken) - { - JwtSecurityToken = jwtSecurityToken; - } - - /// <summary> - /// Gets the time at which the Access Token expires. - /// </summary> - public long Expires => ((DateTimeOffset)JwtSecurityToken.ValidTo).ToUnixTimeSeconds(); - - /// <summary> - /// Gets the time at which the Access Token was issued. - /// </summary> - public long Issued => ((DateTimeOffset)JwtSecurityToken.ValidFrom).ToUnixTimeSeconds(); - - /// <summary> - /// Gets the value of the Name claim from the Access Token. - /// </summary> - public string Name => JwtSecurityToken.Claims.SingleOrDefault(c => c.Type == ClaimTypes.Name)?.Value; - - /// <summary> - /// Gets the value of the Not Before claim from the Access Token. - /// </summary> - public long NotBefore => long.Parse(JwtSecurityToken.Claims.SingleOrDefault(c => c.Type == "nbf").Value); - - /// <summary> - /// Gets the Access Token string. - /// </summary> - public string Token => new JwtSecurityTokenHandler().WriteToken(JwtSecurityToken); - - /// <summary> - /// Gets the Token type. - /// </summary> - public string TokenType => JwtBearerDefaults.AuthenticationScheme; - - [JsonIgnore] - private JwtSecurityToken JwtSecurityToken { get; } - } -}
\ No newline at end of file diff --git a/src/slskd/API/DTO/Transfer.cs b/src/slskd/API/DTO/Transfer.cs deleted file mode 100644 index c3e4ac22..00000000 --- a/src/slskd/API/DTO/Transfer.cs +++ /dev/null @@ -1,148 +0,0 @@ -// <copyright file="Transfer.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.API.DTO -{ - using System; - using System.Net; - using Soulseek; - - /// <summary> - /// A single file transfer. - /// </summary> - public class Transfer - { - /// <summary> - /// Gets the current average transfer speed. - /// </summary> - public double AverageSpeed { get; set; } - - /// <summary> - /// Gets the number of remaining bytes to be transferred. - /// </summary> - public long BytesRemaining { get; set; } - - /// <summary> - /// Gets the total number of bytes transferred. - /// </summary> - public long BytesTransferred { get; set; } - - /// <summary> - /// Gets the transfer direction. - /// </summary> - public TransferDirection Direction { get; set; } - - /// <summary> - /// Gets the current duration of the transfer, if it has been started. - /// </summary> - public double? ElapsedTime { get; set; } - - /// <summary> - /// Gets the UTC time at which the transfer transitioned into the <see cref="TransferStates.Completed"/> state. - /// </summary> - public DateTime? EndTime { get; set; } - - /// <summary> - /// Gets the filename of the file to be transferred. - /// </summary> - public string Filename { get; set; } - - /// <summary> - /// Gets the transfer id. - /// </summary> - public string Id => Filename.Sha1(); - - /// <summary> - /// Gets the ip endpoint of the remote transfer connection, if one has been established. - /// </summary> - public IPEndPoint IPEndPoint { get; set; } - - /// <summary> - /// Gets the current progress in percent. - /// </summary> - public double PercentComplete { get; set; } - - /// <summary> - /// Gets the current place in queue, if it has been fetched. - /// </summary> - public int? PlaceInQueue { get; set; } - - /// <summary> - /// Gets the projected remaining duration of the transfer. - /// </summary> - public double? RemainingTime { get; set; } - - /// <summary> - /// Gets the remote unique token for the transfer. - /// </summary> - public int? RemoteToken { get; set; } - - /// <summary> - /// Gets the size of the file to be transferred, in bytes. - /// </summary> - public long Size { get; set; } - - /// <summary> - /// Gets the starting offset of the transfer, in bytes. - /// </summary> - public long StartOffset { get; set; } - - /// <summary> - /// Gets the UTC time at which the transfer transitioned into the <see cref="TransferStates.InProgress"/> state. - /// </summary> - public DateTime? StartTime { get; set; } - - /// <summary> - /// Gets the state of the transfer. - /// </summary> - public TransferStates State { get; set; } - - /// <summary> - /// Gets the unique token for the transfer. - /// </summary> - public int Token { get; set; } - - /// <summary> - /// Gets the username of the peer to or from which the file is to be transferred. - /// </summary> - public string Username { get; set; } - - public static Transfer FromSoulseekTransfer(Soulseek.Transfer transfer) - { - return new Transfer() - { - AverageSpeed = transfer.AverageSpeed, - BytesRemaining = transfer.BytesRemaining, - BytesTransferred = transfer.BytesTransferred, - Direction = transfer.Direction, - ElapsedTime = transfer.ElapsedTime?.TotalMilliseconds, - EndTime = transfer.EndTime, - Filename = transfer.Filename, - IPEndPoint = transfer.IPEndPoint, - PercentComplete = transfer.PercentComplete, - RemainingTime = transfer.RemainingTime?.TotalMilliseconds, - RemoteToken = transfer.RemoteToken, - Size = transfer.Size, - StartOffset = transfer.StartOffset, - StartTime = transfer.StartTime, - State = transfer.State, - Token = transfer.Token, - Username = transfer.Username, - }; - } - } -}
\ No newline at end of file diff --git a/src/slskd/API/DTO/UserDataResponse.cs b/src/slskd/API/DTO/UserDataResponse.cs deleted file mode 100644 index e854922e..00000000 --- a/src/slskd/API/DTO/UserDataResponse.cs +++ /dev/null @@ -1,85 +0,0 @@ -// <copyright file="UserDataResponse.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.API.DTO -{ - using Soulseek; - - public class UserDataResponse - { - /// <summary> - /// The average upload speed of the user. - /// </summary> - public int AverageSpeed { get; set; } - - /// <summary> - /// The user's country code, if provided. - /// </summary> - public string CountryCode { get; set; } - - /// <summary> - /// The number of directories shared by the user. - /// </summary> - public int DirectoryCount { get; set; } - - /// <summary> - /// The number of active user downloads. - /// </summary> - public long DownloadCount { get; set; } - - /// <summary> - /// The number of files shared by the user. - /// </summary> - public int FileCount { get; set; } - - /// <summary> - /// A value indicating whether this user data belongs to the currently logged in user. - /// </summary> - public bool? Self { get; set; } - - /// <summary> - /// The number of the user's free download slots, if provided. - /// </summary> - public int? SlotsFree { get; set; } - - /// <summary> - /// The status of the user (0 = offline, 1 = away, 2 = online). - /// </summary> - public UserPresence Status { get; set; } - - /// <summary> - /// The username of the user. - /// </summary> - public string Username { get; set; } - - public static UserDataResponse FromUserData(UserData userData, bool self = false) - { - return new UserDataResponse() - { - AverageSpeed = userData.AverageSpeed, - CountryCode = userData.CountryCode, - DirectoryCount = userData.DirectoryCount, - DownloadCount = userData.DownloadCount, - FileCount = userData.FileCount, - SlotsFree = userData.SlotsFree, - Status = userData.Status, - Username = userData.Username, - Self = self ? self : (bool?)null, - }; - } - } -}
\ No newline at end of file |
