You've already forked AstralRinth
forked from didirus/AstralRinth
Add report + moderation messaging (#567)
* Add report + moderation messaging * Add system messages * address review comments * Remove ds store * Update messaging * run prep --------- Co-authored-by: Geometrically <geometrically@Jais-MacBook-Pro.local>
This commit is contained in:
@@ -101,6 +101,7 @@ pub struct ProjectBuilder {
|
||||
pub donation_urls: Vec<DonationUrl>,
|
||||
pub gallery_items: Vec<GalleryItem>,
|
||||
pub color: Option<u32>,
|
||||
pub thread_id: ThreadId,
|
||||
}
|
||||
|
||||
impl ProjectBuilder {
|
||||
@@ -146,6 +147,7 @@ impl ProjectBuilder {
|
||||
color: self.color,
|
||||
loaders: vec![],
|
||||
game_versions: vec![],
|
||||
thread_id: Some(self.thread_id),
|
||||
};
|
||||
project_struct.insert(&mut *transaction).await?;
|
||||
|
||||
@@ -230,6 +232,7 @@ pub struct Project {
|
||||
pub color: Option<u32>,
|
||||
pub loaders: Vec<String>,
|
||||
pub game_versions: Vec<String>,
|
||||
pub thread_id: Option<ThreadId>,
|
||||
}
|
||||
|
||||
impl Project {
|
||||
@@ -244,14 +247,14 @@ impl Project {
|
||||
published, downloads, icon_url, issues_url,
|
||||
source_url, wiki_url, status, requested_status, discord_url,
|
||||
client_side, server_side, license_url, license,
|
||||
slug, project_type, color
|
||||
slug, project_type, color, thread_id
|
||||
)
|
||||
VALUES (
|
||||
$1, $2, $3, $4, $5,
|
||||
$6, $7, $8, $9,
|
||||
$10, $11, $12, $13, $14,
|
||||
$15, $16, $17, $18,
|
||||
LOWER($19), $20, $21
|
||||
LOWER($19), $20, $21, $22
|
||||
)
|
||||
",
|
||||
self.id as ProjectId,
|
||||
@@ -274,7 +277,8 @@ impl Project {
|
||||
&self.license,
|
||||
self.slug.as_ref(),
|
||||
self.project_type as ProjectTypeId,
|
||||
self.color.map(|x| x as i32)
|
||||
self.color.map(|x| x as i32),
|
||||
self.thread_id.map(|x| x.0),
|
||||
)
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
@@ -313,7 +317,7 @@ impl Project {
|
||||
issues_url, source_url, wiki_url, discord_url, license_url,
|
||||
team_id, client_side, server_side, license, slug,
|
||||
moderation_message, moderation_message_body, flame_anvil_project,
|
||||
flame_anvil_user, webhook_sent, color, loaders, game_versions
|
||||
flame_anvil_user, webhook_sent, color, loaders, game_versions, thread_id
|
||||
FROM mods
|
||||
WHERE id = ANY($1)
|
||||
",
|
||||
@@ -359,6 +363,7 @@ impl Project {
|
||||
loaders: m.loaders,
|
||||
game_versions: m.game_versions,
|
||||
queued: m.queued,
|
||||
thread_id: m.thread_id.map(ThreadId),
|
||||
}))
|
||||
})
|
||||
.try_collect::<Vec<Project>>()
|
||||
@@ -386,6 +391,26 @@ impl Project {
|
||||
return Ok(None);
|
||||
};
|
||||
|
||||
let thread_id = sqlx::query!(
|
||||
"
|
||||
SELECT thread_id FROM mods
|
||||
WHERE id = $1
|
||||
",
|
||||
id as ProjectId
|
||||
)
|
||||
.fetch_optional(&mut *transaction)
|
||||
.await?;
|
||||
|
||||
if let Some(thread_id) = thread_id {
|
||||
if let Some(id) = thread_id.thread_id {
|
||||
crate::database::models::Thread::remove_full(
|
||||
ThreadId(id),
|
||||
transaction,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
||||
sqlx::query!(
|
||||
"
|
||||
DELETE FROM mod_follows
|
||||
@@ -654,7 +679,7 @@ impl Project {
|
||||
m.issues_url issues_url, m.source_url source_url, m.wiki_url wiki_url, m.discord_url discord_url, m.license_url license_url,
|
||||
m.team_id team_id, m.client_side client_side, m.server_side server_side, m.license license, m.slug slug, m.moderation_message moderation_message, m.moderation_message_body moderation_message_body,
|
||||
cs.name client_side_type, ss.name server_side_type, pt.name project_type_name, m.flame_anvil_project flame_anvil_project, m.flame_anvil_user flame_anvil_user, m.webhook_sent, m.color,
|
||||
m.loaders loaders, m.game_versions game_versions,
|
||||
m.loaders loaders, m.game_versions game_versions, m.thread_id thread_id,
|
||||
ARRAY_AGG(DISTINCT c.category) filter (where c.category is not null and mc.is_additional is false) categories,
|
||||
ARRAY_AGG(DISTINCT c.category) filter (where c.category is not null and mc.is_additional is true) additional_categories,
|
||||
JSONB_AGG(DISTINCT jsonb_build_object('id', v.id, 'date_published', v.date_published)) filter (where v.id is not null) versions,
|
||||
@@ -720,6 +745,7 @@ impl Project {
|
||||
loaders: m.loaders,
|
||||
game_versions: m.game_versions,
|
||||
queued: m.queued,
|
||||
thread_id: m.thread_id.map(ThreadId),
|
||||
},
|
||||
project_type: m.project_type_name,
|
||||
categories: m.categories.unwrap_or_default(),
|
||||
|
||||
Reference in New Issue
Block a user