web, core, desktop: share a note with a group, and Settings → Groups

The Share dialog lists people and groups in one picker and shows a group share
as its name and member count. Settings gains a Groups section for the admin:
create, rename, delete, and add or remove people.

The core client reads the directory's groups and group shares (ShareTarget:
a member or a group); the desktop command takes user_id or group_id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-07 18:25:16 -04:00
co-authored by Claude Opus 5.5
parent 5f3cfe8bb7
commit 442cca4398
9 changed files with 413 additions and 57 deletions
+8 -6
View File
@@ -8,7 +8,7 @@
use rusqlite::params;
use super::client::{self, Member, NoteShare};
use super::client::{self, Directory, NoteShare, ShareTarget};
use super::state;
use crate::local::Db;
@@ -38,7 +38,7 @@ fn mark_shared(db: &Db, note_id: &str, shares: &[NoteShare]) -> Result<(), Strin
Ok(())
}
pub async fn directory(db: &Db) -> Result<Vec<Member>, String> {
pub async fn directory(db: &Db) -> Result<Directory, String> {
let (url, token) = link(db)?;
client::directory(&url, &token).await
}
@@ -53,11 +53,11 @@ pub async fn list(db: &Db, note_id: &str) -> Result<Vec<NoteShare>, String> {
pub async fn share(
db: &Db,
note_id: &str,
user_id: &str,
target: &ShareTarget,
permission: &str,
) -> Result<Vec<NoteShare>, String> {
let (url, token) = link(db)?;
let shares = client::share_note(&url, &token, note_id, user_id, permission).await?;
let shares = client::share_note(&url, &token, note_id, target, permission).await?;
mark_shared(db, note_id, &shares)?;
Ok(shares)
}
@@ -73,6 +73,7 @@ pub async fn unshare(db: &Db, note_id: &str, share_id: &str) -> Result<Vec<NoteS
mod tests {
use super::*;
use crate::local::schema;
use crate::sync::client::Member;
use rusqlite::Connection;
use std::sync::Mutex;
@@ -101,11 +102,12 @@ mod tests {
}
let one = NoteShare {
id: "s1".into(),
member: Member {
member: Some(Member {
id: "u2".into(),
display_name: "Sam".into(),
email: "sam@example.test".into(),
},
}),
group: None,
permission: "view".into(),
created_at: None,
};