Move community to lemmy_db_schema

pull/1329/head
Felix Ableitner 3 years ago
parent f842bbff8d
commit a7e231b35b

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -11,7 +11,13 @@ use anyhow::Context;
use lemmy_apub::ActorType; use lemmy_apub::ActorType;
use lemmy_db::{ use lemmy_db::{
diesel_option_overwrite, diesel_option_overwrite,
source::{comment::Comment_, community::*, moderator::*, post::Post_, site::*}, source::{
comment::Comment_,
community::{CommunityModerator_, Community_},
moderator::*,
post::Post_,
site::*,
},
views::{ views::{
comment_view::CommentQueryBuilder, comment_view::CommentQueryBuilder,
community::{ community::{
@ -30,7 +36,7 @@ use lemmy_db::{
}; };
use lemmy_db_schema::{ use lemmy_db_schema::{
naive_now, naive_now,
source::{comment::Comment, post::Post}, source::{comment::Comment, community::*, post::Post},
}; };
use lemmy_structs::{blocking, community::*}; use lemmy_structs::{blocking, community::*};
use lemmy_utils::{ use lemmy_utils::{

@ -1,12 +1,16 @@
use crate::claims::Claims; use crate::claims::Claims;
use actix_web::{web, web::Data}; use actix_web::{web, web::Data};
use lemmy_db::{ use lemmy_db::{
source::community::{Community, CommunityModerator}, source::community::{CommunityModerator_, Community_},
views::community::community_user_ban_view::CommunityUserBanView, views::community::community_user_ban_view::CommunityUserBanView,
Crud, Crud,
DbPool, DbPool,
}; };
use lemmy_db_schema::source::{post::Post, user::User_}; use lemmy_db_schema::source::{
community::{Community, CommunityModerator},
post::Post,
user::User_,
};
use lemmy_structs::{blocking, comment::*, community::*, post::*, site::*, user::*}; use lemmy_structs::{blocking, comment::*, community::*, post::*, site::*, user::*};
use lemmy_utils::{settings::Settings, APIError, ConnectionId, LemmyError}; use lemmy_utils::{settings::Settings, APIError, ConnectionId, LemmyError};
use lemmy_websocket::{serialize_websocket_message, LemmyContext, UserOperation}; use lemmy_websocket::{serialize_websocket_message, LemmyContext, UserOperation};

@ -18,7 +18,7 @@ use lemmy_db::{
diesel_option_overwrite, diesel_option_overwrite,
source::{ source::{
comment::Comment_, comment::Comment_,
community::*, community::Community_,
moderator::*, moderator::*,
password_reset_request::*, password_reset_request::*,
post::Post_, post::Post_,
@ -49,7 +49,7 @@ use lemmy_db::{
}; };
use lemmy_db_schema::{ use lemmy_db_schema::{
naive_now, naive_now,
source::{comment::Comment, post::Post, user::*}, source::{comment::Comment, community::*, post::Post, user::*},
}; };
use lemmy_structs::{blocking, send_email_to_user, user::*}; use lemmy_structs::{blocking, send_email_to_user, user::*};
use lemmy_utils::{ use lemmy_utils::{

@ -5,10 +5,11 @@ use activitystreams::{
}; };
use anyhow::Context; use anyhow::Context;
use lemmy_db::{ use lemmy_db::{
source::community::Community, source::community::Community_,
views::community::community_view::CommunityView, views::community::community_view::CommunityView,
ApubObject, ApubObject,
}; };
use lemmy_db_schema::source::community::Community;
use lemmy_structs::{blocking, community::CommunityResponse}; use lemmy_structs::{blocking, community::CommunityResponse};
use lemmy_utils::{location_info, LemmyError}; use lemmy_utils::{location_info, LemmyError};
use lemmy_websocket::{messages::SendCommunityRoomMessage, LemmyContext, UserOperation}; use lemmy_websocket::{messages::SendCommunityRoomMessage, LemmyContext, UserOperation};

@ -26,8 +26,8 @@ use activitystreams::{
}; };
use anyhow::anyhow; use anyhow::anyhow;
use itertools::Itertools; use itertools::Itertools;
use lemmy_db::{source::community::Community, Crud, DbPool}; use lemmy_db::{Crud, DbPool};
use lemmy_db_schema::source::{comment::Comment, post::Post, user::User_}; use lemmy_db_schema::source::{comment::Comment, community::Community, post::Post, user::User_};
use lemmy_structs::{blocking, WebFingerResponse}; use lemmy_structs::{blocking, WebFingerResponse};
use lemmy_utils::{ use lemmy_utils::{
request::{retry, RecvError}, request::{retry, RecvError},

@ -23,11 +23,8 @@ use activitystreams::{
}; };
use anyhow::Context; use anyhow::Context;
use itertools::Itertools; use itertools::Itertools;
use lemmy_db::{ use lemmy_db::{views::community::community_follower_view::CommunityFollowerView, DbPool};
source::community::Community, use lemmy_db_schema::source::community::Community;
views::community::community_follower_view::CommunityFollowerView,
DbPool,
};
use lemmy_structs::blocking; use lemmy_structs::blocking;
use lemmy_utils::{location_info, settings::Settings, LemmyError}; use lemmy_utils::{location_info, settings::Settings, LemmyError};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;

@ -21,8 +21,8 @@ use activitystreams::{
prelude::*, prelude::*,
public, public,
}; };
use lemmy_db::{source::community::Community, Crud}; use lemmy_db::Crud;
use lemmy_db_schema::source::{post::Post, user::User_}; use lemmy_db_schema::source::{community::Community, post::Post, user::User_};
use lemmy_structs::blocking; use lemmy_structs::blocking;
use lemmy_utils::LemmyError; use lemmy_utils::LemmyError;
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;

@ -13,13 +13,11 @@ use activitystreams::{
base::{AnyBase, BaseExt, ExtendsExt}, base::{AnyBase, BaseExt, ExtendsExt},
object::ObjectExt, object::ObjectExt,
}; };
use lemmy_db::{ use lemmy_db::{ApubObject, DbPool, Followable};
source::community::{Community, CommunityFollower, CommunityFollowerForm}, use lemmy_db_schema::source::{
ApubObject, community::{Community, CommunityFollower, CommunityFollowerForm},
DbPool, user::User_,
Followable,
}; };
use lemmy_db_schema::source::user::User_;
use lemmy_structs::blocking; use lemmy_structs::blocking;
use lemmy_utils::LemmyError; use lemmy_utils::LemmyError;
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;

@ -19,8 +19,8 @@ use background_jobs::{
WorkerConfig, WorkerConfig,
}; };
use itertools::Itertools; use itertools::Itertools;
use lemmy_db::{source::community::Community, DbPool}; use lemmy_db::DbPool;
use lemmy_db_schema::source::user::User_; use lemmy_db_schema::source::{community::Community, user::User_};
use lemmy_utils::{location_info, settings::Settings, LemmyError}; use lemmy_utils::{location_info, settings::Settings, LemmyError};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
use log::{debug, warn}; use log::{debug, warn};

@ -13,10 +13,7 @@ use anyhow::{anyhow, Context};
use chrono::NaiveDateTime; use chrono::NaiveDateTime;
use diesel::result::Error::NotFound; use diesel::result::Error::NotFound;
use lemmy_db::{ use lemmy_db::{
source::{ source::user::User,
community::{Community, CommunityModerator, CommunityModeratorForm},
user::User,
},
views::{ views::{
comment_view::CommentView, comment_view::CommentView,
community::community_view::CommunityView, community::community_view::CommunityView,
@ -30,7 +27,12 @@ use lemmy_db::{
}; };
use lemmy_db_schema::{ use lemmy_db_schema::{
naive_now, naive_now,
source::{comment::Comment, post::Post, user::User_}, source::{
comment::Comment,
community::{Community, CommunityModerator, CommunityModeratorForm},
post::Post,
user::User_,
},
}; };
use lemmy_structs::{blocking, site::SearchResponse}; use lemmy_structs::{blocking, site::SearchResponse};
use lemmy_utils::{ use lemmy_utils::{

@ -10,10 +10,10 @@ use activitystreams::{
}; };
use actix_web::{body::Body, web, HttpResponse}; use actix_web::{body::Body, web, HttpResponse};
use lemmy_db::{ use lemmy_db::{
source::{community::Community, post::Post_}, source::{community::Community_, post::Post_},
views::community::community_follower_view::CommunityFollowerView, views::community::community_follower_view::CommunityFollowerView,
}; };
use lemmy_db_schema::source::post::Post; use lemmy_db_schema::source::{community::Community, post::Post};
use lemmy_structs::blocking; use lemmy_structs::blocking;
use lemmy_utils::LemmyError; use lemmy_utils::LemmyError;
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;

@ -27,13 +27,16 @@ use activitystreams::{
use actix_web::{web, HttpRequest, HttpResponse}; use actix_web::{web, HttpRequest, HttpResponse};
use anyhow::{anyhow, Context}; use anyhow::{anyhow, Context};
use lemmy_db::{ use lemmy_db::{
source::community::{Community, CommunityFollower, CommunityFollowerForm}, source::community::Community_,
views::community::community_user_ban_view::CommunityUserBanView, views::community::community_user_ban_view::CommunityUserBanView,
ApubObject, ApubObject,
DbPool, DbPool,
Followable, Followable,
}; };
use lemmy_db_schema::source::user::User_; use lemmy_db_schema::source::{
community::{Community, CommunityFollower, CommunityFollowerForm},
user::User_,
};
use lemmy_structs::blocking; use lemmy_structs::blocking;
use lemmy_utils::{location_info, LemmyError}; use lemmy_utils::{location_info, LemmyError};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;

@ -12,12 +12,8 @@ use activitystreams::{
}; };
use actix_web::HttpRequest; use actix_web::HttpRequest;
use anyhow::{anyhow, Context}; use anyhow::{anyhow, Context};
use lemmy_db::{ use lemmy_db::{source::activity::Activity, ApubObject, DbPool};
source::{activity::Activity, community::Community}, use lemmy_db_schema::source::{community::Community, user::User_};
ApubObject,
DbPool,
};
use lemmy_db_schema::source::user::User_;
use lemmy_structs::blocking; use lemmy_structs::blocking;
use lemmy_utils::{location_info, settings::Settings, LemmyError}; use lemmy_utils::{location_info, settings::Settings, LemmyError};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;

@ -15,7 +15,8 @@ use crate::{
use activitystreams::{activity::ActorAndObject, prelude::*}; use activitystreams::{activity::ActorAndObject, prelude::*};
use actix_web::{web, HttpRequest, HttpResponse}; use actix_web::{web, HttpRequest, HttpResponse};
use anyhow::Context; use anyhow::Context;
use lemmy_db::{source::community::Community, ApubObject, DbPool}; use lemmy_db::{ApubObject, DbPool};
use lemmy_db_schema::source::community::Community;
use lemmy_structs::blocking; use lemmy_structs::blocking;
use lemmy_utils::{location_info, LemmyError}; use lemmy_utils::{location_info, LemmyError};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;

@ -49,15 +49,14 @@ use actix_web::{web, HttpRequest, HttpResponse};
use anyhow::{anyhow, Context}; use anyhow::{anyhow, Context};
use diesel::NotFound; use diesel::NotFound;
use lemmy_db::{ use lemmy_db::{
source::{ source::{private_message::PrivateMessage, user::User},
community::{Community, CommunityFollower},
private_message::PrivateMessage,
user::User,
},
ApubObject, ApubObject,
Followable, Followable,
}; };
use lemmy_db_schema::source::user::User_; use lemmy_db_schema::source::{
community::{Community, CommunityFollower},
user::User_,
};
use lemmy_structs::blocking; use lemmy_structs::blocking;
use lemmy_utils::{location_info, LemmyError}; use lemmy_utils::{location_info, LemmyError};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;

@ -23,9 +23,10 @@ use activitystreams::{
prelude::*, prelude::*,
}; };
use anyhow::{anyhow, Context}; use anyhow::{anyhow, Context};
use lemmy_db::{source::community::Community, Crud, DbPool}; use lemmy_db::{Crud, DbPool};
use lemmy_db_schema::source::{ use lemmy_db_schema::source::{
comment::{Comment, CommentForm}, comment::{Comment, CommentForm},
community::Community,
post::Post, post::Post,
user::User_, user::User_,
}; };

@ -22,12 +22,11 @@ use activitystreams::{
}; };
use activitystreams_ext::Ext2; use activitystreams_ext::Ext2;
use anyhow::Context; use anyhow::Context;
use lemmy_db::{ use lemmy_db::{views::community::community_moderator_view::CommunityModeratorView, DbPool};
use lemmy_db_schema::{
naive_now,
source::community::{Community, CommunityForm}, source::community::{Community, CommunityForm},
views::community::community_moderator_view::CommunityModeratorView,
DbPool,
}; };
use lemmy_db_schema::naive_now;
use lemmy_structs::blocking; use lemmy_structs::blocking;
use lemmy_utils::{ use lemmy_utils::{
location_info, location_info,

@ -20,8 +20,9 @@ use activitystreams::{
}; };
use activitystreams_ext::Ext1; use activitystreams_ext::Ext1;
use anyhow::Context; use anyhow::Context;
use lemmy_db::{source::community::Community, Crud, DbPool}; use lemmy_db::{Crud, DbPool};
use lemmy_db_schema::source::{ use lemmy_db_schema::source::{
community::Community,
post::{Post, PostForm}, post::{Post, PostForm},
user::User_, user::User_,
}; };

@ -24,7 +24,6 @@ impl CommunityAggregates {
mod tests { mod tests {
use crate::{ use crate::{
aggregates::community_aggregates::CommunityAggregates, aggregates::community_aggregates::CommunityAggregates,
source::community::{Community, CommunityFollower, CommunityFollowerForm, CommunityForm},
tests::establish_unpooled_connection, tests::establish_unpooled_connection,
Crud, Crud,
Followable, Followable,
@ -33,6 +32,7 @@ mod tests {
}; };
use lemmy_db_schema::source::{ use lemmy_db_schema::source::{
comment::{Comment, CommentForm}, comment::{Comment, CommentForm},
community::{Community, CommunityFollower, CommunityFollowerForm, CommunityForm},
post::{Post, PostForm}, post::{Post, PostForm},
user::{UserForm, User_}, user::{UserForm, User_},
}; };

@ -26,7 +26,6 @@ impl PostAggregates {
mod tests { mod tests {
use crate::{ use crate::{
aggregates::post_aggregates::PostAggregates, aggregates::post_aggregates::PostAggregates,
source::community::{Community, CommunityForm},
tests::establish_unpooled_connection, tests::establish_unpooled_connection,
Crud, Crud,
Likeable, Likeable,
@ -35,6 +34,7 @@ mod tests {
}; };
use lemmy_db_schema::source::{ use lemmy_db_schema::source::{
comment::{Comment, CommentForm}, comment::{Comment, CommentForm},
community::{Community, CommunityForm},
post::{Post, PostForm, PostLike, PostLikeForm}, post::{Post, PostForm, PostLike, PostLikeForm},
user::{UserForm, User_}, user::{UserForm, User_},
}; };

@ -22,7 +22,6 @@ impl SiteAggregates {
mod tests { mod tests {
use crate::{ use crate::{
aggregates::site_aggregates::SiteAggregates, aggregates::site_aggregates::SiteAggregates,
source::community::{Community, CommunityForm},
tests::establish_unpooled_connection, tests::establish_unpooled_connection,
Crud, Crud,
ListingType, ListingType,
@ -30,6 +29,7 @@ mod tests {
}; };
use lemmy_db_schema::source::{ use lemmy_db_schema::source::{
comment::{Comment, CommentForm}, comment::{Comment, CommentForm},
community::{Community, CommunityForm},
post::{Post, PostForm}, post::{Post, PostForm},
user::{UserForm, User_}, user::{UserForm, User_},
}; };

@ -25,7 +25,6 @@ impl UserAggregates {
mod tests { mod tests {
use crate::{ use crate::{
aggregates::user_aggregates::UserAggregates, aggregates::user_aggregates::UserAggregates,
source::community::{Community, CommunityForm},
tests::establish_unpooled_connection, tests::establish_unpooled_connection,
Crud, Crud,
Likeable, Likeable,
@ -34,6 +33,7 @@ mod tests {
}; };
use lemmy_db_schema::source::{ use lemmy_db_schema::source::{
comment::{Comment, CommentForm, CommentLike, CommentLikeForm}, comment::{Comment, CommentForm, CommentLike, CommentLikeForm},
community::{Community, CommunityForm},
post::{Post, PostForm, PostLike, PostLikeForm}, post::{Post, PostForm, PostLike, PostLikeForm},
user::{UserForm, User_}, user::{UserForm, User_},
}; };

@ -205,7 +205,6 @@ impl Saveable<CommentSavedForm> for CommentSaved {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::{ use crate::{
source::community::*,
tests::establish_unpooled_connection, tests::establish_unpooled_connection,
Crud, Crud,
Likeable, Likeable,
@ -215,6 +214,7 @@ mod tests {
}; };
use lemmy_db_schema::source::{ use lemmy_db_schema::source::{
comment::*, comment::*,
community::{Community, CommunityForm},
post::*, post::*,
user::{UserForm, User_}, user::{UserForm, User_},
}; };

@ -9,57 +9,22 @@ use crate::{
use diesel::{dsl::*, result::Error, *}; use diesel::{dsl::*, result::Error, *};
use lemmy_db_schema::{ use lemmy_db_schema::{
naive_now, naive_now,
schema::{community, community_follower, community_moderator, community_user_ban}, source::community::{
Community,
CommunityFollower,
CommunityFollowerForm,
CommunityForm,
CommunityModerator,
CommunityModeratorForm,
CommunityUserBan,
CommunityUserBanForm,
},
}; };
use serde::Serialize;
#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
#[table_name = "community"]
pub struct Community {
pub id: i32,
pub name: String,
pub title: String,
pub description: Option<String>,
pub category_id: i32,
pub creator_id: i32,
pub removed: bool,
pub published: chrono::NaiveDateTime,
pub updated: Option<chrono::NaiveDateTime>,
pub deleted: bool,
pub nsfw: bool,
pub actor_id: String,
pub local: bool,
pub private_key: Option<String>,
pub public_key: Option<String>,
pub last_refreshed_at: chrono::NaiveDateTime,
pub icon: Option<String>,
pub banner: Option<String>,
}
/// A safe representation of community, without the sensitive info
#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
#[table_name = "community"]
pub struct CommunitySafe {
pub id: i32,
pub name: String,
pub title: String,
pub description: Option<String>,
pub category_id: i32,
pub creator_id: i32,
pub removed: bool,
pub published: chrono::NaiveDateTime,
pub updated: Option<chrono::NaiveDateTime>,
pub deleted: bool,
pub nsfw: bool,
pub actor_id: String,
pub local: bool,
pub icon: Option<String>,
pub banner: Option<String>,
}
mod safe_type { mod safe_type {
use crate::{source::community::Community, ToSafe}; use crate::{source::community::Community, ToSafe};
use lemmy_db_schema::schema::community::columns::*; use lemmy_db_schema::schema::community::*;
type Columns = ( type Columns = (
id, id,
name, name,
@ -102,28 +67,6 @@ mod safe_type {
} }
} }
#[derive(Insertable, AsChangeset, Debug)]
#[table_name = "community"]
pub struct CommunityForm {
pub name: String,
pub title: String,
pub description: Option<String>,
pub category_id: i32,
pub creator_id: i32,
pub removed: Option<bool>,
pub published: Option<chrono::NaiveDateTime>,
pub updated: Option<chrono::NaiveDateTime>,
pub deleted: Option<bool>,
pub nsfw: bool,
pub actor_id: Option<String>,
pub local: bool,
pub private_key: Option<String>,
pub public_key: Option<String>,
pub last_refreshed_at: Option<chrono::NaiveDateTime>,
pub icon: Option<Option<String>>,
pub banner: Option<Option<String>>,
}
impl Crud<CommunityForm> for Community { impl Crud<CommunityForm> for Community {
fn read(conn: &PgConnection, community_id: i32) -> Result<Self, Error> { fn read(conn: &PgConnection, community_id: i32) -> Result<Self, Error> {
use lemmy_db_schema::schema::community::dsl::*; use lemmy_db_schema::schema::community::dsl::*;
@ -173,8 +116,35 @@ impl ApubObject<CommunityForm> for Community {
} }
} }
impl Community { pub trait Community_ {
pub fn read_from_name(conn: &PgConnection, community_name: &str) -> Result<Self, Error> { fn read_from_name(conn: &PgConnection, community_name: &str) -> Result<Community, Error>;
fn update_deleted(
conn: &PgConnection,
community_id: i32,
new_deleted: bool,
) -> Result<Community, Error>;
fn update_removed(
conn: &PgConnection,
community_id: i32,
new_removed: bool,
) -> Result<Community, Error>;
fn update_removed_for_creator(
conn: &PgConnection,
for_creator_id: i32,
new_removed: bool,
) -> Result<Vec<Community>, Error>;
fn update_creator(
conn: &PgConnection,
community_id: i32,
new_creator_id: i32,
) -> Result<Community, Error>;
fn community_mods_and_admins(conn: &PgConnection, community_id: i32) -> Result<Vec<i32>, Error>;
fn distinct_federated_communities(conn: &PgConnection) -> Result<Vec<String>, Error>;
fn is_mod_or_admin(conn: &PgConnection, user_id: i32, community_id: i32) -> bool;
}
impl Community_ for Community {
fn read_from_name(conn: &PgConnection, community_name: &str) -> Result<Community, Error> {
use lemmy_db_schema::schema::community::dsl::*; use lemmy_db_schema::schema::community::dsl::*;
community community
.filter(local.eq(true)) .filter(local.eq(true))
@ -182,44 +152,44 @@ impl Community {
.first::<Self>(conn) .first::<Self>(conn)
} }
pub fn update_deleted( fn update_deleted(
conn: &PgConnection, conn: &PgConnection,
community_id: i32, community_id: i32,
new_deleted: bool, new_deleted: bool,
) -> Result<Self, Error> { ) -> Result<Community, Error> {
use lemmy_db_schema::schema::community::dsl::*; use lemmy_db_schema::schema::community::dsl::*;
diesel::update(community.find(community_id)) diesel::update(community.find(community_id))
.set((deleted.eq(new_deleted), updated.eq(naive_now()))) .set((deleted.eq(new_deleted), updated.eq(naive_now())))
.get_result::<Self>(conn) .get_result::<Self>(conn)
} }
pub fn update_removed( fn update_removed(
conn: &PgConnection, conn: &PgConnection,
community_id: i32, community_id: i32,
new_removed: bool, new_removed: bool,
) -> Result<Self, Error> { ) -> Result<Community, Error> {
use lemmy_db_schema::schema::community::dsl::*; use lemmy_db_schema::schema::community::dsl::*;
diesel::update(community.find(community_id)) diesel::update(community.find(community_id))
.set((removed.eq(new_removed), updated.eq(naive_now()))) .set((removed.eq(new_removed), updated.eq(naive_now())))
.get_result::<Self>(conn) .get_result::<Self>(conn)
} }
pub fn update_removed_for_creator( fn update_removed_for_creator(
conn: &PgConnection, conn: &PgConnection,
for_creator_id: i32, for_creator_id: i32,
new_removed: bool, new_removed: bool,
) -> Result<Vec<Self>, Error> { ) -> Result<Vec<Community>, Error> {
use lemmy_db_schema::schema::community::dsl::*; use lemmy_db_schema::schema::community::dsl::*;
diesel::update(community.filter(creator_id.eq(for_creator_id))) diesel::update(community.filter(creator_id.eq(for_creator_id)))
.set((removed.eq(new_removed), updated.eq(naive_now()))) .set((removed.eq(new_removed), updated.eq(naive_now())))
.get_results::<Self>(conn) .get_results::<Self>(conn)
} }
pub fn update_creator( fn update_creator(
conn: &PgConnection, conn: &PgConnection,
community_id: i32, community_id: i32,
new_creator_id: i32, new_creator_id: i32,
) -> Result<Self, Error> { ) -> Result<Community, Error> {
use lemmy_db_schema::schema::community::dsl::*; use lemmy_db_schema::schema::community::dsl::*;
diesel::update(community.find(community_id)) diesel::update(community.find(community_id))
.set((creator_id.eq(new_creator_id), updated.eq(naive_now()))) .set((creator_id.eq(new_creator_id), updated.eq(naive_now())))
@ -237,35 +207,18 @@ impl Community {
Ok(mods_and_admins) Ok(mods_and_admins)
} }
pub fn distinct_federated_communities(conn: &PgConnection) -> Result<Vec<String>, Error> { fn distinct_federated_communities(conn: &PgConnection) -> Result<Vec<String>, Error> {
use lemmy_db_schema::schema::community::dsl::*; use lemmy_db_schema::schema::community::dsl::*;
community.select(actor_id).distinct().load::<String>(conn) community.select(actor_id).distinct().load::<String>(conn)
} }
pub fn is_mod_or_admin(conn: &PgConnection, user_id: i32, community_id: i32) -> bool { fn is_mod_or_admin(conn: &PgConnection, user_id: i32, community_id: i32) -> bool {
Self::community_mods_and_admins(conn, community_id) Self::community_mods_and_admins(conn, community_id)
.unwrap_or_default() .unwrap_or_default()
.contains(&user_id) .contains(&user_id)
} }
} }
#[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
#[belongs_to(Community)]
#[table_name = "community_moderator"]
pub struct CommunityModerator {
pub id: i32,
pub community_id: i32,
pub user_id: i32,
pub published: chrono::NaiveDateTime,
}
#[derive(Insertable, AsChangeset, Clone)]
#[table_name = "community_moderator"]
pub struct CommunityModeratorForm {
pub community_id: i32,
pub user_id: i32,
}
impl Joinable<CommunityModeratorForm> for CommunityModerator { impl Joinable<CommunityModeratorForm> for CommunityModerator {
fn join( fn join(
conn: &PgConnection, conn: &PgConnection,
@ -291,13 +244,21 @@ impl Joinable<CommunityModeratorForm> for CommunityModerator {
} }
} }
impl CommunityModerator { pub trait CommunityModerator_ {
pub fn delete_for_community(conn: &PgConnection, for_community_id: i32) -> Result<usize, Error> { fn delete_for_community(conn: &PgConnection, for_community_id: i32) -> Result<usize, Error>;
fn get_user_moderated_communities(
conn: &PgConnection,
for_user_id: i32,
) -> Result<Vec<i32>, Error>;
}
impl CommunityModerator_ for CommunityModerator {
fn delete_for_community(conn: &PgConnection, for_community_id: i32) -> Result<usize, Error> {
use lemmy_db_schema::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) diesel::delete(community_moderator.filter(community_id.eq(for_community_id))).execute(conn)
} }
pub fn get_user_moderated_communities( fn get_user_moderated_communities(
conn: &PgConnection, conn: &PgConnection,
for_user_id: i32, for_user_id: i32,
) -> Result<Vec<i32>, Error> { ) -> Result<Vec<i32>, Error> {
@ -309,23 +270,6 @@ impl CommunityModerator {
} }
} }
#[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
#[belongs_to(Community)]
#[table_name = "community_user_ban"]
pub struct CommunityUserBan {
pub id: i32,
pub community_id: i32,
pub user_id: i32,
pub published: chrono::NaiveDateTime,
}
#[derive(Insertable, AsChangeset, Clone)]
#[table_name = "community_user_ban"]
pub struct CommunityUserBanForm {
pub community_id: i32,
pub user_id: i32,
}
impl Bannable<CommunityUserBanForm> for CommunityUserBan { impl Bannable<CommunityUserBanForm> for CommunityUserBan {
fn ban( fn ban(
conn: &PgConnection, conn: &PgConnection,
@ -351,25 +295,6 @@ impl Bannable<CommunityUserBanForm> for CommunityUserBan {
} }
} }
#[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
#[belongs_to(Community)]
#[table_name = "community_follower"]
pub struct CommunityFollower {
pub id: i32,
pub community_id: i32,
pub user_id: i32,
pub published: chrono::NaiveDateTime,
pub pending: Option<bool>,
}
#[derive(Insertable, AsChangeset, Clone)]
#[table_name = "community_follower"]
pub struct CommunityFollowerForm {
pub community_id: i32,
pub user_id: i32,
pub pending: bool,
}
impl Followable<CommunityFollowerForm> for CommunityFollower { impl Followable<CommunityFollowerForm> for CommunityFollower {
fn follow( fn follow(
conn: &PgConnection, conn: &PgConnection,
@ -421,8 +346,16 @@ impl Followable<CommunityFollowerForm> for CommunityFollower {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::{source::community::*, tests::establish_unpooled_connection, ListingType, SortType}; use crate::{
use lemmy_db_schema::source::user::*; tests::establish_unpooled_connection,
Bannable,
Crud,
Followable,
Joinable,
ListingType,
SortType,
};
use lemmy_db_schema::source::{community::*, user::*};
#[test] #[test]
fn test_crud() { fn test_crud() {

@ -391,12 +391,13 @@ impl Crud<ModAddForm> for ModAdd {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::{ use crate::{
source::{community::*, moderator::*}, source::moderator::*,
tests::establish_unpooled_connection, tests::establish_unpooled_connection,
Crud,
ListingType, ListingType,
SortType, SortType,
}; };
use lemmy_db_schema::source::{comment::*, post::*, user::*}; use lemmy_db_schema::source::{comment::*, community::*, post::*, user::*};
// use Crud; // use Crud;
#[test] #[test]

@ -231,13 +231,11 @@ impl Readable<PostReadForm> for PostRead {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::{ use crate::{source::post::*, tests::establish_unpooled_connection, ListingType, SortType};
source::{community::*, post::*}, use lemmy_db_schema::source::{
tests::establish_unpooled_connection, community::{Community, CommunityForm},
ListingType, user::*,
SortType,
}; };
use lemmy_db_schema::source::user::*;
#[test] #[test]
fn test_crud() { fn test_crud() {

@ -79,12 +79,18 @@ impl UserMention {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::{ use crate::{
source::{community::*, user_mention::*}, source::user_mention::*,
tests::establish_unpooled_connection, tests::establish_unpooled_connection,
Crud,
ListingType, ListingType,
SortType, SortType,
}; };
use lemmy_db_schema::source::{comment::*, post::*, user::*}; use lemmy_db_schema::source::{
comment::*,
community::{Community, CommunityForm},
post::*,
user::*,
};
#[test] #[test]
fn test_crud() { fn test_crud() {

@ -1,9 +1,6 @@
use crate::{ use crate::{
limit_and_offset, limit_and_offset,
source::{ source::comment_report::CommentReport,
comment_report::CommentReport,
community::{Community, CommunitySafe},
},
views::ViewToVec, views::ViewToVec,
MaybeOptional, MaybeOptional,
ToSafe, ToSafe,
@ -13,6 +10,7 @@ use lemmy_db_schema::{
schema::{comment, comment_report, community, post, user_, user_alias_1, user_alias_2}, schema::{comment, comment_report, community, post, user_, user_alias_1, user_alias_2},
source::{ source::{
comment::Comment, comment::Comment,
community::{Community, CommunitySafe},
post::Post, post::Post,
user::{UserAlias1, UserAlias2, UserSafe, UserSafeAlias1, UserSafeAlias2, User_}, user::{UserAlias1, UserAlias2, UserSafe, UserSafeAlias1, UserSafeAlias2, User_},
}, },

@ -3,7 +3,6 @@ use crate::{
functions::hot_rank, functions::hot_rank,
fuzzy_search, fuzzy_search,
limit_and_offset, limit_and_offset,
source::community::{Community, CommunityFollower, CommunitySafe, CommunityUserBan},
views::ViewToVec, views::ViewToVec,
ListingType, ListingType,
MaybeOptional, MaybeOptional,
@ -27,6 +26,7 @@ use lemmy_db_schema::{
}, },
source::{ source::{
comment::{Comment, CommentAlias1, CommentSaved}, comment::{Comment, CommentAlias1, CommentSaved},
community::{Community, CommunityFollower, CommunitySafe, CommunityUserBan},
post::Post, post::Post,
user::{UserAlias1, UserSafe, UserSafeAlias1, User_}, user::{UserAlias1, UserSafe, UserSafeAlias1, User_},
}, },
@ -409,15 +409,8 @@ impl ViewToVec for CommentView {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::{ use crate::{tests::establish_unpooled_connection, views::comment_view::*, Crud, Likeable, *};
source::community::*, use lemmy_db_schema::source::{comment::*, community::*, post::*, user::*};
tests::establish_unpooled_connection,
views::comment_view::*,
Crud,
Likeable,
*,
};
use lemmy_db_schema::source::{comment::*, post::*, user::*};
#[test] #[test]
fn test_crud() { fn test_crud() {

@ -1,12 +1,11 @@
use crate::{ use crate::{views::ViewToVec, ToSafe};
source::community::{Community, CommunitySafe},
views::ViewToVec,
ToSafe,
};
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{community, community_follower, user_}, schema::{community, community_follower, user_},
source::user::{UserSafe, User_}, source::{
community::{Community, CommunitySafe},
user::{UserSafe, User_},
},
}; };
use serde::Serialize; use serde::Serialize;

@ -1,12 +1,11 @@
use crate::{ use crate::{views::ViewToVec, ToSafe};
source::community::{Community, CommunitySafe},
views::ViewToVec,
ToSafe,
};
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{community, community_moderator, user_}, schema::{community, community_moderator, user_},
source::user::{UserSafe, User_}, source::{
community::{Community, CommunitySafe},
user::{UserSafe, User_},
},
}; };
use serde::Serialize; use serde::Serialize;

@ -1,11 +1,11 @@
use crate::{ use crate::ToSafe;
source::community::{Community, CommunitySafe},
ToSafe,
};
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{community, community_user_ban, user_}, schema::{community, community_user_ban, user_},
source::user::{UserSafe, User_}, source::{
community::{Community, CommunitySafe},
user::{UserSafe, User_},
},
}; };
use serde::Serialize; use serde::Serialize;

@ -3,10 +3,7 @@ use crate::{
functions::hot_rank, functions::hot_rank,
fuzzy_search, fuzzy_search,
limit_and_offset, limit_and_offset,
source::{ source::category::Category,
category::Category,
community::{Community, CommunityFollower, CommunitySafe},
},
views::ViewToVec, views::ViewToVec,
MaybeOptional, MaybeOptional,
SortType, SortType,
@ -15,7 +12,10 @@ use crate::{
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{category, community, community_aggregates, community_follower, user_}, schema::{category, community, community_aggregates, community_follower, user_},
source::user::{UserSafe, User_}, source::{
community::{Community, CommunityFollower, CommunitySafe},
user::{UserSafe, User_},
},
}; };
use serde::Serialize; use serde::Serialize;

@ -1,16 +1,11 @@
use crate::{ use crate::{limit_and_offset, source::moderator::ModAddCommunity, views::ViewToVec, ToSafe};
limit_and_offset,
source::{
community::{Community, CommunitySafe},
moderator::ModAddCommunity,
},
views::ViewToVec,
ToSafe,
};
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{community, mod_add_community, user_, user_alias_1}, schema::{community, mod_add_community, user_, user_alias_1},
source::user::{UserAlias1, UserSafe, UserSafeAlias1, User_}, source::{
community::{Community, CommunitySafe},
user::{UserAlias1, UserSafe, UserSafeAlias1, User_},
},
}; };
use serde::Serialize; use serde::Serialize;

@ -1,16 +1,11 @@
use crate::{ use crate::{limit_and_offset, source::moderator::ModBanFromCommunity, views::ViewToVec, ToSafe};
limit_and_offset,
source::{
community::{Community, CommunitySafe},
moderator::ModBanFromCommunity,
},
views::ViewToVec,
ToSafe,
};
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{community, mod_ban_from_community, user_, user_alias_1}, schema::{community, mod_ban_from_community, user_, user_alias_1},
source::user::{UserAlias1, UserSafe, UserSafeAlias1, User_}, source::{
community::{Community, CommunitySafe},
user::{UserAlias1, UserSafe, UserSafeAlias1, User_},
},
}; };
use serde::Serialize; use serde::Serialize;

@ -1,16 +1,9 @@
use crate::{ use crate::{limit_and_offset, source::moderator::ModLockPost, views::ViewToVec, ToSafe};
limit_and_offset,
source::{
community::{Community, CommunitySafe},
moderator::ModLockPost,
},
views::ViewToVec,
ToSafe,
};
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{community, mod_lock_post, post, user_}, schema::{community, mod_lock_post, post, user_},
source::{ source::{
community::{Community, CommunitySafe},
post::Post, post::Post,
user::{UserSafe, User_}, user::{UserSafe, User_},
}, },

@ -1,17 +1,10 @@
use crate::{ use crate::{limit_and_offset, source::moderator::ModRemoveComment, views::ViewToVec, ToSafe};
limit_and_offset,
source::{
community::{Community, CommunitySafe},
moderator::ModRemoveComment,
},
views::ViewToVec,
ToSafe,
};
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{comment, community, mod_remove_comment, post, user_, user_alias_1}, schema::{comment, community, mod_remove_comment, post, user_, user_alias_1},
source::{ source::{
comment::Comment, comment::Comment,
community::{Community, CommunitySafe},
post::Post, post::Post,
user::{UserAlias1, UserSafe, UserSafeAlias1, User_}, user::{UserAlias1, UserSafe, UserSafeAlias1, User_},
}, },

@ -1,16 +1,11 @@
use crate::{ use crate::{limit_and_offset, source::moderator::ModRemoveCommunity, views::ViewToVec, ToSafe};
limit_and_offset,
source::{
community::{Community, CommunitySafe},
moderator::ModRemoveCommunity,
},
views::ViewToVec,
ToSafe,
};
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{community, mod_remove_community, user_}, schema::{community, mod_remove_community, user_},
source::user::{UserSafe, User_}, source::{
community::{Community, CommunitySafe},
user::{UserSafe, User_},
},
}; };
use serde::Serialize; use serde::Serialize;

@ -1,16 +1,9 @@
use crate::{ use crate::{limit_and_offset, source::moderator::ModRemovePost, views::ViewToVec, ToSafe};
limit_and_offset,
source::{
community::{Community, CommunitySafe},
moderator::ModRemovePost,
},
views::ViewToVec,
ToSafe,
};
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{community, mod_remove_post, post, user_}, schema::{community, mod_remove_post, post, user_},
source::{ source::{
community::{Community, CommunitySafe},
post::Post, post::Post,
user::{UserSafe, User_}, user::{UserSafe, User_},
}, },

@ -1,16 +1,9 @@
use crate::{ use crate::{limit_and_offset, source::moderator::ModStickyPost, views::ViewToVec, ToSafe};
limit_and_offset,
source::{
community::{Community, CommunitySafe},
moderator::ModStickyPost,
},
views::ViewToVec,
ToSafe,
};
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{community, mod_sticky_post, post, user_}, schema::{community, mod_sticky_post, post, user_},
source::{ source::{
community::{Community, CommunitySafe},
post::Post, post::Post,
user::{UserSafe, User_}, user::{UserSafe, User_},
}, },

@ -1,9 +1,6 @@
use crate::{ use crate::{
limit_and_offset, limit_and_offset,
source::{ source::post_report::PostReport,
community::{Community, CommunitySafe},
post_report::PostReport,
},
views::ViewToVec, views::ViewToVec,
MaybeOptional, MaybeOptional,
ToSafe, ToSafe,
@ -12,6 +9,7 @@ use diesel::{result::Error, *};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{community, post, post_report, user_, user_alias_1, user_alias_2}, schema::{community, post, post_report, user_, user_alias_1, user_alias_2},
source::{ source::{
community::{Community, CommunitySafe},
post::Post, post::Post,
user::{UserAlias1, UserAlias2, UserSafe, UserSafeAlias1, UserSafeAlias2, User_}, user::{UserAlias1, UserAlias2, UserSafe, UserSafeAlias1, UserSafeAlias2, User_},
}, },

@ -3,7 +3,6 @@ use crate::{
functions::hot_rank, functions::hot_rank,
fuzzy_search, fuzzy_search,
limit_and_offset, limit_and_offset,
source::community::{Community, CommunityFollower, CommunitySafe, CommunityUserBan},
views::ViewToVec, views::ViewToVec,
ListingType, ListingType,
MaybeOptional, MaybeOptional,
@ -24,6 +23,7 @@ use lemmy_db_schema::{
user_, user_,
}, },
source::{ source::{
community::{Community, CommunityFollower, CommunitySafe, CommunityUserBan},
post::{Post, PostRead, PostSaved}, post::{Post, PostRead, PostSaved},
user::{UserSafe, User_}, user::{UserSafe, User_},
}, },
@ -408,14 +408,13 @@ impl ViewToVec for PostView {
mod tests { mod tests {
use crate::{ use crate::{
aggregates::post_aggregates::PostAggregates, aggregates::post_aggregates::PostAggregates,
source::community::*,
tests::establish_unpooled_connection, tests::establish_unpooled_connection,
views::post_view::{PostQueryBuilder, PostView}, views::post_view::{PostQueryBuilder, PostView},
Crud, Crud,
Likeable, Likeable,
*, *,
}; };
use lemmy_db_schema::source::{post::*, user::*}; use lemmy_db_schema::source::{community::*, post::*, user::*};
#[test] #[test]
fn test_crud() { fn test_crud() {

@ -2,10 +2,7 @@ use crate::{
aggregates::comment_aggregates::CommentAggregates, aggregates::comment_aggregates::CommentAggregates,
functions::hot_rank, functions::hot_rank,
limit_and_offset, limit_and_offset,
source::{ source::user_mention::UserMention,
community::{Community, CommunityFollower, CommunitySafe, CommunityUserBan},
user_mention::UserMention,
},
views::ViewToVec, views::ViewToVec,
MaybeOptional, MaybeOptional,
SortType, SortType,
@ -28,6 +25,7 @@ use lemmy_db_schema::{
}, },
source::{ source::{
comment::{Comment, CommentSaved}, comment::{Comment, CommentSaved},
community::{Community, CommunityFollower, CommunitySafe, CommunityUserBan},
post::Post, post::Post,
user::{UserAlias1, UserSafe, UserSafeAlias1, User_}, user::{UserAlias1, UserSafe, UserSafeAlias1, User_},
}, },

@ -0,0 +1,121 @@
use crate::schema::{community, community_follower, community_moderator, community_user_ban};
use serde::Serialize;
#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
#[table_name = "community"]
pub struct Community {
pub id: i32,
pub name: String,
pub title: String,
pub description: Option<String>,
pub category_id: i32,
pub creator_id: i32,
pub removed: bool,
pub published: chrono::NaiveDateTime,
pub updated: Option<chrono::NaiveDateTime>,
pub deleted: bool,
pub nsfw: bool,
pub actor_id: String,
pub local: bool,
pub private_key: Option<String>,
pub public_key: Option<String>,
pub last_refreshed_at: chrono::NaiveDateTime,
pub icon: Option<String>,
pub banner: Option<String>,
}
/// A safe representation of community, without the sensitive info
#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
#[table_name = "community"]
pub struct CommunitySafe {
pub id: i32,
pub name: String,
pub title: String,
pub description: Option<String>,
pub category_id: i32,
pub creator_id: i32,
pub removed: bool,
pub published: chrono::NaiveDateTime,
pub updated: Option<chrono::NaiveDateTime>,
pub deleted: bool,
pub nsfw: bool,
pub actor_id: String,
pub local: bool,
pub icon: Option<String>,
pub banner: Option<String>,
}
#[derive(Insertable, AsChangeset, Debug)]
#[table_name = "community"]
pub struct CommunityForm {
pub name: String,
pub title: String,
pub description: Option<String>,
pub category_id: i32,
pub creator_id: i32,
pub removed: Option<bool>,
pub published: Option<chrono::NaiveDateTime>,
pub updated: Option<chrono::NaiveDateTime>,
pub deleted: Option<bool>,
pub nsfw: bool,
pub actor_id: Option<String>,
pub local: bool,
pub private_key: Option<String>,
pub public_key: Option<String>,
pub last_refreshed_at: Option<chrono::NaiveDateTime>,
pub icon: Option<Option<String>>,
pub banner: Option<Option<String>>,
}
#[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
#[belongs_to(Community)]
#[table_name = "community_moderator"]
pub struct CommunityModerator {
pub id: i32,
pub community_id: i32,
pub user_id: i32,
pub published: chrono::NaiveDateTime,
}
#[derive(Insertable, AsChangeset, Clone)]
#[table_name = "community_moderator"]
pub struct CommunityModeratorForm {
pub community_id: i32,
pub user_id: i32,
}
#[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
#[belongs_to(Community)]
#[table_name = "community_user_ban"]
pub struct CommunityUserBan {
pub id: i32,
pub community_id: i32,
pub user_id: i32,
pub published: chrono::NaiveDateTime,
}
#[derive(Insertable, AsChangeset, Clone)]
#[table_name = "community_user_ban"]
pub struct CommunityUserBanForm {
pub community_id: i32,
pub user_id: i32,
}
#[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
#[belongs_to(Community)]
#[table_name = "community_follower"]
pub struct CommunityFollower {
pub id: i32,
pub community_id: i32,
pub user_id: i32,
pub published: chrono::NaiveDateTime,
pub pending: Option<bool>,
}
#[derive(Insertable, AsChangeset, Clone)]
#[table_name = "community_follower"]
pub struct CommunityFollowerForm {
pub community_id: i32,
pub user_id: i32,
pub pending: bool,
}

@ -1,3 +1,4 @@
pub mod comment; pub mod comment;
pub mod community;
pub mod post; pub mod post;
pub mod user; pub mod user;

@ -4,18 +4,14 @@ use diesel::{
*, *,
}; };
use lemmy_db::{ use lemmy_db::{
source::{ source::{comment::Comment_, post::Post_, private_message::PrivateMessage},
comment::Comment_,
community::{Community, CommunityForm},
post::Post_,
private_message::PrivateMessage,
},
Crud, Crud,
}; };
use lemmy_db_schema::{ use lemmy_db_schema::{
naive_now, naive_now,
source::{ source::{
comment::Comment, comment::Comment,
community::{Community, CommunityForm},
post::Post, post::Post,
user::{UserForm, User_}, user::{UserForm, User_},
}, },

@ -4,7 +4,7 @@ use chrono::{DateTime, NaiveDateTime, Utc};
use diesel::PgConnection; use diesel::PgConnection;
use lemmy_api::claims::Claims; use lemmy_api::claims::Claims;
use lemmy_db::{ use lemmy_db::{
source::{community::Community, user::User}, source::{community::Community_, user::User},
views::{ views::{
comment_view::{CommentQueryBuilder, CommentView}, comment_view::{CommentQueryBuilder, CommentView},
post_view::{PostQueryBuilder, PostView}, post_view::{PostQueryBuilder, PostView},
@ -14,7 +14,7 @@ use lemmy_db::{
ListingType, ListingType,
SortType, SortType,
}; };
use lemmy_db_schema::source::user::User_; use lemmy_db_schema::source::{community::Community, user::User_};
use lemmy_structs::blocking; use lemmy_structs::blocking;
use lemmy_utils::{settings::Settings, utils::markdown_to_html, LemmyError}; use lemmy_utils::{settings::Settings, utils::markdown_to_html, LemmyError};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;

@ -1,7 +1,7 @@
use actix_web::{error::ErrorBadRequest, web::Query, *}; use actix_web::{error::ErrorBadRequest, web::Query, *};
use anyhow::anyhow; use anyhow::anyhow;
use lemmy_db::source::{community::Community, user::User}; use lemmy_db::source::{community::Community_, user::User};
use lemmy_db_schema::source::user::User_; use lemmy_db_schema::source::{community::Community, user::User_};
use lemmy_structs::{blocking, WebFingerLink, WebFingerResponse}; use lemmy_structs::{blocking, WebFingerLink, WebFingerResponse};
use lemmy_utils::{ use lemmy_utils::{
settings::Settings, settings::Settings,

@ -28,13 +28,11 @@ use lemmy_apub::{
user_inbox::user_inbox, user_inbox::user_inbox,
}, },
}; };
use lemmy_db::{ use lemmy_db::{Crud, ListingType, SortType};
source::community::{Community, CommunityForm}, use lemmy_db_schema::source::{
Crud, community::{Community, CommunityForm},
ListingType, user::{UserForm, User_},
SortType,
}; };
use lemmy_db_schema::source::user::{UserForm, User_};
use lemmy_rate_limit::{rate_limiter::RateLimiter, RateLimit}; use lemmy_rate_limit::{rate_limiter::RateLimiter, RateLimit};
use lemmy_utils::{apub::generate_actor_keypair, settings::Settings}; use lemmy_utils::{apub::generate_actor_keypair, settings::Settings};
use lemmy_websocket::{chat_server::ChatServer, LemmyContext}; use lemmy_websocket::{chat_server::ChatServer, LemmyContext};

Loading…
Cancel
Save