aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Users/Domain/Info.cs24
-rw-r--r--src/slskd/Users/Extensions.cs15
2 files changed, 16 insertions, 23 deletions
diff --git a/src/slskd/Users/Domain/Info.cs b/src/slskd/Users/Domain/Info.cs
index aaf19942..e3969f17 100644
--- a/src/slskd/Users/Domain/Info.cs
+++ b/src/slskd/Users/Domain/Info.cs
@@ -17,35 +17,13 @@
namespace slskd.Users
{
- using System;
- using System.ComponentModel.DataAnnotations;
- using Soulseek;
-
- public class Info
+ public record Info
{
- [Key]
- public string Username { get; init; }
public string Description { get; init; }
public bool HasFreeUploadSlot { get; init; }
public bool HasPicture { get; init; }
public byte[] Picture { get; init; }
public int QueueLength { get; init; }
public int UploadSlots { 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/Users/Extensions.cs b/src/slskd/Users/Extensions.cs
index 846fd125..d2189a20 100644
--- a/src/slskd/Users/Extensions.cs
+++ b/src/slskd/Users/Extensions.cs
@@ -47,5 +47,20 @@ namespace slskd.Users
IsPrivileged = s.IsPrivileged,
Presence = s.Presence,
};
+
+ /// <summary>
+ /// Converts <see cref="Soulseek.UserInfo"/> to <see cref="Info"/>.
+ /// </summary>
+ /// <param name="i">The UserInfo instance to convert.</param>
+ /// <returns>The converted instance.</returns>
+ public static Info ToInfo(this UserInfo i) => new()
+ {
+ Description = i.Description,
+ HasFreeUploadSlot = i.HasFreeUploadSlot,
+ HasPicture = i.HasPicture,
+ Picture = i.Picture,
+ QueueLength = i.QueueLength,
+ UploadSlots = i.UploadSlots,
+ };
}
}