mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-08 09:24:17 +00:00
Split lemmy_db into separate workspaces
This commit is contained in:
parent
6d96f105c6
commit
089d812dc8
9
Cargo.lock
generated
9
Cargo.lock
generated
|
@ -1789,6 +1789,7 @@ dependencies = [
|
|||
"chrono",
|
||||
"diesel",
|
||||
"lazy_static",
|
||||
"lemmy_db_schema",
|
||||
"lemmy_utils",
|
||||
"log",
|
||||
"regex",
|
||||
|
@ -1800,6 +1801,13 @@ dependencies = [
|
|||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lemmy_db_schema"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"diesel",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lemmy_rate_limit"
|
||||
version = "0.1.0"
|
||||
|
@ -1835,6 +1843,7 @@ dependencies = [
|
|||
"lemmy_api",
|
||||
"lemmy_apub",
|
||||
"lemmy_db",
|
||||
"lemmy_db_schema",
|
||||
"lemmy_rate_limit",
|
||||
"lemmy_structs",
|
||||
"lemmy_utils",
|
||||
|
|
|
@ -12,6 +12,7 @@ members = [
|
|||
"lemmy_apub",
|
||||
"lemmy_utils",
|
||||
"lemmy_db",
|
||||
"lemmy_db_schema",
|
||||
"lemmy_structs",
|
||||
"lemmy_rate_limit",
|
||||
"lemmy_websocket",
|
||||
|
@ -21,6 +22,7 @@ members = [
|
|||
lemmy_api = { path = "./lemmy_api" }
|
||||
lemmy_apub = { path = "./lemmy_apub" }
|
||||
lemmy_utils = { path = "./lemmy_utils" }
|
||||
lemmy_db_schema = { path = "./lemmy_db_schema" }
|
||||
lemmy_db = { path = "./lemmy_db" }
|
||||
lemmy_structs = { path = "./lemmy_structs" }
|
||||
lemmy_rate_limit = { path = "./lemmy_rate_limit" }
|
||||
|
|
|
@ -9,6 +9,7 @@ path = "src/lib.rs"
|
|||
|
||||
[dependencies]
|
||||
lemmy_utils = { path = "../lemmy_utils" }
|
||||
lemmy_db_schema = { path = "../lemmy_db_schema" }
|
||||
diesel = { version = "1.4.5", features = ["postgres","chrono","r2d2","serde_json"] }
|
||||
chrono = { version = "0.4.19", features = ["serde"] }
|
||||
serde = { version = "1.0.118", features = ["derive"] }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::schema::comment_aggregates;
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::schema::comment_aggregates;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Queryable, Associations, Identifiable, PartialEq, Debug, Serialize, Clone)]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::schema::community_aggregates;
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::schema::community_aggregates;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Queryable, Associations, Identifiable, PartialEq, Debug, Serialize, Clone)]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::schema::post_aggregates;
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::schema::post_aggregates;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Queryable, Associations, Identifiable, PartialEq, Debug, Serialize, Clone)]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::schema::site_aggregates;
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::schema::site_aggregates;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Queryable, Associations, Identifiable, PartialEq, Debug, Serialize)]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::schema::user_aggregates;
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::schema::user_aggregates;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Queryable, Associations, Identifiable, PartialEq, Debug, Serialize, Clone)]
|
||||
|
|
|
@ -12,7 +12,6 @@ use serde::{Deserialize, Serialize};
|
|||
use std::{env, env::VarError};
|
||||
|
||||
pub mod aggregates;
|
||||
pub mod schema;
|
||||
pub mod source;
|
||||
pub mod views;
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use crate::{schema::activity, Crud};
|
||||
use crate::Crud;
|
||||
use diesel::{dsl::*, result::Error, *};
|
||||
use lemmy_db_schema::schema::activity;
|
||||
use log::debug;
|
||||
use serde::Serialize;
|
||||
use serde_json::Value;
|
||||
|
@ -32,12 +33,12 @@ pub struct ActivityForm {
|
|||
|
||||
impl Crud<ActivityForm> for Activity {
|
||||
fn read(conn: &PgConnection, activity_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::activity::dsl::*;
|
||||
use lemmy_db_schema::schema::activity::dsl::*;
|
||||
activity.find(activity_id).first::<Self>(conn)
|
||||
}
|
||||
|
||||
fn create(conn: &PgConnection, new_activity: &ActivityForm) -> Result<Self, Error> {
|
||||
use crate::schema::activity::dsl::*;
|
||||
use lemmy_db_schema::schema::activity::dsl::*;
|
||||
insert_into(activity)
|
||||
.values(new_activity)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -48,13 +49,13 @@ impl Crud<ActivityForm> for Activity {
|
|||
activity_id: i32,
|
||||
new_activity: &ActivityForm,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::activity::dsl::*;
|
||||
use lemmy_db_schema::schema::activity::dsl::*;
|
||||
diesel::update(activity.find(activity_id))
|
||||
.set(new_activity)
|
||||
.get_result::<Self>(conn)
|
||||
}
|
||||
fn delete(conn: &PgConnection, activity_id: i32) -> Result<usize, Error> {
|
||||
use crate::schema::activity::dsl::*;
|
||||
use lemmy_db_schema::schema::activity::dsl::*;
|
||||
diesel::delete(activity.find(activity_id)).execute(conn)
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +90,7 @@ impl Activity {
|
|||
}
|
||||
|
||||
pub fn read_from_apub_id(conn: &PgConnection, object_id: &str) -> Result<Self, Error> {
|
||||
use crate::schema::activity::dsl::*;
|
||||
use lemmy_db_schema::schema::activity::dsl::*;
|
||||
activity.filter(ap_id.eq(object_id)).first::<Self>(conn)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
use crate::{
|
||||
schema::{category, category::dsl::*},
|
||||
Crud,
|
||||
};
|
||||
use crate::Crud;
|
||||
use diesel::{dsl::*, result::Error, *};
|
||||
use lemmy_db_schema::schema::{category, category::dsl::*};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Clone)]
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
use super::post::Post;
|
||||
use crate::{
|
||||
naive_now,
|
||||
schema::{comment, comment_alias_1, comment_like, comment_saved},
|
||||
ApubObject,
|
||||
Crud,
|
||||
Likeable,
|
||||
Saveable,
|
||||
};
|
||||
use crate::{naive_now, ApubObject, Crud, Likeable, Saveable};
|
||||
use diesel::{dsl::*, result::Error, *};
|
||||
use lemmy_db_schema::schema::{comment, comment_alias_1, comment_like, comment_saved};
|
||||
use serde::Serialize;
|
||||
use url::{ParseError, Url};
|
||||
|
||||
|
@ -78,17 +72,17 @@ impl CommentForm {
|
|||
|
||||
impl Crud<CommentForm> for Comment {
|
||||
fn read(conn: &PgConnection, comment_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::comment::dsl::*;
|
||||
use lemmy_db_schema::schema::comment::dsl::*;
|
||||
comment.find(comment_id).first::<Self>(conn)
|
||||
}
|
||||
|
||||
fn delete(conn: &PgConnection, comment_id: i32) -> Result<usize, Error> {
|
||||
use crate::schema::comment::dsl::*;
|
||||
use lemmy_db_schema::schema::comment::dsl::*;
|
||||
diesel::delete(comment.find(comment_id)).execute(conn)
|
||||
}
|
||||
|
||||
fn create(conn: &PgConnection, comment_form: &CommentForm) -> Result<Self, Error> {
|
||||
use crate::schema::comment::dsl::*;
|
||||
use lemmy_db_schema::schema::comment::dsl::*;
|
||||
insert_into(comment)
|
||||
.values(comment_form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -99,7 +93,7 @@ impl Crud<CommentForm> for Comment {
|
|||
comment_id: i32,
|
||||
comment_form: &CommentForm,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::comment::dsl::*;
|
||||
use lemmy_db_schema::schema::comment::dsl::*;
|
||||
diesel::update(comment.find(comment_id))
|
||||
.set(comment_form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -108,12 +102,12 @@ impl Crud<CommentForm> for Comment {
|
|||
|
||||
impl ApubObject<CommentForm> for Comment {
|
||||
fn read_from_apub_id(conn: &PgConnection, object_id: &str) -> Result<Self, Error> {
|
||||
use crate::schema::comment::dsl::*;
|
||||
use lemmy_db_schema::schema::comment::dsl::*;
|
||||
comment.filter(ap_id.eq(object_id)).first::<Self>(conn)
|
||||
}
|
||||
|
||||
fn upsert(conn: &PgConnection, comment_form: &CommentForm) -> Result<Self, Error> {
|
||||
use crate::schema::comment::dsl::*;
|
||||
use lemmy_db_schema::schema::comment::dsl::*;
|
||||
insert_into(comment)
|
||||
.values(comment_form)
|
||||
.on_conflict(ap_id)
|
||||
|
@ -129,7 +123,7 @@ impl Comment {
|
|||
comment_id: i32,
|
||||
apub_id: String,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::comment::dsl::*;
|
||||
use lemmy_db_schema::schema::comment::dsl::*;
|
||||
|
||||
diesel::update(comment.find(comment_id))
|
||||
.set(ap_id.eq(apub_id))
|
||||
|
@ -140,7 +134,7 @@ impl Comment {
|
|||
conn: &PgConnection,
|
||||
for_creator_id: i32,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
use crate::schema::comment::dsl::*;
|
||||
use lemmy_db_schema::schema::comment::dsl::*;
|
||||
diesel::update(comment.filter(creator_id.eq(for_creator_id)))
|
||||
.set((
|
||||
content.eq("*Permananently Deleted*"),
|
||||
|
@ -155,7 +149,7 @@ impl Comment {
|
|||
comment_id: i32,
|
||||
new_deleted: bool,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::comment::dsl::*;
|
||||
use lemmy_db_schema::schema::comment::dsl::*;
|
||||
diesel::update(comment.find(comment_id))
|
||||
.set((deleted.eq(new_deleted), updated.eq(naive_now())))
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -166,7 +160,7 @@ impl Comment {
|
|||
comment_id: i32,
|
||||
new_removed: bool,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::comment::dsl::*;
|
||||
use lemmy_db_schema::schema::comment::dsl::*;
|
||||
diesel::update(comment.find(comment_id))
|
||||
.set((removed.eq(new_removed), updated.eq(naive_now())))
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -177,14 +171,14 @@ impl Comment {
|
|||
for_creator_id: i32,
|
||||
new_removed: bool,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
use crate::schema::comment::dsl::*;
|
||||
use lemmy_db_schema::schema::comment::dsl::*;
|
||||
diesel::update(comment.filter(creator_id.eq(for_creator_id)))
|
||||
.set((removed.eq(new_removed), updated.eq(naive_now())))
|
||||
.get_results::<Self>(conn)
|
||||
}
|
||||
|
||||
pub fn update_read(conn: &PgConnection, comment_id: i32, new_read: bool) -> Result<Self, Error> {
|
||||
use crate::schema::comment::dsl::*;
|
||||
use lemmy_db_schema::schema::comment::dsl::*;
|
||||
diesel::update(comment.find(comment_id))
|
||||
.set(read.eq(new_read))
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -195,7 +189,7 @@ impl Comment {
|
|||
comment_id: i32,
|
||||
new_content: &str,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::comment::dsl::*;
|
||||
use lemmy_db_schema::schema::comment::dsl::*;
|
||||
diesel::update(comment.find(comment_id))
|
||||
.set((content.eq(new_content), updated.eq(naive_now())))
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -225,7 +219,7 @@ pub struct CommentLikeForm {
|
|||
|
||||
impl Likeable<CommentLikeForm> for CommentLike {
|
||||
fn like(conn: &PgConnection, comment_like_form: &CommentLikeForm) -> Result<Self, Error> {
|
||||
use crate::schema::comment_like::dsl::*;
|
||||
use lemmy_db_schema::schema::comment_like::dsl::*;
|
||||
insert_into(comment_like)
|
||||
.values(comment_like_form)
|
||||
.on_conflict((comment_id, user_id))
|
||||
|
@ -234,7 +228,7 @@ impl Likeable<CommentLikeForm> for CommentLike {
|
|||
.get_result::<Self>(conn)
|
||||
}
|
||||
fn remove(conn: &PgConnection, user_id: i32, comment_id: i32) -> Result<usize, Error> {
|
||||
use crate::schema::comment_like::dsl;
|
||||
use lemmy_db_schema::schema::comment_like::dsl;
|
||||
diesel::delete(
|
||||
dsl::comment_like
|
||||
.filter(dsl::comment_id.eq(comment_id))
|
||||
|
@ -263,7 +257,7 @@ pub struct CommentSavedForm {
|
|||
|
||||
impl Saveable<CommentSavedForm> for CommentSaved {
|
||||
fn save(conn: &PgConnection, comment_saved_form: &CommentSavedForm) -> Result<Self, Error> {
|
||||
use crate::schema::comment_saved::dsl::*;
|
||||
use lemmy_db_schema::schema::comment_saved::dsl::*;
|
||||
insert_into(comment_saved)
|
||||
.values(comment_saved_form)
|
||||
.on_conflict((comment_id, user_id))
|
||||
|
@ -272,7 +266,7 @@ impl Saveable<CommentSavedForm> for CommentSaved {
|
|||
.get_result::<Self>(conn)
|
||||
}
|
||||
fn unsave(conn: &PgConnection, comment_saved_form: &CommentSavedForm) -> Result<usize, Error> {
|
||||
use crate::schema::comment_saved::dsl::*;
|
||||
use lemmy_db_schema::schema::comment_saved::dsl::*;
|
||||
diesel::delete(
|
||||
comment_saved
|
||||
.filter(comment_id.eq(comment_saved_form.comment_id))
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::{naive_now, source::comment::Comment, Reportable};
|
||||
use diesel::{dsl::*, result::Error, *};
|
||||
use lemmy_db_schema::schema::comment_report;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{naive_now, schema::comment_report, source::comment::Comment, Reportable};
|
||||
|
||||
#[derive(Identifiable, Queryable, Associations, PartialEq, Serialize, Deserialize, Debug, Clone)]
|
||||
#[belongs_to(Comment)]
|
||||
#[table_name = "comment_report"]
|
||||
|
@ -33,7 +33,7 @@ impl Reportable<CommentReportForm> for CommentReport {
|
|||
/// * `conn` - the postgres connection
|
||||
/// * `comment_report_form` - the filled CommentReportForm to insert
|
||||
fn report(conn: &PgConnection, comment_report_form: &CommentReportForm) -> Result<Self, Error> {
|
||||
use crate::schema::comment_report::dsl::*;
|
||||
use lemmy_db_schema::schema::comment_report::dsl::*;
|
||||
insert_into(comment_report)
|
||||
.values(comment_report_form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -45,7 +45,7 @@ impl Reportable<CommentReportForm> for CommentReport {
|
|||
/// * `report_id` - the id of the report to resolve
|
||||
/// * `by_resolver_id` - the id of the user resolving the report
|
||||
fn resolve(conn: &PgConnection, report_id: i32, by_resolver_id: i32) -> Result<usize, Error> {
|
||||
use crate::schema::comment_report::dsl::*;
|
||||
use lemmy_db_schema::schema::comment_report::dsl::*;
|
||||
update(comment_report.find(report_id))
|
||||
.set((
|
||||
resolved.eq(true),
|
||||
|
@ -61,7 +61,7 @@ impl Reportable<CommentReportForm> for CommentReport {
|
|||
/// * `report_id` - the id of the report to unresolve
|
||||
/// * `by_resolver_id` - the id of the user unresolving the report
|
||||
fn unresolve(conn: &PgConnection, report_id: i32, by_resolver_id: i32) -> Result<usize, Error> {
|
||||
use crate::schema::comment_report::dsl::*;
|
||||
use lemmy_db_schema::schema::comment_report::dsl::*;
|
||||
update(comment_report.find(report_id))
|
||||
.set((
|
||||
resolved.eq(false),
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use crate::{
|
||||
naive_now,
|
||||
schema::{community, community_follower, community_moderator, community_user_ban},
|
||||
views::{community::community_moderator_view::CommunityModeratorView, user_view::UserViewSafe},
|
||||
ApubObject,
|
||||
Bannable,
|
||||
|
@ -9,6 +8,12 @@ use crate::{
|
|||
Joinable,
|
||||
};
|
||||
use diesel::{dsl::*, result::Error, *};
|
||||
use lemmy_db_schema::schema::{
|
||||
community,
|
||||
community_follower,
|
||||
community_moderator,
|
||||
community_user_ban,
|
||||
};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
|
||||
|
@ -56,7 +61,8 @@ pub struct CommunitySafe {
|
|||
}
|
||||
|
||||
mod safe_type {
|
||||
use crate::{schema::community::columns::*, source::community::Community, ToSafe};
|
||||
use crate::{source::community::Community, ToSafe};
|
||||
use lemmy_db_schema::schema::community::columns::*;
|
||||
type Columns = (
|
||||
id,
|
||||
name,
|
||||
|
@ -123,17 +129,17 @@ pub struct CommunityForm {
|
|||
|
||||
impl Crud<CommunityForm> for Community {
|
||||
fn read(conn: &PgConnection, community_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::community::dsl::*;
|
||||
use lemmy_db_schema::schema::community::dsl::*;
|
||||
community.find(community_id).first::<Self>(conn)
|
||||
}
|
||||
|
||||
fn delete(conn: &PgConnection, community_id: i32) -> Result<usize, Error> {
|
||||
use crate::schema::community::dsl::*;
|
||||
use lemmy_db_schema::schema::community::dsl::*;
|
||||
diesel::delete(community.find(community_id)).execute(conn)
|
||||
}
|
||||
|
||||
fn create(conn: &PgConnection, new_community: &CommunityForm) -> Result<Self, Error> {
|
||||
use crate::schema::community::dsl::*;
|
||||
use lemmy_db_schema::schema::community::dsl::*;
|
||||
insert_into(community)
|
||||
.values(new_community)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -144,7 +150,7 @@ impl Crud<CommunityForm> for Community {
|
|||
community_id: i32,
|
||||
new_community: &CommunityForm,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::community::dsl::*;
|
||||
use lemmy_db_schema::schema::community::dsl::*;
|
||||
diesel::update(community.find(community_id))
|
||||
.set(new_community)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -153,14 +159,14 @@ impl Crud<CommunityForm> for Community {
|
|||
|
||||
impl ApubObject<CommunityForm> for Community {
|
||||
fn read_from_apub_id(conn: &PgConnection, for_actor_id: &str) -> Result<Self, Error> {
|
||||
use crate::schema::community::dsl::*;
|
||||
use lemmy_db_schema::schema::community::dsl::*;
|
||||
community
|
||||
.filter(actor_id.eq(for_actor_id))
|
||||
.first::<Self>(conn)
|
||||
}
|
||||
|
||||
fn upsert(conn: &PgConnection, community_form: &CommunityForm) -> Result<Community, Error> {
|
||||
use crate::schema::community::dsl::*;
|
||||
use lemmy_db_schema::schema::community::dsl::*;
|
||||
insert_into(community)
|
||||
.values(community_form)
|
||||
.on_conflict(actor_id)
|
||||
|
@ -172,7 +178,7 @@ impl ApubObject<CommunityForm> for Community {
|
|||
|
||||
impl Community {
|
||||
pub fn read_from_name(conn: &PgConnection, community_name: &str) -> Result<Self, Error> {
|
||||
use crate::schema::community::dsl::*;
|
||||
use lemmy_db_schema::schema::community::dsl::*;
|
||||
community
|
||||
.filter(local.eq(true))
|
||||
.filter(name.eq(community_name))
|
||||
|
@ -184,7 +190,7 @@ impl Community {
|
|||
community_id: i32,
|
||||
new_deleted: bool,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::community::dsl::*;
|
||||
use lemmy_db_schema::schema::community::dsl::*;
|
||||
diesel::update(community.find(community_id))
|
||||
.set((deleted.eq(new_deleted), updated.eq(naive_now())))
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -195,7 +201,7 @@ impl Community {
|
|||
community_id: i32,
|
||||
new_removed: bool,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::community::dsl::*;
|
||||
use lemmy_db_schema::schema::community::dsl::*;
|
||||
diesel::update(community.find(community_id))
|
||||
.set((removed.eq(new_removed), updated.eq(naive_now())))
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -206,7 +212,7 @@ impl Community {
|
|||
for_creator_id: i32,
|
||||
new_removed: bool,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
use crate::schema::community::dsl::*;
|
||||
use lemmy_db_schema::schema::community::dsl::*;
|
||||
diesel::update(community.filter(creator_id.eq(for_creator_id)))
|
||||
.set((removed.eq(new_removed), updated.eq(naive_now())))
|
||||
.get_results::<Self>(conn)
|
||||
|
@ -217,7 +223,7 @@ impl Community {
|
|||
community_id: i32,
|
||||
new_creator_id: i32,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::community::dsl::*;
|
||||
use lemmy_db_schema::schema::community::dsl::*;
|
||||
diesel::update(community.find(community_id))
|
||||
.set((creator_id.eq(new_creator_id), updated.eq(naive_now())))
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -235,7 +241,7 @@ impl Community {
|
|||
}
|
||||
|
||||
pub fn distinct_federated_communities(conn: &PgConnection) -> Result<Vec<String>, Error> {
|
||||
use crate::schema::community::dsl::*;
|
||||
use lemmy_db_schema::schema::community::dsl::*;
|
||||
community.select(actor_id).distinct().load::<String>(conn)
|
||||
}
|
||||
|
||||
|
@ -268,7 +274,7 @@ impl Joinable<CommunityModeratorForm> for CommunityModerator {
|
|||
conn: &PgConnection,
|
||||
community_user_form: &CommunityModeratorForm,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::community_moderator::dsl::*;
|
||||
use lemmy_db_schema::schema::community_moderator::dsl::*;
|
||||
insert_into(community_moderator)
|
||||
.values(community_user_form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -278,7 +284,7 @@ impl Joinable<CommunityModeratorForm> for CommunityModerator {
|
|||
conn: &PgConnection,
|
||||
community_user_form: &CommunityModeratorForm,
|
||||
) -> Result<usize, Error> {
|
||||
use crate::schema::community_moderator::dsl::*;
|
||||
use lemmy_db_schema::schema::community_moderator::dsl::*;
|
||||
diesel::delete(
|
||||
community_moderator
|
||||
.filter(community_id.eq(community_user_form.community_id))
|
||||
|
@ -290,7 +296,7 @@ impl Joinable<CommunityModeratorForm> for CommunityModerator {
|
|||
|
||||
impl CommunityModerator {
|
||||
pub fn delete_for_community(conn: &PgConnection, for_community_id: i32) -> Result<usize, Error> {
|
||||
use crate::schema::community_moderator::dsl::*;
|
||||
use lemmy_db_schema::schema::community_moderator::dsl::*;
|
||||
diesel::delete(community_moderator.filter(community_id.eq(for_community_id))).execute(conn)
|
||||
}
|
||||
|
||||
|
@ -298,7 +304,7 @@ impl CommunityModerator {
|
|||
conn: &PgConnection,
|
||||
for_user_id: i32,
|
||||
) -> Result<Vec<i32>, Error> {
|
||||
use crate::schema::community_moderator::dsl::*;
|
||||
use lemmy_db_schema::schema::community_moderator::dsl::*;
|
||||
community_moderator
|
||||
.filter(user_id.eq(for_user_id))
|
||||
.select(community_id)
|
||||
|
@ -328,7 +334,7 @@ impl Bannable<CommunityUserBanForm> for CommunityUserBan {
|
|||
conn: &PgConnection,
|
||||
community_user_ban_form: &CommunityUserBanForm,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::community_user_ban::dsl::*;
|
||||
use lemmy_db_schema::schema::community_user_ban::dsl::*;
|
||||
insert_into(community_user_ban)
|
||||
.values(community_user_ban_form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -338,7 +344,7 @@ impl Bannable<CommunityUserBanForm> for CommunityUserBan {
|
|||
conn: &PgConnection,
|
||||
community_user_ban_form: &CommunityUserBanForm,
|
||||
) -> Result<usize, Error> {
|
||||
use crate::schema::community_user_ban::dsl::*;
|
||||
use lemmy_db_schema::schema::community_user_ban::dsl::*;
|
||||
diesel::delete(
|
||||
community_user_ban
|
||||
.filter(community_id.eq(community_user_ban_form.community_id))
|
||||
|
@ -372,7 +378,7 @@ impl Followable<CommunityFollowerForm> for CommunityFollower {
|
|||
conn: &PgConnection,
|
||||
community_follower_form: &CommunityFollowerForm,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::community_follower::dsl::*;
|
||||
use lemmy_db_schema::schema::community_follower::dsl::*;
|
||||
insert_into(community_follower)
|
||||
.values(community_follower_form)
|
||||
.on_conflict((community_id, user_id))
|
||||
|
@ -384,7 +390,7 @@ impl Followable<CommunityFollowerForm> for CommunityFollower {
|
|||
where
|
||||
Self: Sized,
|
||||
{
|
||||
use crate::schema::community_follower::dsl::*;
|
||||
use lemmy_db_schema::schema::community_follower::dsl::*;
|
||||
diesel::update(
|
||||
community_follower
|
||||
.filter(community_id.eq(community_id_))
|
||||
|
@ -397,7 +403,7 @@ impl Followable<CommunityFollowerForm> for CommunityFollower {
|
|||
conn: &PgConnection,
|
||||
community_follower_form: &CommunityFollowerForm,
|
||||
) -> Result<usize, Error> {
|
||||
use crate::schema::community_follower::dsl::*;
|
||||
use lemmy_db_schema::schema::community_follower::dsl::*;
|
||||
diesel::delete(
|
||||
community_follower
|
||||
.filter(community_id.eq(&community_follower_form.community_id))
|
||||
|
@ -408,7 +414,7 @@ impl Followable<CommunityFollowerForm> for CommunityFollower {
|
|||
// TODO: this function name only makes sense if you call it with a remote community. for a local
|
||||
// community, it will also return true if only remote followers exist
|
||||
fn has_local_followers(conn: &PgConnection, community_id_: i32) -> Result<bool, Error> {
|
||||
use crate::schema::community_follower::dsl::*;
|
||||
use lemmy_db_schema::schema::community_follower::dsl::*;
|
||||
diesel::select(exists(
|
||||
community_follower.filter(community_id.eq(community_id_)),
|
||||
))
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
use crate::{
|
||||
schema::{
|
||||
mod_add,
|
||||
mod_add_community,
|
||||
mod_ban,
|
||||
mod_ban_from_community,
|
||||
mod_lock_post,
|
||||
mod_remove_comment,
|
||||
mod_remove_community,
|
||||
mod_remove_post,
|
||||
mod_sticky_post,
|
||||
},
|
||||
Crud,
|
||||
};
|
||||
use crate::Crud;
|
||||
use diesel::{dsl::*, result::Error, *};
|
||||
use lemmy_db_schema::schema::{
|
||||
mod_add,
|
||||
mod_add_community,
|
||||
mod_ban,
|
||||
mod_ban_from_community,
|
||||
mod_lock_post,
|
||||
mod_remove_comment,
|
||||
mod_remove_community,
|
||||
mod_remove_post,
|
||||
mod_sticky_post,
|
||||
};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
|
||||
|
@ -37,19 +35,19 @@ pub struct ModRemovePostForm {
|
|||
|
||||
impl Crud<ModRemovePostForm> for ModRemovePost {
|
||||
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::mod_remove_post::dsl::*;
|
||||
use lemmy_db_schema::schema::mod_remove_post::dsl::*;
|
||||
mod_remove_post.find(from_id).first::<Self>(conn)
|
||||
}
|
||||
|
||||
fn create(conn: &PgConnection, form: &ModRemovePostForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_remove_post::dsl::*;
|
||||
use lemmy_db_schema::schema::mod_remove_post::dsl::*;
|
||||
insert_into(mod_remove_post)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
}
|
||||
|
||||
fn update(conn: &PgConnection, from_id: i32, form: &ModRemovePostForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_remove_post::dsl::*;
|
||||
use lemmy_db_schema::schema::mod_remove_post::dsl::*;
|
||||
diesel::update(mod_remove_post.find(from_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -76,19 +74,19 @@ pub struct ModLockPostForm {
|
|||
|
||||
impl Crud<ModLockPostForm> for ModLockPost {
|
||||
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::mod_lock_post::dsl::*;
|
||||
use lemmy_db_schema::schema::mod_lock_post::dsl::*;
|
||||
mod_lock_post.find(from_id).first::<Self>(conn)
|
||||
}
|
||||
|
||||
fn create(conn: &PgConnection, form: &ModLockPostForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_lock_post::dsl::*;
|
||||
use lemmy_db_schema::schema::mod_lock_post::dsl::*;
|
||||
insert_into(mod_lock_post)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
}
|
||||
|
||||
fn update(conn: &PgConnection, from_id: i32, form: &ModLockPostForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_lock_post::dsl::*;
|
||||
use lemmy_db_schema::schema::mod_lock_post::dsl::*;
|
||||
diesel::update(mod_lock_post.find(from_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -115,19 +113,19 @@ pub struct ModStickyPostForm {
|
|||
|
||||
impl Crud<ModStickyPostForm> for ModStickyPost {
|
||||
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::mod_sticky_post::dsl::*;
|
||||
use lemmy_db_schema::schema::mod_sticky_post::dsl::*;
|
||||
mod_sticky_post.find(from_id).first::<Self>(conn)
|
||||
}
|
||||
|
||||
fn create(conn: &PgConnection, form: &ModStickyPostForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_sticky_post::dsl::*;
|
||||
use lemmy_db_schema::schema::mod_sticky_post::dsl::*;
|
||||
insert_into(mod_sticky_post)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
}
|
||||
|
||||
fn update(conn: &PgConnection, from_id: i32, form: &ModStickyPostForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_sticky_post::dsl::*;
|
||||
use lemmy_db_schema::schema::mod_sticky_post::dsl::*;
|
||||
diesel::update(mod_sticky_post.find(from_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -156,19 +154,19 @@ pub struct ModRemoveCommentForm {
|
|||
|
||||
impl Crud<ModRemoveCommentForm> for ModRemoveComment {
|
||||
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::mod_remove_comment::dsl::*;
|
||||
use lemmy_db_schema::schema::mod_remove_comment::dsl::*;
|
||||
mod_remove_comment.find(from_id).first::<Self>(conn)
|
||||
}
|
||||
|
||||
fn create(conn: &PgConnection, form: &ModRemoveCommentForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_remove_comment::dsl::*;
|
||||
use lemmy_db_schema::schema::mod_remove_comment::dsl::*;
|
||||
insert_into(mod_remove_comment)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
}
|
||||
|
||||
fn update(conn: &PgConnection, from_id: i32, form: &ModRemoveCommentForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_remove_comment::dsl::*;
|
||||
use lemmy_db_schema::schema::mod_remove_comment::dsl::*;
|
||||
diesel::update(mod_remove_comment.find(from_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -199,12 +197,12 @@ pub struct ModRemoveCommunityForm {
|
|||
|
||||
impl Crud<ModRemoveCommunityForm> for ModRemoveCommunity {
|
||||
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::mod_remove_community::dsl::*;
|
||||
use lemmy_db_schema::schema::mod_remove_community::dsl::*;
|
||||
mod_remove_community.find(from_id).first::<Self>(conn)
|
||||
}
|
||||
|
||||
fn create(conn: &PgConnection, form: &ModRemoveCommunityForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_remove_community::dsl::*;
|
||||
use lemmy_db_schema::schema::mod_remove_community::dsl::*;
|
||||
insert_into(mod_remove_community)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -215,7 +213,7 @@ impl Crud<ModRemoveCommunityForm> for ModRemoveCommunity {
|
|||
from_id: i32,
|
||||
form: &ModRemoveCommunityForm,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::mod_remove_community::dsl::*;
|
||||
use lemmy_db_schema::schema::mod_remove_community::dsl::*;
|
||||
diesel::update(mod_remove_community.find(from_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -248,12 +246,12 @@ pub struct ModBanFromCommunityForm {
|
|||
|
||||
impl Crud<ModBanFromCommunityForm> for ModBanFromCommunity {
|
||||
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::mod_ban_from_community::dsl::*;
|
||||
use lemmy_db_schema::schema::mod_ban_from_community::dsl::*;
|
||||
mod_ban_from_community.find(from_id).first::<Self>(conn)
|
||||
}
|
||||
|
||||
fn create(conn: &PgConnection, form: &ModBanFromCommunityForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_ban_from_community::dsl::*;
|
||||
use lemmy_db_schema::schema::mod_ban_from_community::dsl::*;
|
||||
insert_into(mod_ban_from_community)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -264,7 +262,7 @@ impl Crud<ModBanFromCommunityForm> for ModBanFromCommunity {
|
|||
from_id: i32,
|
||||
form: &ModBanFromCommunityForm,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::mod_ban_from_community::dsl::*;
|
||||
use lemmy_db_schema::schema::mod_ban_from_community::dsl::*;
|
||||
diesel::update(mod_ban_from_community.find(from_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -295,17 +293,17 @@ pub struct ModBanForm {
|
|||
|
||||
impl Crud<ModBanForm> for ModBan {
|
||||
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::mod_ban::dsl::*;
|
||||
use lemmy_db_schema::schema::mod_ban::dsl::*;
|
||||
mod_ban.find(from_id).first::<Self>(conn)
|
||||
}
|
||||
|
||||
fn create(conn: &PgConnection, form: &ModBanForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_ban::dsl::*;
|
||||
use lemmy_db_schema::schema::mod_ban::dsl::*;
|
||||
insert_into(mod_ban).values(form).get_result::<Self>(conn)
|
||||
}
|
||||
|
||||
fn update(conn: &PgConnection, from_id: i32, form: &ModBanForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_ban::dsl::*;
|
||||
use lemmy_db_schema::schema::mod_ban::dsl::*;
|
||||
diesel::update(mod_ban.find(from_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -334,19 +332,19 @@ pub struct ModAddCommunityForm {
|
|||
|
||||
impl Crud<ModAddCommunityForm> for ModAddCommunity {
|
||||
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::mod_add_community::dsl::*;
|
||||
use lemmy_db_schema::schema::mod_add_community::dsl::*;
|
||||
mod_add_community.find(from_id).first::<Self>(conn)
|
||||
}
|
||||
|
||||
fn create(conn: &PgConnection, form: &ModAddCommunityForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_add_community::dsl::*;
|
||||
use lemmy_db_schema::schema::mod_add_community::dsl::*;
|
||||
insert_into(mod_add_community)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
}
|
||||
|
||||
fn update(conn: &PgConnection, from_id: i32, form: &ModAddCommunityForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_add_community::dsl::*;
|
||||
use lemmy_db_schema::schema::mod_add_community::dsl::*;
|
||||
diesel::update(mod_add_community.find(from_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -373,17 +371,17 @@ pub struct ModAddForm {
|
|||
|
||||
impl Crud<ModAddForm> for ModAdd {
|
||||
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::mod_add::dsl::*;
|
||||
use lemmy_db_schema::schema::mod_add::dsl::*;
|
||||
mod_add.find(from_id).first::<Self>(conn)
|
||||
}
|
||||
|
||||
fn create(conn: &PgConnection, form: &ModAddForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_add::dsl::*;
|
||||
use lemmy_db_schema::schema::mod_add::dsl::*;
|
||||
insert_into(mod_add).values(form).get_result::<Self>(conn)
|
||||
}
|
||||
|
||||
fn update(conn: &PgConnection, from_id: i32, form: &ModAddForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_add::dsl::*;
|
||||
use lemmy_db_schema::schema::mod_add::dsl::*;
|
||||
diesel::update(mod_add.find(from_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
use crate::{
|
||||
schema::{password_reset_request, password_reset_request::dsl::*},
|
||||
Crud,
|
||||
};
|
||||
use crate::Crud;
|
||||
use diesel::{dsl::*, result::Error, PgConnection, *};
|
||||
use lemmy_db_schema::schema::{password_reset_request, password_reset_request::dsl::*};
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
#[derive(Queryable, Identifiable, PartialEq, Debug)]
|
||||
|
@ -23,7 +21,6 @@ pub struct PasswordResetRequestForm {
|
|||
|
||||
impl Crud<PasswordResetRequestForm> for PasswordResetRequest {
|
||||
fn read(conn: &PgConnection, password_reset_request_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::password_reset_request::dsl::*;
|
||||
password_reset_request
|
||||
.find(password_reset_request_id)
|
||||
.first::<Self>(conn)
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
use crate::{
|
||||
naive_now,
|
||||
schema::{post, post_like, post_read, post_saved},
|
||||
ApubObject,
|
||||
Crud,
|
||||
Likeable,
|
||||
Readable,
|
||||
Saveable,
|
||||
};
|
||||
use crate::{naive_now, ApubObject, Crud, Likeable, Readable, Saveable};
|
||||
use diesel::{dsl::*, result::Error, *};
|
||||
use lemmy_db_schema::schema::{post, post_like, post_read, post_saved};
|
||||
use serde::Serialize;
|
||||
use url::{ParseError, Url};
|
||||
|
||||
|
@ -66,22 +59,22 @@ impl PostForm {
|
|||
|
||||
impl Crud<PostForm> for Post {
|
||||
fn read(conn: &PgConnection, post_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::post::dsl::*;
|
||||
use lemmy_db_schema::schema::post::dsl::*;
|
||||
post.find(post_id).first::<Self>(conn)
|
||||
}
|
||||
|
||||
fn delete(conn: &PgConnection, post_id: i32) -> Result<usize, Error> {
|
||||
use crate::schema::post::dsl::*;
|
||||
use lemmy_db_schema::schema::post::dsl::*;
|
||||
diesel::delete(post.find(post_id)).execute(conn)
|
||||
}
|
||||
|
||||
fn create(conn: &PgConnection, new_post: &PostForm) -> Result<Self, Error> {
|
||||
use crate::schema::post::dsl::*;
|
||||
use lemmy_db_schema::schema::post::dsl::*;
|
||||
insert_into(post).values(new_post).get_result::<Self>(conn)
|
||||
}
|
||||
|
||||
fn update(conn: &PgConnection, post_id: i32, new_post: &PostForm) -> Result<Self, Error> {
|
||||
use crate::schema::post::dsl::*;
|
||||
use lemmy_db_schema::schema::post::dsl::*;
|
||||
diesel::update(post.find(post_id))
|
||||
.set(new_post)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -90,12 +83,12 @@ impl Crud<PostForm> for Post {
|
|||
|
||||
impl ApubObject<PostForm> for Post {
|
||||
fn read_from_apub_id(conn: &PgConnection, object_id: &str) -> Result<Self, Error> {
|
||||
use crate::schema::post::dsl::*;
|
||||
use lemmy_db_schema::schema::post::dsl::*;
|
||||
post.filter(ap_id.eq(object_id)).first::<Self>(conn)
|
||||
}
|
||||
|
||||
fn upsert(conn: &PgConnection, post_form: &PostForm) -> Result<Post, Error> {
|
||||
use crate::schema::post::dsl::*;
|
||||
use lemmy_db_schema::schema::post::dsl::*;
|
||||
insert_into(post)
|
||||
.values(post_form)
|
||||
.on_conflict(ap_id)
|
||||
|
@ -107,7 +100,7 @@ impl ApubObject<PostForm> for Post {
|
|||
|
||||
impl Post {
|
||||
pub fn read(conn: &PgConnection, post_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::post::dsl::*;
|
||||
use lemmy_db_schema::schema::post::dsl::*;
|
||||
post.filter(id.eq(post_id)).first::<Self>(conn)
|
||||
}
|
||||
|
||||
|
@ -115,7 +108,7 @@ impl Post {
|
|||
conn: &PgConnection,
|
||||
the_community_id: i32,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
use crate::schema::post::dsl::*;
|
||||
use lemmy_db_schema::schema::post::dsl::*;
|
||||
post
|
||||
.filter(community_id.eq(the_community_id))
|
||||
.then_order_by(published.desc())
|
||||
|
@ -125,7 +118,7 @@ impl Post {
|
|||
}
|
||||
|
||||
pub fn update_ap_id(conn: &PgConnection, post_id: i32, apub_id: String) -> Result<Self, Error> {
|
||||
use crate::schema::post::dsl::*;
|
||||
use lemmy_db_schema::schema::post::dsl::*;
|
||||
|
||||
diesel::update(post.find(post_id))
|
||||
.set(ap_id.eq(apub_id))
|
||||
|
@ -136,7 +129,7 @@ impl Post {
|
|||
conn: &PgConnection,
|
||||
for_creator_id: i32,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
use crate::schema::post::dsl::*;
|
||||
use lemmy_db_schema::schema::post::dsl::*;
|
||||
|
||||
let perma_deleted = "*Permananently Deleted*";
|
||||
let perma_deleted_url = "https://deleted.com";
|
||||
|
@ -157,7 +150,7 @@ impl Post {
|
|||
post_id: i32,
|
||||
new_deleted: bool,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::post::dsl::*;
|
||||
use lemmy_db_schema::schema::post::dsl::*;
|
||||
diesel::update(post.find(post_id))
|
||||
.set((deleted.eq(new_deleted), updated.eq(naive_now())))
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -168,7 +161,7 @@ impl Post {
|
|||
post_id: i32,
|
||||
new_removed: bool,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::post::dsl::*;
|
||||
use lemmy_db_schema::schema::post::dsl::*;
|
||||
diesel::update(post.find(post_id))
|
||||
.set((removed.eq(new_removed), updated.eq(naive_now())))
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -180,7 +173,7 @@ impl Post {
|
|||
for_community_id: Option<i32>,
|
||||
new_removed: bool,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
use crate::schema::post::dsl::*;
|
||||
use lemmy_db_schema::schema::post::dsl::*;
|
||||
|
||||
let mut update = diesel::update(post).into_boxed();
|
||||
update = update.filter(creator_id.eq(for_creator_id));
|
||||
|
@ -195,7 +188,7 @@ impl Post {
|
|||
}
|
||||
|
||||
pub fn update_locked(conn: &PgConnection, post_id: i32, new_locked: bool) -> Result<Self, Error> {
|
||||
use crate::schema::post::dsl::*;
|
||||
use lemmy_db_schema::schema::post::dsl::*;
|
||||
diesel::update(post.find(post_id))
|
||||
.set(locked.eq(new_locked))
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -206,7 +199,7 @@ impl Post {
|
|||
post_id: i32,
|
||||
new_stickied: bool,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::post::dsl::*;
|
||||
use lemmy_db_schema::schema::post::dsl::*;
|
||||
diesel::update(post.find(post_id))
|
||||
.set(stickied.eq(new_stickied))
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -238,7 +231,7 @@ pub struct PostLikeForm {
|
|||
|
||||
impl Likeable<PostLikeForm> for PostLike {
|
||||
fn like(conn: &PgConnection, post_like_form: &PostLikeForm) -> Result<Self, Error> {
|
||||
use crate::schema::post_like::dsl::*;
|
||||
use lemmy_db_schema::schema::post_like::dsl::*;
|
||||
insert_into(post_like)
|
||||
.values(post_like_form)
|
||||
.on_conflict((post_id, user_id))
|
||||
|
@ -247,7 +240,7 @@ impl Likeable<PostLikeForm> for PostLike {
|
|||
.get_result::<Self>(conn)
|
||||
}
|
||||
fn remove(conn: &PgConnection, user_id: i32, post_id: i32) -> Result<usize, Error> {
|
||||
use crate::schema::post_like::dsl;
|
||||
use lemmy_db_schema::schema::post_like::dsl;
|
||||
diesel::delete(
|
||||
dsl::post_like
|
||||
.filter(dsl::post_id.eq(post_id))
|
||||
|
@ -276,7 +269,7 @@ pub struct PostSavedForm {
|
|||
|
||||
impl Saveable<PostSavedForm> for PostSaved {
|
||||
fn save(conn: &PgConnection, post_saved_form: &PostSavedForm) -> Result<Self, Error> {
|
||||
use crate::schema::post_saved::dsl::*;
|
||||
use lemmy_db_schema::schema::post_saved::dsl::*;
|
||||
insert_into(post_saved)
|
||||
.values(post_saved_form)
|
||||
.on_conflict((post_id, user_id))
|
||||
|
@ -285,7 +278,7 @@ impl Saveable<PostSavedForm> for PostSaved {
|
|||
.get_result::<Self>(conn)
|
||||
}
|
||||
fn unsave(conn: &PgConnection, post_saved_form: &PostSavedForm) -> Result<usize, Error> {
|
||||
use crate::schema::post_saved::dsl::*;
|
||||
use lemmy_db_schema::schema::post_saved::dsl::*;
|
||||
diesel::delete(
|
||||
post_saved
|
||||
.filter(post_id.eq(post_saved_form.post_id))
|
||||
|
@ -318,14 +311,14 @@ pub struct PostReadForm {
|
|||
|
||||
impl Readable<PostReadForm> for PostRead {
|
||||
fn mark_as_read(conn: &PgConnection, post_read_form: &PostReadForm) -> Result<Self, Error> {
|
||||
use crate::schema::post_read::dsl::*;
|
||||
use lemmy_db_schema::schema::post_read::dsl::*;
|
||||
insert_into(post_read)
|
||||
.values(post_read_form)
|
||||
.get_result::<Self>(conn)
|
||||
}
|
||||
|
||||
fn mark_as_unread(conn: &PgConnection, post_read_form: &PostReadForm) -> Result<usize, Error> {
|
||||
use crate::schema::post_read::dsl::*;
|
||||
use lemmy_db_schema::schema::post_read::dsl::*;
|
||||
diesel::delete(
|
||||
post_read
|
||||
.filter(post_id.eq(post_read_form.post_id))
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::{naive_now, source::post::Post, Reportable};
|
||||
use diesel::{dsl::*, result::Error, *};
|
||||
use lemmy_db_schema::schema::post_report;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{naive_now, schema::post_report, source::post::Post, Reportable};
|
||||
|
||||
#[derive(Identifiable, Queryable, Associations, PartialEq, Serialize, Deserialize, Debug, Clone)]
|
||||
#[belongs_to(Post)]
|
||||
#[table_name = "post_report"]
|
||||
|
@ -37,7 +37,7 @@ impl Reportable<PostReportForm> for PostReport {
|
|||
/// * `conn` - the postgres connection
|
||||
/// * `post_report_form` - the filled CommentReportForm to insert
|
||||
fn report(conn: &PgConnection, post_report_form: &PostReportForm) -> Result<Self, Error> {
|
||||
use crate::schema::post_report::dsl::*;
|
||||
use lemmy_db_schema::schema::post_report::dsl::*;
|
||||
insert_into(post_report)
|
||||
.values(post_report_form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -49,7 +49,7 @@ impl Reportable<PostReportForm> for PostReport {
|
|||
/// * `report_id` - the id of the report to resolve
|
||||
/// * `by_resolver_id` - the id of the user resolving the report
|
||||
fn resolve(conn: &PgConnection, report_id: i32, by_resolver_id: i32) -> Result<usize, Error> {
|
||||
use crate::schema::post_report::dsl::*;
|
||||
use lemmy_db_schema::schema::post_report::dsl::*;
|
||||
update(post_report.find(report_id))
|
||||
.set((
|
||||
resolved.eq(true),
|
||||
|
@ -65,7 +65,7 @@ impl Reportable<PostReportForm> for PostReport {
|
|||
/// * `report_id` - the id of the report to unresolve
|
||||
/// * `by_resolver_id` - the id of the user unresolving the report
|
||||
fn unresolve(conn: &PgConnection, report_id: i32, by_resolver_id: i32) -> Result<usize, Error> {
|
||||
use crate::schema::post_report::dsl::*;
|
||||
use lemmy_db_schema::schema::post_report::dsl::*;
|
||||
update(post_report.find(report_id))
|
||||
.set((
|
||||
resolved.eq(false),
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use crate::{naive_now, schema::private_message, ApubObject, Crud};
|
||||
use crate::{naive_now, ApubObject, Crud};
|
||||
use diesel::{dsl::*, result::Error, *};
|
||||
use lemmy_db_schema::schema::private_message;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Clone, Queryable, Associations, Identifiable, PartialEq, Debug, Serialize)]
|
||||
|
@ -33,12 +34,12 @@ pub struct PrivateMessageForm {
|
|||
|
||||
impl Crud<PrivateMessageForm> for PrivateMessage {
|
||||
fn read(conn: &PgConnection, private_message_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::private_message::dsl::*;
|
||||
use lemmy_db_schema::schema::private_message::dsl::*;
|
||||
private_message.find(private_message_id).first::<Self>(conn)
|
||||
}
|
||||
|
||||
fn create(conn: &PgConnection, private_message_form: &PrivateMessageForm) -> Result<Self, Error> {
|
||||
use crate::schema::private_message::dsl::*;
|
||||
use lemmy_db_schema::schema::private_message::dsl::*;
|
||||
insert_into(private_message)
|
||||
.values(private_message_form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -49,7 +50,7 @@ impl Crud<PrivateMessageForm> for PrivateMessage {
|
|||
private_message_id: i32,
|
||||
private_message_form: &PrivateMessageForm,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::private_message::dsl::*;
|
||||
use lemmy_db_schema::schema::private_message::dsl::*;
|
||||
diesel::update(private_message.find(private_message_id))
|
||||
.set(private_message_form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -61,14 +62,14 @@ impl ApubObject<PrivateMessageForm> for PrivateMessage {
|
|||
where
|
||||
Self: Sized,
|
||||
{
|
||||
use crate::schema::private_message::dsl::*;
|
||||
use lemmy_db_schema::schema::private_message::dsl::*;
|
||||
private_message
|
||||
.filter(ap_id.eq(object_id))
|
||||
.first::<Self>(conn)
|
||||
}
|
||||
|
||||
fn upsert(conn: &PgConnection, private_message_form: &PrivateMessageForm) -> Result<Self, Error> {
|
||||
use crate::schema::private_message::dsl::*;
|
||||
use lemmy_db_schema::schema::private_message::dsl::*;
|
||||
insert_into(private_message)
|
||||
.values(private_message_form)
|
||||
.on_conflict(ap_id)
|
||||
|
@ -84,7 +85,7 @@ impl PrivateMessage {
|
|||
private_message_id: i32,
|
||||
apub_id: String,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::private_message::dsl::*;
|
||||
use lemmy_db_schema::schema::private_message::dsl::*;
|
||||
|
||||
diesel::update(private_message.find(private_message_id))
|
||||
.set(ap_id.eq(apub_id))
|
||||
|
@ -96,7 +97,7 @@ impl PrivateMessage {
|
|||
private_message_id: i32,
|
||||
new_content: &str,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::private_message::dsl::*;
|
||||
use lemmy_db_schema::schema::private_message::dsl::*;
|
||||
diesel::update(private_message.find(private_message_id))
|
||||
.set((content.eq(new_content), updated.eq(naive_now())))
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -107,7 +108,7 @@ impl PrivateMessage {
|
|||
private_message_id: i32,
|
||||
new_deleted: bool,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::private_message::dsl::*;
|
||||
use lemmy_db_schema::schema::private_message::dsl::*;
|
||||
diesel::update(private_message.find(private_message_id))
|
||||
.set(deleted.eq(new_deleted))
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -118,14 +119,14 @@ impl PrivateMessage {
|
|||
private_message_id: i32,
|
||||
new_read: bool,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::private_message::dsl::*;
|
||||
use lemmy_db_schema::schema::private_message::dsl::*;
|
||||
diesel::update(private_message.find(private_message_id))
|
||||
.set(read.eq(new_read))
|
||||
.get_result::<Self>(conn)
|
||||
}
|
||||
|
||||
pub fn mark_all_as_read(conn: &PgConnection, for_recipient_id: i32) -> Result<Vec<Self>, Error> {
|
||||
use crate::schema::private_message::dsl::*;
|
||||
use lemmy_db_schema::schema::private_message::dsl::*;
|
||||
diesel::update(
|
||||
private_message
|
||||
.filter(recipient_id.eq(for_recipient_id))
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use crate::{naive_now, schema::site, Crud};
|
||||
use crate::{naive_now, Crud};
|
||||
use diesel::{dsl::*, result::Error, *};
|
||||
use lemmy_db_schema::schema::site;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Queryable, Identifiable, PartialEq, Debug, Clone, Serialize)]
|
||||
|
@ -35,17 +36,17 @@ pub struct SiteForm {
|
|||
|
||||
impl Crud<SiteForm> for Site {
|
||||
fn read(conn: &PgConnection, _site_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::site::dsl::*;
|
||||
use lemmy_db_schema::schema::site::dsl::*;
|
||||
site.first::<Self>(conn)
|
||||
}
|
||||
|
||||
fn create(conn: &PgConnection, new_site: &SiteForm) -> Result<Self, Error> {
|
||||
use crate::schema::site::dsl::*;
|
||||
use lemmy_db_schema::schema::site::dsl::*;
|
||||
insert_into(site).values(new_site).get_result::<Self>(conn)
|
||||
}
|
||||
|
||||
fn update(conn: &PgConnection, site_id: i32, new_site: &SiteForm) -> Result<Self, Error> {
|
||||
use crate::schema::site::dsl::*;
|
||||
use lemmy_db_schema::schema::site::dsl::*;
|
||||
diesel::update(site.find(site_id))
|
||||
.set(new_site)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -54,7 +55,7 @@ impl Crud<SiteForm> for Site {
|
|||
|
||||
impl Site {
|
||||
pub fn transfer(conn: &PgConnection, new_creator_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::site::dsl::*;
|
||||
use lemmy_db_schema::schema::site::dsl::*;
|
||||
diesel::update(site.find(1))
|
||||
.set((creator_id.eq(new_creator_id), updated.eq(naive_now())))
|
||||
.get_result::<Self>(conn)
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
use crate::{
|
||||
is_email_regex,
|
||||
naive_now,
|
||||
schema::{user_, user_::dsl::*, user_alias_1, user_alias_2},
|
||||
ApubObject,
|
||||
Crud,
|
||||
};
|
||||
use crate::{is_email_regex, naive_now, ApubObject, Crud};
|
||||
use bcrypt::{hash, DEFAULT_COST};
|
||||
use diesel::{dsl::*, result::Error, *};
|
||||
use lemmy_db_schema::schema::{user_, user_::dsl::*, user_alias_1, user_alias_2};
|
||||
use lemmy_utils::settings::Settings;
|
||||
use serde::Serialize;
|
||||
|
||||
|
@ -62,7 +57,8 @@ pub struct UserSafe {
|
|||
}
|
||||
|
||||
mod safe_type {
|
||||
use crate::{schema::user_::columns::*, source::user::User_, ToSafe};
|
||||
use crate::{source::user::User_, ToSafe};
|
||||
use lemmy_db_schema::schema::user_::columns::*;
|
||||
type Columns = (
|
||||
id,
|
||||
name,
|
||||
|
@ -154,7 +150,8 @@ pub struct UserSafeAlias1 {
|
|||
}
|
||||
|
||||
mod safe_type_alias_1 {
|
||||
use crate::{schema::user_alias_1::columns::*, source::user::UserAlias1, ToSafe};
|
||||
use crate::{source::user::UserAlias1, ToSafe};
|
||||
use lemmy_db_schema::schema::user_alias_1::columns::*;
|
||||
type Columns = (
|
||||
id,
|
||||
name,
|
||||
|
@ -246,7 +243,8 @@ pub struct UserSafeAlias2 {
|
|||
}
|
||||
|
||||
mod safe_type_alias_2 {
|
||||
use crate::{schema::user_alias_2::columns::*, source::user::UserAlias2, ToSafe};
|
||||
use crate::{source::user::UserAlias2, ToSafe};
|
||||
use lemmy_db_schema::schema::user_alias_2::columns::*;
|
||||
type Columns = (
|
||||
id,
|
||||
name,
|
||||
|
@ -338,7 +336,7 @@ impl Crud<UserForm> for User_ {
|
|||
|
||||
impl ApubObject<UserForm> for User_ {
|
||||
fn read_from_apub_id(conn: &PgConnection, object_id: &str) -> Result<Self, Error> {
|
||||
use crate::schema::user_::dsl::*;
|
||||
use lemmy_db_schema::schema::user_::dsl::*;
|
||||
user_
|
||||
.filter(deleted.eq(false))
|
||||
.filter(actor_id.eq(object_id))
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use super::comment::Comment;
|
||||
use crate::{schema::user_mention, Crud};
|
||||
use crate::Crud;
|
||||
use diesel::{dsl::*, result::Error, *};
|
||||
use lemmy_db_schema::schema::user_mention;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Clone, Queryable, Associations, Identifiable, PartialEq, Debug, Serialize)]
|
||||
|
@ -24,12 +25,12 @@ pub struct UserMentionForm {
|
|||
|
||||
impl Crud<UserMentionForm> for UserMention {
|
||||
fn read(conn: &PgConnection, user_mention_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::user_mention::dsl::*;
|
||||
use lemmy_db_schema::schema::user_mention::dsl::*;
|
||||
user_mention.find(user_mention_id).first::<Self>(conn)
|
||||
}
|
||||
|
||||
fn create(conn: &PgConnection, user_mention_form: &UserMentionForm) -> Result<Self, Error> {
|
||||
use crate::schema::user_mention::dsl::*;
|
||||
use lemmy_db_schema::schema::user_mention::dsl::*;
|
||||
// since the return here isnt utilized, we dont need to do an update
|
||||
// but get_result doesnt return the existing row here
|
||||
insert_into(user_mention)
|
||||
|
@ -45,7 +46,7 @@ impl Crud<UserMentionForm> for UserMention {
|
|||
user_mention_id: i32,
|
||||
user_mention_form: &UserMentionForm,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::user_mention::dsl::*;
|
||||
use lemmy_db_schema::schema::user_mention::dsl::*;
|
||||
diesel::update(user_mention.find(user_mention_id))
|
||||
.set(user_mention_form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -58,14 +59,14 @@ impl UserMention {
|
|||
user_mention_id: i32,
|
||||
new_read: bool,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::user_mention::dsl::*;
|
||||
use lemmy_db_schema::schema::user_mention::dsl::*;
|
||||
diesel::update(user_mention.find(user_mention_id))
|
||||
.set(read.eq(new_read))
|
||||
.get_result::<Self>(conn)
|
||||
}
|
||||
|
||||
pub fn mark_all_as_read(conn: &PgConnection, for_recipient_id: i32) -> Result<Vec<Self>, Error> {
|
||||
use crate::schema::user_mention::dsl::*;
|
||||
use lemmy_db_schema::schema::user_mention::dsl::*;
|
||||
diesel::update(
|
||||
user_mention
|
||||
.filter(recipient_id.eq(for_recipient_id))
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use crate::{
|
||||
limit_and_offset,
|
||||
schema::{comment, comment_report, community, post, user_, user_alias_1, user_alias_2},
|
||||
source::{
|
||||
comment::Comment,
|
||||
comment_report::CommentReport,
|
||||
|
@ -13,6 +12,15 @@ use crate::{
|
|||
ToSafe,
|
||||
};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::schema::{
|
||||
comment,
|
||||
comment_report,
|
||||
community,
|
||||
post,
|
||||
user_,
|
||||
user_alias_1,
|
||||
user_alias_2,
|
||||
};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Clone)]
|
||||
|
|
|
@ -3,19 +3,6 @@ use crate::{
|
|||
functions::hot_rank,
|
||||
fuzzy_search,
|
||||
limit_and_offset,
|
||||
schema::{
|
||||
comment,
|
||||
comment_aggregates,
|
||||
comment_alias_1,
|
||||
comment_like,
|
||||
comment_saved,
|
||||
community,
|
||||
community_follower,
|
||||
community_user_ban,
|
||||
post,
|
||||
user_,
|
||||
user_alias_1,
|
||||
},
|
||||
source::{
|
||||
comment::{Comment, CommentAlias1, CommentSaved},
|
||||
community::{Community, CommunityFollower, CommunitySafe, CommunityUserBan},
|
||||
|
@ -29,6 +16,19 @@ use crate::{
|
|||
ToSafe,
|
||||
};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::schema::{
|
||||
comment,
|
||||
comment_aggregates,
|
||||
comment_alias_1,
|
||||
comment_like,
|
||||
comment_saved,
|
||||
community,
|
||||
community_follower,
|
||||
community_user_ban,
|
||||
post,
|
||||
user_,
|
||||
user_alias_1,
|
||||
};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Clone)]
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use crate::{
|
||||
schema::{community, community_follower, user_},
|
||||
source::{
|
||||
community::{Community, CommunitySafe},
|
||||
user::{UserSafe, User_},
|
||||
|
@ -8,6 +7,7 @@ use crate::{
|
|||
ToSafe,
|
||||
};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::schema::{community, community_follower, user_};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Serialize, Clone)]
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use crate::{
|
||||
schema::{community, community_moderator, user_},
|
||||
source::{
|
||||
community::{Community, CommunitySafe},
|
||||
user::{UserSafe, User_},
|
||||
|
@ -8,6 +7,7 @@ use crate::{
|
|||
ToSafe,
|
||||
};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::schema::{community, community_moderator, user_};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Serialize, Clone)]
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use crate::{
|
||||
schema::{community, community_user_ban, user_},
|
||||
source::{
|
||||
community::{Community, CommunitySafe},
|
||||
user::{UserSafe, User_},
|
||||
|
@ -7,6 +6,7 @@ use crate::{
|
|||
ToSafe,
|
||||
};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::schema::{community, community_user_ban, user_};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Serialize, Clone)]
|
||||
|
|
|
@ -3,7 +3,6 @@ use crate::{
|
|||
functions::hot_rank,
|
||||
fuzzy_search,
|
||||
limit_and_offset,
|
||||
schema::{category, community, community_aggregates, community_follower, user_},
|
||||
source::{
|
||||
category::Category,
|
||||
community::{Community, CommunityFollower, CommunitySafe},
|
||||
|
@ -15,6 +14,13 @@ use crate::{
|
|||
ToSafe,
|
||||
};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::schema::{
|
||||
category,
|
||||
community,
|
||||
community_aggregates,
|
||||
community_follower,
|
||||
user_,
|
||||
};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Serialize, Clone)]
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use crate::{
|
||||
limit_and_offset,
|
||||
schema::{community, mod_add_community, user_, user_alias_1},
|
||||
source::{
|
||||
community::{Community, CommunitySafe},
|
||||
moderator::ModAddCommunity,
|
||||
|
@ -10,6 +9,7 @@ use crate::{
|
|||
ToSafe,
|
||||
};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::schema::{community, mod_add_community, user_, user_alias_1};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Serialize, Clone)]
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use crate::{
|
||||
limit_and_offset,
|
||||
schema::{mod_add, user_, user_alias_1},
|
||||
source::{
|
||||
moderator::ModAdd,
|
||||
user::{UserAlias1, UserSafe, UserSafeAlias1, User_},
|
||||
|
@ -9,6 +8,7 @@ use crate::{
|
|||
ToSafe,
|
||||
};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::schema::{mod_add, user_, user_alias_1};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Serialize, Clone)]
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use crate::{
|
||||
limit_and_offset,
|
||||
schema::{community, mod_ban_from_community, user_, user_alias_1},
|
||||
source::{
|
||||
community::{Community, CommunitySafe},
|
||||
moderator::ModBanFromCommunity,
|
||||
|
@ -10,6 +9,7 @@ use crate::{
|
|||
ToSafe,
|
||||
};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::schema::{community, mod_ban_from_community, user_, user_alias_1};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Serialize, Clone)]
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use crate::{
|
||||
limit_and_offset,
|
||||
schema::{mod_ban, user_, user_alias_1},
|
||||
source::{
|
||||
moderator::ModBan,
|
||||
user::{UserAlias1, UserSafe, UserSafeAlias1, User_},
|
||||
|
@ -9,6 +8,7 @@ use crate::{
|
|||
ToSafe,
|
||||
};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::schema::{mod_ban, user_, user_alias_1};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Serialize, Clone)]
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use crate::{
|
||||
limit_and_offset,
|
||||
schema::{community, mod_lock_post, post, user_},
|
||||
source::{
|
||||
community::{Community, CommunitySafe},
|
||||
moderator::ModLockPost,
|
||||
|
@ -11,6 +10,7 @@ use crate::{
|
|||
ToSafe,
|
||||
};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::schema::{community, mod_lock_post, post, user_};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Serialize, Clone)]
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use crate::{
|
||||
limit_and_offset,
|
||||
schema::{comment, community, mod_remove_comment, post, user_, user_alias_1},
|
||||
source::{
|
||||
comment::Comment,
|
||||
community::{Community, CommunitySafe},
|
||||
|
@ -12,6 +11,7 @@ use crate::{
|
|||
ToSafe,
|
||||
};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::schema::{comment, community, mod_remove_comment, post, user_, user_alias_1};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Serialize, Clone)]
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use crate::{
|
||||
limit_and_offset,
|
||||
schema::{community, mod_remove_community, user_},
|
||||
source::{
|
||||
community::{Community, CommunitySafe},
|
||||
moderator::ModRemoveCommunity,
|
||||
|
@ -10,6 +9,7 @@ use crate::{
|
|||
ToSafe,
|
||||
};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::schema::{community, mod_remove_community, user_};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Serialize, Clone)]
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use crate::{
|
||||
limit_and_offset,
|
||||
schema::{community, mod_remove_post, post, user_},
|
||||
source::{
|
||||
community::{Community, CommunitySafe},
|
||||
moderator::ModRemovePost,
|
||||
|
@ -11,6 +10,7 @@ use crate::{
|
|||
ToSafe,
|
||||
};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::schema::{community, mod_remove_post, post, user_};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Serialize, Clone)]
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use crate::{
|
||||
limit_and_offset,
|
||||
schema::{community, mod_sticky_post, post, user_},
|
||||
source::{
|
||||
community::{Community, CommunitySafe},
|
||||
moderator::ModStickyPost,
|
||||
|
@ -11,6 +10,7 @@ use crate::{
|
|||
ToSafe,
|
||||
};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::schema::{community, mod_sticky_post, post, user_};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Serialize, Clone)]
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use crate::{
|
||||
limit_and_offset,
|
||||
schema::{community, post, post_report, user_, user_alias_1, user_alias_2},
|
||||
source::{
|
||||
community::{Community, CommunitySafe},
|
||||
post::Post,
|
||||
|
@ -12,6 +11,7 @@ use crate::{
|
|||
ToSafe,
|
||||
};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::schema::{community, post, post_report, user_, user_alias_1, user_alias_2};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Clone)]
|
||||
|
|
|
@ -3,17 +3,6 @@ use crate::{
|
|||
functions::hot_rank,
|
||||
fuzzy_search,
|
||||
limit_and_offset,
|
||||
schema::{
|
||||
community,
|
||||
community_follower,
|
||||
community_user_ban,
|
||||
post,
|
||||
post_aggregates,
|
||||
post_like,
|
||||
post_read,
|
||||
post_saved,
|
||||
user_,
|
||||
},
|
||||
source::{
|
||||
community::{Community, CommunityFollower, CommunitySafe, CommunityUserBan},
|
||||
post::{Post, PostRead, PostSaved},
|
||||
|
@ -26,6 +15,17 @@ use crate::{
|
|||
ToSafe,
|
||||
};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::schema::{
|
||||
community,
|
||||
community_follower,
|
||||
community_user_ban,
|
||||
post,
|
||||
post_aggregates,
|
||||
post_like,
|
||||
post_read,
|
||||
post_saved,
|
||||
user_,
|
||||
};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Clone)]
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use crate::{
|
||||
limit_and_offset,
|
||||
schema::{private_message, user_, user_alias_1},
|
||||
source::{
|
||||
private_message::PrivateMessage,
|
||||
user::{UserAlias1, UserSafe, UserSafeAlias1, User_},
|
||||
|
@ -10,6 +9,7 @@ use crate::{
|
|||
ToSafe,
|
||||
};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::schema::{private_message, user_, user_alias_1};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Clone)]
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use crate::{
|
||||
schema::{site, user_},
|
||||
source::{
|
||||
site::Site,
|
||||
user::{UserSafe, User_},
|
||||
|
@ -7,6 +6,7 @@ use crate::{
|
|||
ToSafe,
|
||||
};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::schema::{site, user_};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Serialize, Clone)]
|
||||
|
|
|
@ -2,19 +2,6 @@ use crate::{
|
|||
aggregates::comment_aggregates::CommentAggregates,
|
||||
functions::hot_rank,
|
||||
limit_and_offset,
|
||||
schema::{
|
||||
comment,
|
||||
comment_aggregates,
|
||||
comment_like,
|
||||
comment_saved,
|
||||
community,
|
||||
community_follower,
|
||||
community_user_ban,
|
||||
post,
|
||||
user_,
|
||||
user_alias_1,
|
||||
user_mention,
|
||||
},
|
||||
source::{
|
||||
comment::{Comment, CommentSaved},
|
||||
community::{Community, CommunityFollower, CommunitySafe, CommunityUserBan},
|
||||
|
@ -28,6 +15,19 @@ use crate::{
|
|||
ToSafe,
|
||||
};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::schema::{
|
||||
comment,
|
||||
comment_aggregates,
|
||||
comment_like,
|
||||
comment_saved,
|
||||
community,
|
||||
community_follower,
|
||||
community_user_ban,
|
||||
post,
|
||||
user_,
|
||||
user_alias_1,
|
||||
user_mention,
|
||||
};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Clone)]
|
||||
|
|
|
@ -2,7 +2,6 @@ use crate::{
|
|||
aggregates::user_aggregates::UserAggregates,
|
||||
fuzzy_search,
|
||||
limit_and_offset,
|
||||
schema::{user_, user_aggregates},
|
||||
source::user::{UserSafe, User_},
|
||||
views::ViewToVec,
|
||||
MaybeOptional,
|
||||
|
@ -10,6 +9,7 @@ use crate::{
|
|||
ToSafe,
|
||||
};
|
||||
use diesel::{dsl::*, result::Error, *};
|
||||
use lemmy_db_schema::schema::{user_, user_aggregates};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Serialize, Clone)]
|
||||
|
|
7
lemmy_db_schema/Cargo.toml
Normal file
7
lemmy_db_schema/Cargo.toml
Normal file
|
@ -0,0 +1,7 @@
|
|||
[package]
|
||||
name = "lemmy_db_schema"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
diesel = { version = "1.4.5", features = ["postgres","chrono","r2d2","serde_json"] }
|
4
lemmy_db_schema/src/lib.rs
Normal file
4
lemmy_db_schema/src/lib.rs
Normal file
|
@ -0,0 +1,4 @@
|
|||
#[macro_use]
|
||||
extern crate diesel;
|
||||
|
||||
pub mod schema;
|
|
@ -33,7 +33,7 @@ pub fn run_advanced_migrations(conn: &PgConnection) -> Result<(), LemmyError> {
|
|||
}
|
||||
|
||||
fn user_updates_2020_04_02(conn: &PgConnection) -> Result<(), LemmyError> {
|
||||
use lemmy_db::schema::user_::dsl::*;
|
||||
use lemmy_db_schema::schema::user_::dsl::*;
|
||||
|
||||
info!("Running user_updates_2020_04_02");
|
||||
|
||||
|
@ -86,7 +86,7 @@ fn user_updates_2020_04_02(conn: &PgConnection) -> Result<(), LemmyError> {
|
|||
}
|
||||
|
||||
fn community_updates_2020_04_02(conn: &PgConnection) -> Result<(), LemmyError> {
|
||||
use lemmy_db::schema::community::dsl::*;
|
||||
use lemmy_db_schema::schema::community::dsl::*;
|
||||
|
||||
info!("Running community_updates_2020_04_02");
|
||||
|
||||
|
@ -132,7 +132,7 @@ fn community_updates_2020_04_02(conn: &PgConnection) -> Result<(), LemmyError> {
|
|||
}
|
||||
|
||||
fn post_updates_2020_04_03(conn: &PgConnection) -> Result<(), LemmyError> {
|
||||
use lemmy_db::schema::post::dsl::*;
|
||||
use lemmy_db_schema::schema::post::dsl::*;
|
||||
|
||||
info!("Running post_updates_2020_04_03");
|
||||
|
||||
|
@ -157,7 +157,7 @@ fn post_updates_2020_04_03(conn: &PgConnection) -> Result<(), LemmyError> {
|
|||
}
|
||||
|
||||
fn comment_updates_2020_04_03(conn: &PgConnection) -> Result<(), LemmyError> {
|
||||
use lemmy_db::schema::comment::dsl::*;
|
||||
use lemmy_db_schema::schema::comment::dsl::*;
|
||||
|
||||
info!("Running comment_updates_2020_04_03");
|
||||
|
||||
|
@ -182,7 +182,7 @@ fn comment_updates_2020_04_03(conn: &PgConnection) -> Result<(), LemmyError> {
|
|||
}
|
||||
|
||||
fn private_message_updates_2020_05_05(conn: &PgConnection) -> Result<(), LemmyError> {
|
||||
use lemmy_db::schema::private_message::dsl::*;
|
||||
use lemmy_db_schema::schema::private_message::dsl::*;
|
||||
|
||||
info!("Running private_message_updates_2020_05_05");
|
||||
|
||||
|
@ -203,7 +203,7 @@ fn private_message_updates_2020_05_05(conn: &PgConnection) -> Result<(), LemmyEr
|
|||
}
|
||||
|
||||
fn post_thumbnail_url_updates_2020_07_27(conn: &PgConnection) -> Result<(), LemmyError> {
|
||||
use lemmy_db::schema::post::dsl::*;
|
||||
use lemmy_db_schema::schema::post::dsl::*;
|
||||
|
||||
info!("Running post_thumbnail_url_updates_2020_07_27");
|
||||
|
||||
|
|
Loading…
Reference in a new issue