tie friends profile together

This commit is contained in:
2026-08-08 03:27:25 +08:00
parent 056c9304f7
commit 8bc1d074d4
4 changed files with 498 additions and 28 deletions
+29 -6
View File
@@ -12,9 +12,24 @@ pub struct Profile {
#[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "camelCase")]
pub enum ClientMessage {
Register { profile: Profile, signature: String },
ProfileUpdated { profile: Profile, signature: String },
Signed { payload: String, signature: String },
Register {
profile: Profile,
friends: Vec<String>,
signature: String,
},
ProfileUpdated {
profile: Profile,
signature: String,
},
FriendsUpdated {
friends: Vec<String>,
signature: String,
},
SyncFriendProfiles,
Signed {
payload: String,
signature: String,
},
}
#[derive(Debug, Serialize, Deserialize)]
@@ -22,12 +37,16 @@ pub enum ClientMessage {
pub enum ServerMessage {
Challenge { version: u8, challenge: String },
Registered,
FriendProfileUpdated { profile: Profile },
FriendProfiles { profiles: Vec<Profile> },
}
pub fn register_bytes(challenge: &str, profile: &Profile) -> Vec<u8> {
pub fn register_bytes(challenge: &str, profile: &Profile, friends: &[String]) -> Vec<u8> {
format!(
"wyd-register-v{VERSION}\n{challenge}\n{}\n{}",
profile.id, profile.display_name
"wyd-register-v{VERSION}\n{challenge}\n{}\n{}\n{}",
profile.id,
profile.display_name,
friends.join("\n")
)
.into_bytes()
}
@@ -43,3 +62,7 @@ pub fn profile_bytes(profile: &Profile) -> Vec<u8> {
)
.into_bytes()
}
pub fn friends_bytes(friends: &[String]) -> Vec<u8> {
format!("wyd-friends-v{VERSION}\n{}", friends.join("\n")).into_bytes()
}