lemmy/crates/db_schema/src/source/community_report.rs
Dessalines 42bd941f35
Upgrading ts-rs, and adding feature flag (#5777)
* Upgrading ts-rs, and adding feature flag.

- Lets us remove all the ts-optionals on every field.
- Should speed up compilation, and this feature is only needed for
  lemmy-js-client.
- Fixes #5741

* Removing ts_optional_fields from enums

* Updating translations.

* Fix tests

* Fixing translations

* Adding ts-rs feature to ts_bindings script

* Consolidating optional fields and export to one line.

* Dont export federation_queue_state
2025-06-12 16:30:48 +02:00

54 lines
1.9 KiB
Rust

use crate::newtypes::{CommunityId, CommunityReportId, DbUrl, PersonId};
use chrono::{DateTime, Utc};
#[cfg(feature = "full")]
use lemmy_db_schema_file::schema::community_report;
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
#[skip_serializing_none]
#[derive(PartialEq, Eq, Serialize, Deserialize, Debug, Clone)]
#[cfg_attr(
feature = "full",
derive(Queryable, Selectable, Associations, Identifiable)
)]
#[cfg_attr(
feature = "full",
diesel(belongs_to(crate::source::community::Community))
)]
#[cfg_attr(feature = "full", diesel(table_name = community_report))]
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))]
/// A comment report.
pub struct CommunityReport {
pub id: CommunityReportId,
pub creator_id: PersonId,
pub community_id: CommunityId,
pub original_community_name: String,
pub original_community_title: String,
pub original_community_description: Option<String>,
pub original_community_sidebar: Option<String>,
pub original_community_icon: Option<String>,
pub original_community_banner: Option<String>,
pub reason: String,
pub resolved: bool,
pub resolver_id: Option<PersonId>,
pub published_at: DateTime<Utc>,
pub updated_at: Option<DateTime<Utc>>,
}
#[derive(Clone)]
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
#[cfg_attr(feature = "full", diesel(table_name = community_report))]
pub struct CommunityReportForm {
pub creator_id: PersonId,
pub community_id: CommunityId,
pub original_community_name: String,
pub original_community_title: String,
pub original_community_description: Option<String>,
pub original_community_sidebar: Option<String>,
pub original_community_icon: Option<DbUrl>,
pub original_community_banner: Option<DbUrl>,
pub reason: String,
}