e78ba38e94
* Use URL type in most outstanding struct fields This fixes all known remaining cases where url fields are stored as plain strings, with the exception of form fields where empty strings are used as sentinels (see `diesel_option_overwrite_to_url`). Tested for regressions in the federated docker setup attempting to exercise all changed fields, including through apub federation. Fixes #1385 * Add migration to fix blank-string post.url values to be null This also then fixes #602 * Address review feedback - Fixed some unwraps and err message formatting - Bumped the `url` library to 2.2.1 to fix a bug with serde error messages - Add unit tests for the two diesel option override functions - Fix migration teardown by adding a no-op * Rename lemmy_db_queries::Url to lemmy_db_queries::DbUrl * fix compile error * box PostOrComment variants
32 lines
898 B
Rust
32 lines
898 B
Rust
use crate::{schema::post_report, source::post::Post, DbUrl};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(
|
|
Identifiable, Queryable, Associations, PartialEq, Serialize, Deserialize, Debug, Clone,
|
|
)]
|
|
#[belongs_to(Post)]
|
|
#[table_name = "post_report"]
|
|
pub struct PostReport {
|
|
pub id: i32,
|
|
pub creator_id: i32,
|
|
pub post_id: i32,
|
|
pub original_post_name: String,
|
|
pub original_post_url: Option<DbUrl>,
|
|
pub original_post_body: Option<String>,
|
|
pub reason: String,
|
|
pub resolved: bool,
|
|
pub resolver_id: Option<i32>,
|
|
pub published: chrono::NaiveDateTime,
|
|
pub updated: Option<chrono::NaiveDateTime>,
|
|
}
|
|
|
|
#[derive(Insertable, AsChangeset, Clone)]
|
|
#[table_name = "post_report"]
|
|
pub struct PostReportForm {
|
|
pub creator_id: i32,
|
|
pub post_id: i32,
|
|
pub original_post_name: String,
|
|
pub original_post_url: Option<DbUrl>,
|
|
pub original_post_body: Option<String>,
|
|
pub reason: String,
|
|
}
|