~ knotless Search/
↑↓ move↵ open⇧↵ all results

chadtmiller.com/knotless

git that lives in your Atmosphere account

knotless.dev
1 collaborator

knotless 0.13.0 Latest 2 packages, 1 image

1
10

knotless-serve: A hide on a private repository shows on its page at once

Merged chadtmiller.com asked to merge into main from chadtmiller.com/knotless:serve/private-hide
crates/knotless-serve/src/web/threads.rs+11−13
@@ -378,12 +378,14 @@ pub async fn hide_item(
hid.await.map_err(refused)?;
let after = hides(&app, &repo, &input.subject).await?;
// Kept at keys of their own, each the time it was written: those
// there were go, and those there are now come in.
if let Some(index) = app.index.as_ref() {
// there were go, and those there are now come in, to the index the
// page reads next, the space's own for a private repository.
if let Some(index) = super::indexed(&app, &repo) {
let space = repo.in_space.as_deref();
let gone = before.iter();
let gone = gone.map(|h| index.delete(&repo.did, nsid::HIDE, &h.rkey));
let gone = gone.map(|h| index.delete_in(space, &repo.did, nsid::HIDE, &h.rkey));
let now = after.iter();
let now = now.map(|h| index.put(&repo.did, nsid::HIDE, &h.rkey, &h.value));
let now = now.map(|h| index.put_in(space, &repo.did, nsid::HIDE, &h.rkey, &h.value));
let wrote: rusqlite::Result<()> = gone.chain(now).collect();
wrote
.map_err(anyhow::Error::from)
@@ -394,18 +396,14 @@ pub async fn hide_item(
}))
}
/// The owner's hides of `subject`, as its repo has them now, where the
/// index keeps them: none for a private repository, whose are in its
/// space.
/// The owner's hides of `subject`, as their repo has them now, where an
/// index keeps them: for a private repository, their repo in its space,
/// read as the viewer.
async fn hides(app: &App, repo: &Repo, subject: &str) -> Result<Vec<Stored<Value>>> {
let mut found = Vec::new();
if app.index.is_some() && repo.in_space.is_none() {
let url = RepoUrl {
authority: repo.did.clone(),
name: repo.name.clone(),
};
if super::indexed(app, repo).is_some() {
let read = async {
let owner = Remote::connect(&app.ctx, &url).await?;
let owner = author(app, repo, &repo.did).await?;
owner.list_all::<Value>(nsid::HIDE).await
};
found = read.await.map_err(AppError::upstream)?;