mirror of
https://github.com/modrinth/code.git
synced 2026-08-27 01:54:47 +00:00
feat(labrinth): shared instances moderation (#6784)
* feat(labrinth): shared instance report type * style(labrinth): cargo fmt * feat(labrinth): check that instance exists when reporting * style(labrinth): cleanup unused import * feat(labrinth): store version id for shared instance reports * style(labrinth): satisfy clippy * fix(labrinth): use string id instead of int
This commit is contained in:
@@ -292,3 +292,4 @@ id_type!(StatusId as i32);
|
||||
id_type!(DelphiReportId as i64);
|
||||
id_type!(DelphiReportIssueId as i64);
|
||||
id_type!(DelphiReportIssueDetailsId as i64);
|
||||
id_type!(SharedInstanceId as i64);
|
||||
|
||||
@@ -9,6 +9,8 @@ pub struct DBReport {
|
||||
pub project_id: Option<DBProjectId>,
|
||||
pub version_id: Option<DBVersionId>,
|
||||
pub user_id: Option<DBUserId>,
|
||||
pub shared_instance_id: Option<SharedInstanceId>,
|
||||
pub shared_instance_version_id: Option<i32>,
|
||||
pub body: String,
|
||||
pub reporter: DBUserId,
|
||||
pub created: DateTime<Utc>,
|
||||
@@ -21,6 +23,8 @@ pub struct ReportQueryResult {
|
||||
pub project_id: Option<DBProjectId>,
|
||||
pub version_id: Option<DBVersionId>,
|
||||
pub user_id: Option<DBUserId>,
|
||||
pub shared_instance_id: Option<SharedInstanceId>,
|
||||
pub shared_instance_version_id: Option<i32>,
|
||||
pub body: String,
|
||||
pub reporter: DBUserId,
|
||||
pub created: DateTime<Utc>,
|
||||
@@ -37,11 +41,11 @@ impl DBReport {
|
||||
"
|
||||
INSERT INTO reports (
|
||||
id, report_type_id, mod_id, version_id, user_id,
|
||||
body, reporter
|
||||
shared_instance_id, shared_instance_version_id, body, reporter
|
||||
)
|
||||
VALUES (
|
||||
$1, $2, $3, $4, $5,
|
||||
$6, $7
|
||||
$6, $7, $8, $9
|
||||
)
|
||||
",
|
||||
self.id as DBReportId,
|
||||
@@ -49,6 +53,8 @@ impl DBReport {
|
||||
self.project_id.map(|x| x.0 as i64),
|
||||
self.version_id.map(|x| x.0 as i64),
|
||||
self.user_id.map(|x| x.0 as i64),
|
||||
self.shared_instance_id.map(|x| x.0 as i64),
|
||||
self.shared_instance_version_id,
|
||||
self.body,
|
||||
self.reporter as DBUserId
|
||||
)
|
||||
@@ -83,7 +89,7 @@ impl DBReport {
|
||||
report_ids.iter().map(|x| x.0).collect();
|
||||
let reports = sqlx::query!(
|
||||
"
|
||||
SELECT r.id, rt.name, r.mod_id, r.version_id, r.user_id, r.body, r.reporter, r.created, t.id thread_id, r.closed
|
||||
SELECT r.id, rt.name, r.mod_id, r.version_id, r.user_id, r.shared_instance_id, r.shared_instance_version_id, r.body, r.reporter, r.created, t.id thread_id, r.closed
|
||||
FROM reports r
|
||||
INNER JOIN report_types rt ON rt.id = r.report_type_id
|
||||
INNER JOIN threads t ON t.report_id = r.id
|
||||
@@ -99,6 +105,8 @@ impl DBReport {
|
||||
project_id: x.mod_id.map(DBProjectId),
|
||||
version_id: x.version_id.map(DBVersionId),
|
||||
user_id: x.user_id.map(DBUserId),
|
||||
shared_instance_id: x.shared_instance_id.map(SharedInstanceId),
|
||||
shared_instance_version_id: x.shared_instance_version_id,
|
||||
body: x.body,
|
||||
reporter: DBUserId(x.reporter),
|
||||
created: x.created,
|
||||
|
||||
Reference in New Issue
Block a user