fix in db and collaborate

This commit is contained in:
Mateusz Gruszczyński
2026-08-04 14:22:26 +02:00
parent 1a77ccd1bf
commit 8d58549d11
26 changed files with 3009 additions and 298 deletions
+35 -28
View File
@@ -342,10 +342,17 @@ pub struct PaginationMeta {
total_pages: usize,
}
fn default_page() -> usize { 1 }
fn default_per_page() -> usize { 25 }
fn default_page() -> usize {
1
}
fn default_per_page() -> usize {
25
}
fn normalized_per_page(value: usize) -> usize {
match value { 25 | 50 | 100 => value, _ => 25 }
match value {
25 | 50 | 100 => value,
_ => 25,
}
}
#[derive(Serialize)]
pub struct SessionResponse {
@@ -1237,14 +1244,13 @@ pub async fn resources(
.fetch_all(state.db.pool())
.await
.map_err(AuthError::database)?;
let pads = sqlx::query_as::<_, ResourceItem>(
queries::get(state.db.kind(), queries::USER_LIST_PADS),
)
.bind(user.id)
.bind(user.id)
.fetch_all(state.db.pool())
.await
.map_err(AuthError::database)?;
let pads =
sqlx::query_as::<_, ResourceItem>(queries::get(state.db.kind(), queries::USER_LIST_PADS))
.bind(user.id)
.bind(user.id)
.fetch_all(state.db.pool())
.await
.map_err(AuthError::database)?;
let search = query.q.trim().to_lowercase();
let mut items = workspaces
@@ -1278,7 +1284,12 @@ pub async fn resources(
Ok(Json(ResourceList {
items,
pagination: PaginationMeta { page, per_page, total, total_pages },
pagination: PaginationMeta {
page,
per_page,
total,
total_pages,
},
}))
}
@@ -1817,10 +1828,9 @@ pub async fn create_share_link(
header::CACHE_CONTROL,
"no-store, max-age=0".parse().expect("valid cache-control"),
);
response.headers_mut().insert(
header::PRAGMA,
"no-cache".parse().expect("valid pragma"),
);
response
.headers_mut()
.insert(header::PRAGMA, "no-cache".parse().expect("valid pragma"));
Ok(response)
}
@@ -2059,18 +2069,15 @@ pub async fn create_share_session(
.map_err(AuthError::database)?;
let token = random_token();
sqlx::query(queries::get(
state.db.kind(),
queries::SHARE_SESSION_INSERT,
))
.bind(hash_token(&token))
.bind(source.token_hash)
.bind(kind)
.bind(slug)
.bind(expires_at.to_rfc3339())
.execute(state.db.pool())
.await
.map_err(AuthError::database)?;
sqlx::query(queries::get(state.db.kind(), queries::SHARE_SESSION_INSERT))
.bind(hash_token(&token))
.bind(source.token_hash)
.bind(kind)
.bind(slug)
.bind(expires_at.to_rfc3339())
.execute(state.db.pool())
.await
.map_err(AuthError::database)?;
Ok(Some(ShareSession {
token,