mirror of
https://github.com/modrinth/code.git
synced 2026-08-25 00:55:25 +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:
@@ -169,6 +169,9 @@ GOTENBERG_URL=http://labrinth-gotenberg:13000
|
|||||||
GOTENBERG_CALLBACK_BASE=http://host.docker.internal:8000/_internal/gotenberg
|
GOTENBERG_CALLBACK_BASE=http://host.docker.internal:8000/_internal/gotenberg
|
||||||
GOTENBERG_TIMEOUT=30000
|
GOTENBERG_TIMEOUT=30000
|
||||||
|
|
||||||
|
SHARED_INSTANCES_URL=none
|
||||||
|
SHARED_INSTANCES_KEY=none
|
||||||
|
|
||||||
ARCHON_URL=none
|
ARCHON_URL=none
|
||||||
|
|
||||||
MURALPAY_API_URL=https://api.muralpay.com
|
MURALPAY_API_URL=https://api.muralpay.com
|
||||||
|
|||||||
@@ -195,6 +195,9 @@ GOTENBERG_URL=http://localhost:13000
|
|||||||
GOTENBERG_CALLBACK_BASE=http://host.docker.internal:8000/_internal/gotenberg
|
GOTENBERG_CALLBACK_BASE=http://host.docker.internal:8000/_internal/gotenberg
|
||||||
GOTENBERG_TIMEOUT=30000
|
GOTENBERG_TIMEOUT=30000
|
||||||
|
|
||||||
|
SHARED_INSTANCES_URL=none
|
||||||
|
SHARED_INSTANCES_KEY=none
|
||||||
|
|
||||||
ARCHON_URL=none
|
ARCHON_URL=none
|
||||||
|
|
||||||
MURALPAY_API_URL=https://api-staging.muralpay.com
|
MURALPAY_API_URL=https://api-staging.muralpay.com
|
||||||
|
|||||||
+4
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"db_name": "PostgreSQL",
|
"db_name": "PostgreSQL",
|
||||||
"query": "\n INSERT INTO reports (\n id, report_type_id, mod_id, version_id, user_id,\n body, reporter\n )\n VALUES (\n $1, $2, $3, $4, $5,\n $6, $7\n )\n ",
|
"query": "\n INSERT INTO reports (\n id, report_type_id, mod_id, version_id, user_id,\n shared_instance_id, shared_instance_version_id, body, reporter\n )\n VALUES (\n $1, $2, $3, $4, $5,\n $6, $7, $8, $9\n )\n ",
|
||||||
"describe": {
|
"describe": {
|
||||||
"columns": [],
|
"columns": [],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -10,11 +10,13 @@
|
|||||||
"Int8",
|
"Int8",
|
||||||
"Int8",
|
"Int8",
|
||||||
"Int8",
|
"Int8",
|
||||||
|
"Int8",
|
||||||
|
"Int4",
|
||||||
"Varchar",
|
"Varchar",
|
||||||
"Int8"
|
"Int8"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"nullable": []
|
"nullable": []
|
||||||
},
|
},
|
||||||
"hash": "c3f594d8d0ffcf5df1b36759cf3088bfaec496c5dfdbf496d3b05f0b122a5d0c"
|
"hash": "d03688d1840db14dc10cc942a8aa0b819aa1ee54f121d2c47903d44fc871e45e"
|
||||||
}
|
}
|
||||||
+18
-6
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"db_name": "PostgreSQL",
|
"db_name": "PostgreSQL",
|
||||||
"query": "\n 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\n FROM reports r\n INNER JOIN report_types rt ON rt.id = r.report_type_id\n INNER JOIN threads t ON t.report_id = r.id\n WHERE r.id = ANY($1)\n ORDER BY r.created DESC\n ",
|
"query": "\n 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\n FROM reports r\n INNER JOIN report_types rt ON rt.id = r.report_type_id\n INNER JOIN threads t ON t.report_id = r.id\n WHERE r.id = ANY($1)\n ORDER BY r.created DESC\n ",
|
||||||
"describe": {
|
"describe": {
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
@@ -30,26 +30,36 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 5,
|
"ordinal": 5,
|
||||||
|
"name": "shared_instance_id",
|
||||||
|
"type_info": "Int8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 6,
|
||||||
|
"name": "shared_instance_version_id",
|
||||||
|
"type_info": "Int4"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 7,
|
||||||
"name": "body",
|
"name": "body",
|
||||||
"type_info": "Varchar"
|
"type_info": "Varchar"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 6,
|
"ordinal": 8,
|
||||||
"name": "reporter",
|
"name": "reporter",
|
||||||
"type_info": "Int8"
|
"type_info": "Int8"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 7,
|
"ordinal": 9,
|
||||||
"name": "created",
|
"name": "created",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 8,
|
"ordinal": 10,
|
||||||
"name": "thread_id",
|
"name": "thread_id",
|
||||||
"type_info": "Int8"
|
"type_info": "Int8"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 9,
|
"ordinal": 11,
|
||||||
"name": "closed",
|
"name": "closed",
|
||||||
"type_info": "Bool"
|
"type_info": "Bool"
|
||||||
}
|
}
|
||||||
@@ -65,6 +75,8 @@
|
|||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
@@ -72,5 +84,5 @@
|
|||||||
false
|
false
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"hash": "6b7958eac5f273af8f37c0c888594e106fe323cbb3b0c32868b02f869d30f33f"
|
"hash": "de085413113d832b534db925b8bf1e50b852afea1c6e751664cae4fd9e789aab"
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
ALTER TABLE reports
|
||||||
|
ADD COLUMN shared_instance_id bigint,
|
||||||
|
ADD COLUMN shared_instance_version_id integer;
|
||||||
@@ -292,3 +292,4 @@ id_type!(StatusId as i32);
|
|||||||
id_type!(DelphiReportId as i64);
|
id_type!(DelphiReportId as i64);
|
||||||
id_type!(DelphiReportIssueId as i64);
|
id_type!(DelphiReportIssueId as i64);
|
||||||
id_type!(DelphiReportIssueDetailsId 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 project_id: Option<DBProjectId>,
|
||||||
pub version_id: Option<DBVersionId>,
|
pub version_id: Option<DBVersionId>,
|
||||||
pub user_id: Option<DBUserId>,
|
pub user_id: Option<DBUserId>,
|
||||||
|
pub shared_instance_id: Option<SharedInstanceId>,
|
||||||
|
pub shared_instance_version_id: Option<i32>,
|
||||||
pub body: String,
|
pub body: String,
|
||||||
pub reporter: DBUserId,
|
pub reporter: DBUserId,
|
||||||
pub created: DateTime<Utc>,
|
pub created: DateTime<Utc>,
|
||||||
@@ -21,6 +23,8 @@ pub struct ReportQueryResult {
|
|||||||
pub project_id: Option<DBProjectId>,
|
pub project_id: Option<DBProjectId>,
|
||||||
pub version_id: Option<DBVersionId>,
|
pub version_id: Option<DBVersionId>,
|
||||||
pub user_id: Option<DBUserId>,
|
pub user_id: Option<DBUserId>,
|
||||||
|
pub shared_instance_id: Option<SharedInstanceId>,
|
||||||
|
pub shared_instance_version_id: Option<i32>,
|
||||||
pub body: String,
|
pub body: String,
|
||||||
pub reporter: DBUserId,
|
pub reporter: DBUserId,
|
||||||
pub created: DateTime<Utc>,
|
pub created: DateTime<Utc>,
|
||||||
@@ -37,11 +41,11 @@ impl DBReport {
|
|||||||
"
|
"
|
||||||
INSERT INTO reports (
|
INSERT INTO reports (
|
||||||
id, report_type_id, mod_id, version_id, user_id,
|
id, report_type_id, mod_id, version_id, user_id,
|
||||||
body, reporter
|
shared_instance_id, shared_instance_version_id, body, reporter
|
||||||
)
|
)
|
||||||
VALUES (
|
VALUES (
|
||||||
$1, $2, $3, $4, $5,
|
$1, $2, $3, $4, $5,
|
||||||
$6, $7
|
$6, $7, $8, $9
|
||||||
)
|
)
|
||||||
",
|
",
|
||||||
self.id as DBReportId,
|
self.id as DBReportId,
|
||||||
@@ -49,6 +53,8 @@ impl DBReport {
|
|||||||
self.project_id.map(|x| x.0 as i64),
|
self.project_id.map(|x| x.0 as i64),
|
||||||
self.version_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.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.body,
|
||||||
self.reporter as DBUserId
|
self.reporter as DBUserId
|
||||||
)
|
)
|
||||||
@@ -83,7 +89,7 @@ impl DBReport {
|
|||||||
report_ids.iter().map(|x| x.0).collect();
|
report_ids.iter().map(|x| x.0).collect();
|
||||||
let reports = sqlx::query!(
|
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
|
FROM reports r
|
||||||
INNER JOIN report_types rt ON rt.id = r.report_type_id
|
INNER JOIN report_types rt ON rt.id = r.report_type_id
|
||||||
INNER JOIN threads t ON t.report_id = r.id
|
INNER JOIN threads t ON t.report_id = r.id
|
||||||
@@ -99,6 +105,8 @@ impl DBReport {
|
|||||||
project_id: x.mod_id.map(DBProjectId),
|
project_id: x.mod_id.map(DBProjectId),
|
||||||
version_id: x.version_id.map(DBVersionId),
|
version_id: x.version_id.map(DBVersionId),
|
||||||
user_id: x.user_id.map(DBUserId),
|
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,
|
body: x.body,
|
||||||
reporter: DBUserId(x.reporter),
|
reporter: DBUserId(x.reporter),
|
||||||
created: x.created,
|
created: x.created,
|
||||||
|
|||||||
@@ -312,6 +312,9 @@ vars! {
|
|||||||
|
|
||||||
DELPHI_URL: String = "";
|
DELPHI_URL: String = "";
|
||||||
|
|
||||||
|
SHARED_INSTANCES_URL: String = "";
|
||||||
|
SHARED_INSTANCES_KEY: String = "";
|
||||||
|
|
||||||
AVALARA_1099_API_URL: String = "https://www.track1099.com/api";
|
AVALARA_1099_API_URL: String = "https://www.track1099.com/api";
|
||||||
AVALARA_1099_API_KEY: String = "none";
|
AVALARA_1099_API_KEY: String = "none";
|
||||||
AVALARA_1099_API_TEAM_ID: String = "none";
|
AVALARA_1099_API_TEAM_ID: String = "none";
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ impl From<ItemType> for LegacyItemType {
|
|||||||
ItemType::Project => LegacyItemType::Project,
|
ItemType::Project => LegacyItemType::Project,
|
||||||
ItemType::Version => LegacyItemType::Version,
|
ItemType::Version => LegacyItemType::Version,
|
||||||
ItemType::User => LegacyItemType::User,
|
ItemType::User => LegacyItemType::User,
|
||||||
|
ItemType::SharedInstance => LegacyItemType::Unknown,
|
||||||
ItemType::Unknown => LegacyItemType::Unknown,
|
ItemType::Unknown => LegacyItemType::Unknown,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use crate::database::models::report_item::ReportQueryResult as DBReport;
|
use crate::database::models::report_item::ReportQueryResult as DBReport;
|
||||||
use crate::models::ids::{ProjectId, ReportId, ThreadId, VersionId};
|
use crate::models::ids::{ProjectId, ReportId, ThreadId, VersionId};
|
||||||
use ariadne::ids::UserId;
|
use ariadne::ids::UserId;
|
||||||
|
use ariadne::ids::base62_impl::to_base62;
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
@@ -10,6 +11,8 @@ pub struct Report {
|
|||||||
pub report_type: String,
|
pub report_type: String,
|
||||||
pub item_id: String,
|
pub item_id: String,
|
||||||
pub item_type: ItemType,
|
pub item_type: ItemType,
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub shared_instance_version_id: Option<i32>,
|
||||||
pub reporter: UserId,
|
pub reporter: UserId,
|
||||||
pub body: String,
|
pub body: String,
|
||||||
pub created: DateTime<Utc>,
|
pub created: DateTime<Utc>,
|
||||||
@@ -23,6 +26,7 @@ pub enum ItemType {
|
|||||||
Project,
|
Project,
|
||||||
Version,
|
Version,
|
||||||
User,
|
User,
|
||||||
|
SharedInstance,
|
||||||
Unknown,
|
Unknown,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,6 +36,7 @@ impl ItemType {
|
|||||||
ItemType::Project => "project",
|
ItemType::Project => "project",
|
||||||
ItemType::Version => "version",
|
ItemType::Version => "version",
|
||||||
ItemType::User => "user",
|
ItemType::User => "user",
|
||||||
|
ItemType::SharedInstance => "shared-instance",
|
||||||
ItemType::Unknown => "unknown",
|
ItemType::Unknown => "unknown",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -41,6 +46,7 @@ impl From<DBReport> for Report {
|
|||||||
fn from(x: DBReport) -> Self {
|
fn from(x: DBReport) -> Self {
|
||||||
let mut item_id = "".to_string();
|
let mut item_id = "".to_string();
|
||||||
let mut item_type = ItemType::Unknown;
|
let mut item_type = ItemType::Unknown;
|
||||||
|
let mut shared_instance_version_id = None;
|
||||||
|
|
||||||
if let Some(project_id) = x.project_id {
|
if let Some(project_id) = x.project_id {
|
||||||
item_id = ProjectId::from(project_id).to_string();
|
item_id = ProjectId::from(project_id).to_string();
|
||||||
@@ -51,6 +57,10 @@ impl From<DBReport> for Report {
|
|||||||
} else if let Some(user_id) = x.user_id {
|
} else if let Some(user_id) = x.user_id {
|
||||||
item_id = UserId::from(user_id).to_string();
|
item_id = UserId::from(user_id).to_string();
|
||||||
item_type = ItemType::User;
|
item_type = ItemType::User;
|
||||||
|
} else if let Some(shared_instance_id) = x.shared_instance_id {
|
||||||
|
item_id = to_base62(shared_instance_id.0 as u64);
|
||||||
|
item_type = ItemType::SharedInstance;
|
||||||
|
shared_instance_version_id = x.shared_instance_version_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
Report {
|
Report {
|
||||||
@@ -58,6 +68,7 @@ impl From<DBReport> for Report {
|
|||||||
report_type: x.report_type,
|
report_type: x.report_type,
|
||||||
item_id,
|
item_id,
|
||||||
item_type,
|
item_type,
|
||||||
|
shared_instance_version_id,
|
||||||
reporter: x.reporter.into(),
|
reporter: x.reporter.into(),
|
||||||
body: x.body,
|
body: x.body,
|
||||||
created: x.created,
|
created: x.created,
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
use crate::auth::{check_is_moderator_from_headers, get_user_from_headers};
|
use crate::auth::{check_is_moderator_from_headers, get_user_from_headers};
|
||||||
use crate::database;
|
use crate::database;
|
||||||
use crate::database::PgPool;
|
use crate::database::PgPool;
|
||||||
|
use crate::database::models::SharedInstanceId;
|
||||||
use crate::database::models::image_item;
|
use crate::database::models::image_item;
|
||||||
use crate::database::models::notification_item::NotificationBuilder;
|
use crate::database::models::notification_item::NotificationBuilder;
|
||||||
use crate::database::models::thread_item::{
|
use crate::database::models::thread_item::{
|
||||||
ThreadBuilder, ThreadMessageBuilder,
|
ThreadBuilder, ThreadMessageBuilder,
|
||||||
};
|
};
|
||||||
|
use crate::env::ENV;
|
||||||
use crate::models::ids::ImageId;
|
use crate::models::ids::ImageId;
|
||||||
use crate::models::ids::{ProjectId, VersionId};
|
use crate::models::ids::{ProjectId, VersionId};
|
||||||
use crate::models::images::{Image, ImageContext};
|
use crate::models::images::{Image, ImageContext};
|
||||||
@@ -15,11 +17,13 @@ use crate::models::reports::{ItemType, Report};
|
|||||||
use crate::models::threads::{MessageBody, ThreadType};
|
use crate::models::threads::{MessageBody, ThreadType};
|
||||||
use crate::queue::session::AuthQueue;
|
use crate::queue::session::AuthQueue;
|
||||||
use crate::routes::ApiError;
|
use crate::routes::ApiError;
|
||||||
|
use crate::util::error::Context;
|
||||||
|
use crate::util::http::HTTP_CLIENT;
|
||||||
use crate::util::img;
|
use crate::util::img;
|
||||||
use crate::util::routes::read_typed_from_payload;
|
use crate::util::routes::read_typed_from_payload;
|
||||||
use actix_web::{HttpRequest, HttpResponse, delete, get, patch, post, web};
|
use actix_web::{HttpRequest, HttpResponse, delete, get, patch, post, web};
|
||||||
use ariadne::ids::UserId;
|
use ariadne::ids::UserId;
|
||||||
use ariadne::ids::base62_impl::parse_base62;
|
use ariadne::ids::base62_impl::{parse_base62, to_base62};
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use validator::Validate;
|
use validator::Validate;
|
||||||
@@ -103,6 +107,8 @@ pub async fn report_create(
|
|||||||
project_id: None,
|
project_id: None,
|
||||||
version_id: None,
|
version_id: None,
|
||||||
user_id: None,
|
user_id: None,
|
||||||
|
shared_instance_id: None,
|
||||||
|
shared_instance_version_id: None,
|
||||||
body: new_report.body.clone(),
|
body: new_report.body.clone(),
|
||||||
reporter: current_user.id.into(),
|
reporter: current_user.id.into(),
|
||||||
created: Utc::now(),
|
created: Utc::now(),
|
||||||
@@ -169,6 +175,64 @@ pub async fn report_create(
|
|||||||
|
|
||||||
report.user_id = Some(user_id.into())
|
report.user_id = Some(user_id.into())
|
||||||
}
|
}
|
||||||
|
ItemType::SharedInstance => {
|
||||||
|
// parsing
|
||||||
|
let (instance_part, version_part) = new_report
|
||||||
|
.item_id
|
||||||
|
.split_once('/')
|
||||||
|
.ok_or_else(|| {
|
||||||
|
ApiError::InvalidInput(
|
||||||
|
"Shared instance reports must format the item ID as `instance_id/version_id`"
|
||||||
|
.to_string(),
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let shared_instance_id =
|
||||||
|
SharedInstanceId(parse_base62(instance_part)? as i64);
|
||||||
|
let shared_instance_version_id: i32 =
|
||||||
|
version_part.parse().map_err(|_| {
|
||||||
|
ApiError::InvalidInput(format!(
|
||||||
|
"Shared instance version is not a number: {version_part}"
|
||||||
|
))
|
||||||
|
})?;
|
||||||
|
|
||||||
|
// validation
|
||||||
|
let url = format!(
|
||||||
|
"{}/v1/instances/{}",
|
||||||
|
ENV.SHARED_INSTANCES_URL,
|
||||||
|
to_base62(shared_instance_id.0 as u64)
|
||||||
|
);
|
||||||
|
let instance_response = HTTP_CLIENT
|
||||||
|
.get(&url)
|
||||||
|
.bearer_auth(&ENV.SHARED_INSTANCES_KEY)
|
||||||
|
.send()
|
||||||
|
.await
|
||||||
|
.wrap_internal_err(
|
||||||
|
"failed to reach the shared instance service (instance lookup)",
|
||||||
|
)?;
|
||||||
|
|
||||||
|
if !instance_response.status().is_success() {
|
||||||
|
return Err(ApiError::InvalidInput(format!(
|
||||||
|
"Shared instance could not be found: {instance_part}"
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
|
let version_response = HTTP_CLIENT
|
||||||
|
.get(format!("{url}/versions/{version_part}"))
|
||||||
|
.bearer_auth(&ENV.SHARED_INSTANCES_KEY)
|
||||||
|
.send()
|
||||||
|
.await
|
||||||
|
.wrap_internal_err("failed to reach the shared instance service (version lookup)")?;
|
||||||
|
|
||||||
|
if !version_response.status().is_success() {
|
||||||
|
return Err(ApiError::InvalidInput(format!(
|
||||||
|
"Shared instance version could not be found: {instance_part}/{version_part}"
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
|
report.shared_instance_id = Some(shared_instance_id);
|
||||||
|
report.shared_instance_version_id = Some(shared_instance_version_id)
|
||||||
|
}
|
||||||
ItemType::Unknown => {
|
ItemType::Unknown => {
|
||||||
return Err(ApiError::InvalidInput(format!(
|
return Err(ApiError::InvalidInput(format!(
|
||||||
"Invalid report item type: {}",
|
"Invalid report item type: {}",
|
||||||
@@ -236,8 +300,12 @@ pub async fn report_create(
|
|||||||
Ok(HttpResponse::Ok().json(Report {
|
Ok(HttpResponse::Ok().json(Report {
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
report_type: new_report.report_type.clone(),
|
report_type: new_report.report_type.clone(),
|
||||||
item_id: new_report.item_id.clone(),
|
item_id: match report.shared_instance_id {
|
||||||
|
Some(shared_instance_id) => to_base62(shared_instance_id.0 as u64),
|
||||||
|
None => new_report.item_id.clone(),
|
||||||
|
},
|
||||||
item_type: new_report.item_type.clone(),
|
item_type: new_report.item_type.clone(),
|
||||||
|
shared_instance_version_id: report.shared_instance_version_id,
|
||||||
reporter: current_user.id,
|
reporter: current_user.id,
|
||||||
body: new_report.body.clone(),
|
body: new_report.body.clone(),
|
||||||
created: Utc::now(),
|
created: Utc::now(),
|
||||||
|
|||||||
Reference in New Issue
Block a user