feat(labrinth): project disclosures (#6945)

* feat(labrinth): project disclosures model

* feat(labrinth): project disclosures database model

* feat(labrinth): project disclosures get endpoint

* feat(labrinth): censor user ids if set by moderator

* feat(labrinth): wrap disclosures in struct

* feat(labrinth): edit project disclosures endpoint

* style(labrinth): cargo fmt

* style(labrinth): fix typo

* feat(labrinth): add fields for ai content disclosure

* fix(labrinth): field typo

* chore(labrinth): update query cache

* feat(labrinth): index disclosures in search

* refactor(labrinth): use enum instead of bools

* feat(labrinth): trigger incremental index on disclosure change

* feat(labrinth): change archived status to disclosure

* feat(labrinth): use disclosure for archival status

* fix(labrinth): error type for deserialization

* fix(labrinth): migration timestamp

* fix(labrinth): add disclosures to elasticsearch schema

* fix(labrinth): don't remove archival disclosure when changing status via v3 api

* feat(labrinth): derive str for ai usages and telemtry consent

* feat(labrinth): include ai usages and telemetry consent in disclosure types

* refactor(labrinth): move disclosure parsing to document creation

* fix(labrinth): prevent removing moderator added archival disclosures

* fix(labrinth): dedupe ai usages

* fix(labrinth): auth logic on archived disclosure removal

* feat(labrinth): add interactions field

* style(labrinth): cargo fmt

* feat(labrinth): soft delete disclosures

* feat(labrinth): return soft-deleted disclosures

* fix(labrinth): update disclosure on removal

---------

Co-authored-by: Prospector <6166773+Prospector@users.noreply.github.com>
This commit is contained in:
Sychic
2026-08-12 17:26:14 -07:00
committed by GitHub
parent 4b82cca3bf
commit 549b333eb2
39 changed files with 1305 additions and 214 deletions
+26 -9
View File
@@ -3,7 +3,10 @@ use std::convert::TryFrom;
use std::collections::HashMap;
use super::super::ids::OrganizationId;
use crate::database::models::{DatabaseError, version_item};
use crate::database::models::{
DBProjectDisclosure, DBProjectId, DatabaseError, version_item,
};
use crate::models::disclosures::ProjectDisclosureType;
use crate::models::ids::{ProjectId, TeamId, ThreadId, VersionId};
use crate::models::projects::{
Dependency, License, Link, Loader, ModeratorMessage, MonetizationStatus,
@@ -238,28 +241,42 @@ impl LegacyProject {
}
// Because from needs a version_item, this is a helper function to get many from one db query.
pub async fn from_many<'a, E>(
pub async fn from_many(
data: Vec<Project>,
exec: E,
pool: &crate::database::PgPool,
redis: &RedisPool,
) -> Result<Vec<Self>, DatabaseError>
where
E: crate::database::Acquire<'a, Database = sqlx::Postgres>,
{
) -> Result<Vec<Self>, DatabaseError> {
let version_ids: Vec<_> = data
.iter()
.filter_map(|p| p.versions.first().map(|i| (*i).into()))
.collect();
let project_ids: Vec<DBProjectId> =
data.iter().map(|p| p.id.into()).collect();
let example_versions =
version_item::DBVersion::get_many(&version_ids, exec, redis)
version_item::DBVersion::get_many(&version_ids, pool, redis)
.await?;
let archived_disclosure_ids = DBProjectDisclosure::projects_with_type(
ProjectDisclosureType::Archived,
&project_ids,
pool,
)
.await?;
let mut legacy_projects = Vec::new();
for project in data {
let version_item = example_versions
.iter()
.find(|v| v.inner.project_id == project.id.into())
.cloned();
let project = LegacyProject::from(project, version_item);
let has_archived_disclosure =
archived_disclosure_ids.contains(&project.id.into());
let mut project = LegacyProject::from(project, version_item);
if has_archived_disclosure
&& project.status == ProjectStatus::Approved
{
project.status = ProjectStatus::Archived;
}
legacy_projects.push(project);
}
Ok(legacy_projects)