use serde::{Deserialize, Serialize};
use std::{env, env::VarError};
-pub mod activity;
-pub mod category;
-pub mod comment;
-pub mod comment_report;
-pub mod comment_view;
-pub mod community;
-pub mod community_view;
-pub mod moderator;
-pub mod moderator_views;
-pub mod password_reset_request;
-pub mod post;
-pub mod post_report;
-pub mod post_view;
-pub mod private_message;
-pub mod private_message_view;
+pub mod aggregates;
pub mod schema;
-pub mod site;
-pub mod site_view;
-pub mod user;
-pub mod user_mention;
-pub mod user_mention_view;
-pub mod user_view;
+pub mod source;
+pub mod views;
pub type DbPool = diesel::r2d2::Pool<diesel::r2d2::ConnectionManager<diesel::PgConnection>>;
Self: Sized;
}
+pub trait ApubObject<T> {
+ fn read_from_apub_id(conn: &PgConnection, object_id: &str) -> Result<Self, Error>
+ where
+ Self: Sized;
+ fn upsert(conn: &PgConnection, user_form: &T) -> Result<Self, Error>
+ where
+ Self: Sized;
+}
+
pub trait MaybeOptional<T> {
fn get_optional(self) -> Option<T>;
}
}
}
+pub(crate) trait ToSafe {
+ type SafeColumns;
+ fn safe_columns_tuple() -> Self::SafeColumns;
+}
+
pub fn get_database_url_from_env() -> Result<String, VarError> {
env::var("LEMMY_DATABASE_URL")
}
Regex::new(r"^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$").unwrap();
}
+pub(crate) mod functions {
+ use diesel::sql_types::*;
+
+ sql_function! {
+ fn hot_rank(score: BigInt, time: Timestamp) -> Integer;
+ }
+}
+
#[cfg(test)]
mod tests {
use super::fuzzy_search;