community: friends, two signed answers on one request carried over soulseek, one answer is only ever pending

This commit is contained in:
KeelrLeek committed 2026-09-02 14:40:33 -05:00
1 parent 6ed6f5b8f8
commit 984738135a
9 files changed
+967 -4

No files matched your search

+16 -1
View File
@@ -150,7 +150,7 @@ async fn send_pm(app: &tauri::AppHandle, to: &str, text: &str) -> Result<(), Str
/// Ask `username` over Soulseek for their signed SoulStream ID and verify
/// the answer. One PM out, one in, thirty seconds at most.
async fn ask(app: &tauri::AppHandle, username: &str) -> Result<KnownLink, String> {
pub(crate) async fn ask(app: &tauri::AppHandle, username: &str) -> Result<KnownLink, String> {
let target = sl::normalize_username(username);
if target.is_empty() {
return Err("no username".into());
@@ -278,6 +278,21 @@ pub async fn intercept_pm(app: &tauri::AppHandle, from: &str, message: &str) ->
false
}
/// A verified link for `username`, if this device holds one.
pub(crate) fn known_link(app: &tauri::AppHandle, username: &str) -> Option<KnownLink> {
load(app)
.others
.get(&sl::normalize_username(username))
.cloned()
}
/// Keep a link another service verified (the friends handshake binds a
/// request's key to its sender the same way the drawer's Ask does).
pub(crate) fn remember(app: &tauri::AppHandle, link: KnownLink) {
let mut links = load(app);
links.others.insert(link.username_normalized.clone(), link);
let _ = save(app, &links);
}
// ---------------------------------------------------------------- commands
#[tauri::command]