You've already forked AstralRinth
forked from didirus/AstralRinth
Public discord webhook (#492)
This commit is contained in:
@@ -3,6 +3,7 @@ use super::DatabaseError;
|
||||
use chrono::DateTime;
|
||||
use chrono::Utc;
|
||||
use futures::TryStreamExt;
|
||||
use serde::Deserialize;
|
||||
|
||||
pub struct ProjectType {
|
||||
pub id: ProjectTypeId,
|
||||
@@ -16,12 +17,13 @@ pub struct Loader {
|
||||
pub supported_project_types: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Deserialize, Debug)]
|
||||
pub struct GameVersion {
|
||||
pub id: GameVersionId,
|
||||
pub version: String,
|
||||
pub version_type: String,
|
||||
pub date: DateTime<Utc>,
|
||||
#[serde(rename = "type")]
|
||||
pub type_: String,
|
||||
pub created: DateTime<Utc>,
|
||||
pub major: bool,
|
||||
}
|
||||
|
||||
@@ -507,8 +509,8 @@ impl GameVersion {
|
||||
.try_filter_map(|e| async { Ok(e.right().map(|c| GameVersion {
|
||||
id: GameVersionId(c.id),
|
||||
version: c.version_,
|
||||
version_type: c.type_,
|
||||
date: c.created,
|
||||
type_: c.type_,
|
||||
created: c.created,
|
||||
major: c.major
|
||||
})) })
|
||||
.try_collect::<Vec<GameVersion>>()
|
||||
@@ -542,8 +544,8 @@ impl GameVersion {
|
||||
.try_filter_map(|e| async { Ok(e.right().map(|c| GameVersion {
|
||||
id: GameVersionId(c.id),
|
||||
version: c.version_,
|
||||
version_type: c.type_,
|
||||
date: c.created,
|
||||
type_: c.type_,
|
||||
created: c.created,
|
||||
major: c.major,
|
||||
})) })
|
||||
.try_collect::<Vec<GameVersion>>()
|
||||
@@ -561,8 +563,8 @@ impl GameVersion {
|
||||
.try_filter_map(|e| async { Ok(e.right().map(|c| GameVersion {
|
||||
id: GameVersionId(c.id),
|
||||
version: c.version_,
|
||||
version_type: c.type_,
|
||||
date: c.created,
|
||||
type_: c.type_,
|
||||
created: c.created,
|
||||
major: c.major,
|
||||
})) })
|
||||
.try_collect::<Vec<GameVersion>>()
|
||||
@@ -581,8 +583,8 @@ impl GameVersion {
|
||||
.try_filter_map(|e| async { Ok(e.right().map(|c| GameVersion {
|
||||
id: GameVersionId(c.id),
|
||||
version: c.version_,
|
||||
version_type: c.type_,
|
||||
date: c.created,
|
||||
type_: c.type_,
|
||||
created: c.created,
|
||||
major: c.major,
|
||||
})) })
|
||||
.try_collect::<Vec<GameVersion>>()
|
||||
|
||||
@@ -2,6 +2,7 @@ use super::DatabaseError;
|
||||
use crate::models::ids::base62_impl::to_base62;
|
||||
use crate::models::ids::random_base62_rng;
|
||||
use censor::Censor;
|
||||
use serde::Deserialize;
|
||||
use sqlx::sqlx_macros::Type;
|
||||
|
||||
const ID_RETRY_COUNT: usize = 20;
|
||||
@@ -136,7 +137,7 @@ pub struct DonationPlatformId(pub i32);
|
||||
#[derive(Copy, Clone, Debug, Type, PartialEq, Eq, Hash)]
|
||||
#[sqlx(transparent)]
|
||||
pub struct VersionId(pub i64);
|
||||
#[derive(Copy, Clone, Debug, Type)]
|
||||
#[derive(Copy, Clone, Debug, Type, Deserialize)]
|
||||
#[sqlx(transparent)]
|
||||
pub struct GameVersionId(pub i32);
|
||||
#[derive(Copy, Clone, Debug, Type)]
|
||||
|
||||
@@ -134,6 +134,7 @@ impl ProjectBuilder {
|
||||
moderation_message_body: None,
|
||||
flame_anvil_project: None,
|
||||
flame_anvil_user: None,
|
||||
webhook_sent: false,
|
||||
};
|
||||
project_struct.insert(&mut *transaction).await?;
|
||||
|
||||
@@ -211,6 +212,7 @@ pub struct Project {
|
||||
pub moderation_message_body: Option<String>,
|
||||
pub flame_anvil_project: Option<i32>,
|
||||
pub flame_anvil_user: Option<UserId>,
|
||||
pub webhook_sent: bool,
|
||||
}
|
||||
|
||||
impl Project {
|
||||
@@ -277,7 +279,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
|
||||
flame_anvil_user, webhook_sent
|
||||
FROM mods
|
||||
WHERE id = $1
|
||||
",
|
||||
@@ -318,6 +320,7 @@ impl Project {
|
||||
approved: row.approved,
|
||||
flame_anvil_project: row.flame_anvil_project,
|
||||
flame_anvil_user: row.flame_anvil_user.map(UserId),
|
||||
webhook_sent: row.webhook_sent,
|
||||
}))
|
||||
} else {
|
||||
Ok(None)
|
||||
@@ -343,7 +346,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
|
||||
flame_anvil_user, webhook_sent
|
||||
FROM mods
|
||||
WHERE id = ANY($1)
|
||||
",
|
||||
@@ -384,6 +387,7 @@ impl Project {
|
||||
approved: m.approved,
|
||||
flame_anvil_project: m.flame_anvil_project,
|
||||
flame_anvil_user: m.flame_anvil_user.map(UserId),
|
||||
webhook_sent: m.webhook_sent,
|
||||
}))
|
||||
})
|
||||
.try_collect::<Vec<Project>>()
|
||||
@@ -662,7 +666,7 @@ impl Project {
|
||||
m.updated updated, m.approved approved, m.status status, m.requested_status requested_status,
|
||||
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,
|
||||
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 webhook_sent,
|
||||
ARRAY_AGG(DISTINCT c.category || ' |||| ' || mc.is_additional) filter (where c.category is not null) categories,
|
||||
ARRAY_AGG(DISTINCT v.id || ' |||| ' || v.date_published) filter (where v.id is not null) versions,
|
||||
ARRAY_AGG(DISTINCT mg.image_url || ' |||| ' || mg.featured || ' |||| ' || mg.created || ' |||| ' || COALESCE(mg.title, ' ') || ' |||| ' || COALESCE(mg.description, ' ')) filter (where mg.image_url is not null) gallery,
|
||||
@@ -736,6 +740,7 @@ impl Project {
|
||||
approved: m.approved,
|
||||
flame_anvil_project: m.flame_anvil_project,
|
||||
flame_anvil_user: m.flame_anvil_user.map(UserId),
|
||||
webhook_sent: m.webhook_sent,
|
||||
},
|
||||
project_type: m.project_type_name,
|
||||
categories,
|
||||
@@ -848,7 +853,7 @@ impl Project {
|
||||
m.updated updated, m.approved approved, m.status status, m.requested_status requested_status,
|
||||
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,
|
||||
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,
|
||||
ARRAY_AGG(DISTINCT c.category || ' |||| ' || mc.is_additional) filter (where c.category is not null) categories,
|
||||
ARRAY_AGG(DISTINCT v.id || ' |||| ' || v.date_published) filter (where v.id is not null) versions,
|
||||
ARRAY_AGG(DISTINCT mg.image_url || ' |||| ' || mg.featured || ' |||| ' || mg.created || ' |||| ' || COALESCE(mg.title, ' ') || ' |||| ' || COALESCE(mg.description, ' ')) filter (where mg.image_url is not null) gallery,
|
||||
@@ -925,7 +930,8 @@ impl Project {
|
||||
moderation_message_body: m.moderation_message_body,
|
||||
approved: m.approved,
|
||||
flame_anvil_project: m.flame_anvil_project,
|
||||
flame_anvil_user: m.flame_anvil_user.map(UserId)
|
||||
flame_anvil_user: m.flame_anvil_user.map(UserId),
|
||||
webhook_sent: m.webhook_sent,
|
||||
},
|
||||
project_type: m.project_type_name,
|
||||
categories,
|
||||
|
||||
Reference in New Issue
Block a user