community: declare what you like on soulseek, so the similar-users shelf finally has something to rank on

This commit is contained in:
KeelrLeek committed 2026-09-03 15:05:23 -05:00
1 parent 8093adc89e
commit 7b7f48ebc6
8 files changed
+5671 -5519

No files matched your search

+13
View File
@@ -625,6 +625,19 @@ impl Client {
}
}
/// Declare, or take back, one interest on the server. Fire and forget:
/// the server sends nothing back, and reading our own interests is how you
/// confirm it landed.
pub fn declare_interest(&self, thing: &str, like: bool, on: bool) -> Result<()> {
let msg = match (like, on) {
(true, true) => server::add_thing_i_like(thing),
(true, false) => server::remove_thing_i_like(thing),
(false, true) => server::add_thing_i_hate(thing),
(false, false) => server::remove_thing_i_hate(thing),
};
self.inner.send_server(msg)
}
/// Users the server ranks as similar to us by shared interests. Spawn-shaped.
pub fn similar_users(
&self,
+26
View File
@@ -31,7 +31,11 @@ pub mod code {
pub const PING: u32 = 32;
pub const SHARED_FOLDERS_AND_FILES: u32 = 35;
pub const GET_USER_STATS: u32 = 36;
pub const ADD_THING_I_LIKE: u32 = 51;
pub const REMOVE_THING_I_LIKE: u32 = 52;
pub const USER_INTERESTS: u32 = 57;
pub const ADD_THING_I_HATE: u32 = 117;
pub const REMOVE_THING_I_HATE: u32 = 118;
pub const SIMILAR_USERS: u32 = 110;
pub const ROOM_LIST: u32 = 64;
pub const HAVE_NO_PARENTS: u32 = 71;
@@ -138,6 +142,28 @@ pub fn get_user_stats(username: &str) -> Vec<u8> {
.finish_u32(code::GET_USER_STATS)
}
/// Declare a like (code 51). These are what the server matches on when it
/// ranks similar users, so a client that never sends one is invisible to that
/// ranking however much it reads.
pub fn add_thing_i_like(thing: &str) -> Vec<u8> {
Writer::new().string(thing).finish_u32(code::ADD_THING_I_LIKE)
}
/// Take a like back (code 52).
pub fn remove_thing_i_like(thing: &str) -> Vec<u8> {
Writer::new().string(thing).finish_u32(code::REMOVE_THING_I_LIKE)
}
/// Declare a dislike (code 117).
pub fn add_thing_i_hate(thing: &str) -> Vec<u8> {
Writer::new().string(thing).finish_u32(code::ADD_THING_I_HATE)
}
/// Take a dislike back (code 118).
pub fn remove_thing_i_hate(thing: &str) -> Vec<u8> {
Writer::new().string(thing).finish_u32(code::REMOVE_THING_I_HATE)
}
/// A user's declared likes and hates (code 57).
pub fn user_interests(username: &str) -> Vec<u8> {
Writer::new()