pinakes-server: propagate sync/share errors; cap unbounded pagination
limits Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I79339740dd34353014d02f571b6f55a26a6a6964
This commit is contained in:
parent
b12ad5d272
commit
f049dd100a
3 changed files with 37 additions and 15 deletions
|
|
@ -171,8 +171,10 @@ pub async fn create_share(
|
|||
created_at: Utc::now(),
|
||||
};
|
||||
|
||||
// Ignore notification errors
|
||||
let _ = state.storage.create_share_notification(¬ification).await;
|
||||
if let Err(e) = state.storage.create_share_notification(¬ification).await
|
||||
{
|
||||
tracing::warn!(error = %e, "failed to send share notification");
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Json(created.into()))
|
||||
|
|
@ -188,7 +190,7 @@ pub async fn list_outgoing(
|
|||
let user_id = resolve_user_id(&state.storage, &username).await?;
|
||||
let pagination = Pagination {
|
||||
offset: params.offset.unwrap_or(0),
|
||||
limit: params.limit.unwrap_or(50),
|
||||
limit: params.limit.unwrap_or(50).min(1000),
|
||||
sort: params.sort,
|
||||
};
|
||||
|
||||
|
|
@ -211,7 +213,7 @@ pub async fn list_incoming(
|
|||
let user_id = resolve_user_id(&state.storage, &username).await?;
|
||||
let pagination = Pagination {
|
||||
offset: params.offset.unwrap_or(0),
|
||||
limit: params.limit.unwrap_or(50),
|
||||
limit: params.limit.unwrap_or(50).min(1000),
|
||||
sort: params.sort,
|
||||
};
|
||||
|
||||
|
|
@ -316,7 +318,10 @@ pub async fn update_share(
|
|||
is_read: false,
|
||||
created_at: Utc::now(),
|
||||
};
|
||||
let _ = state.storage.create_share_notification(¬ification).await;
|
||||
if let Err(e) = state.storage.create_share_notification(¬ification).await
|
||||
{
|
||||
tracing::warn!(error = %e, "failed to send share update notification");
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Json(updated.into()))
|
||||
|
|
@ -351,7 +356,10 @@ pub async fn delete_share(
|
|||
is_read: false,
|
||||
created_at: Utc::now(),
|
||||
};
|
||||
let _ = state.storage.create_share_notification(¬ification).await;
|
||||
if let Err(e) = state.storage.create_share_notification(¬ification).await
|
||||
{
|
||||
tracing::warn!(error = %e, "failed to send share revocation notification");
|
||||
}
|
||||
}
|
||||
|
||||
state.storage.delete_share(ShareId(id)).await.map_err(|e| {
|
||||
|
|
@ -442,7 +450,9 @@ pub async fn access_shared(
|
|||
details: None,
|
||||
timestamp: Utc::now(),
|
||||
};
|
||||
let _ = state.storage.record_share_activity(&activity).await;
|
||||
if let Err(e) = state.storage.record_share_activity(&activity).await {
|
||||
tracing::warn!(error = %e, "failed to record share activity");
|
||||
}
|
||||
|
||||
return Err(ApiError::unauthorized("Invalid password"));
|
||||
}
|
||||
|
|
@ -511,7 +521,7 @@ pub async fn get_activity(
|
|||
|
||||
let pagination = Pagination {
|
||||
offset: params.offset.unwrap_or(0),
|
||||
limit: params.limit.unwrap_or(50),
|
||||
limit: params.limit.unwrap_or(50).min(1000),
|
||||
sort: params.sort,
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue