mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-24 15:26:20 +00:00
parent
84794714da
commit
d1866cbd04
|
@ -11,10 +11,12 @@ use lemmy_db_schema::{
|
||||||
RegistrationApplicationId,
|
RegistrationApplicationId,
|
||||||
},
|
},
|
||||||
source::{
|
source::{
|
||||||
|
community::Community,
|
||||||
federation_queue_state::FederationQueueState,
|
federation_queue_state::FederationQueueState,
|
||||||
instance::Instance,
|
instance::Instance,
|
||||||
language::Language,
|
language::Language,
|
||||||
local_site_url_blocklist::LocalSiteUrlBlocklist,
|
local_site_url_blocklist::LocalSiteUrlBlocklist,
|
||||||
|
person::Person,
|
||||||
tagline::Tagline,
|
tagline::Tagline,
|
||||||
},
|
},
|
||||||
ListingType,
|
ListingType,
|
||||||
|
@ -33,12 +35,9 @@ use lemmy_db_views::structs::{
|
||||||
SiteView,
|
SiteView,
|
||||||
};
|
};
|
||||||
use lemmy_db_views_actor::structs::{
|
use lemmy_db_views_actor::structs::{
|
||||||
CommunityBlockView,
|
|
||||||
CommunityFollowerView,
|
CommunityFollowerView,
|
||||||
CommunityModeratorView,
|
CommunityModeratorView,
|
||||||
CommunityView,
|
CommunityView,
|
||||||
InstanceBlockView,
|
|
||||||
PersonBlockView,
|
|
||||||
PersonView,
|
PersonView,
|
||||||
};
|
};
|
||||||
use lemmy_db_views_moderator::structs::{
|
use lemmy_db_views_moderator::structs::{
|
||||||
|
@ -337,9 +336,9 @@ pub struct MyUserInfo {
|
||||||
pub local_user_view: LocalUserView,
|
pub local_user_view: LocalUserView,
|
||||||
pub follows: Vec<CommunityFollowerView>,
|
pub follows: Vec<CommunityFollowerView>,
|
||||||
pub moderates: Vec<CommunityModeratorView>,
|
pub moderates: Vec<CommunityModeratorView>,
|
||||||
pub community_blocks: Vec<CommunityBlockView>,
|
pub community_blocks: Vec<Community>,
|
||||||
pub instance_blocks: Vec<InstanceBlockView>,
|
pub instance_blocks: Vec<Instance>,
|
||||||
pub person_blocks: Vec<PersonBlockView>,
|
pub person_blocks: Vec<Person>,
|
||||||
pub discussion_languages: Vec<LanguageId>,
|
pub discussion_languages: Vec<LanguageId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,19 +5,15 @@ use lemmy_api_common::{
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::source::{
|
use lemmy_db_schema::source::{
|
||||||
actor_language::{LocalUserLanguage, SiteLanguage},
|
actor_language::{LocalUserLanguage, SiteLanguage},
|
||||||
|
community_block::CommunityBlock,
|
||||||
|
instance_block::InstanceBlock,
|
||||||
language::Language,
|
language::Language,
|
||||||
local_site_url_blocklist::LocalSiteUrlBlocklist,
|
local_site_url_blocklist::LocalSiteUrlBlocklist,
|
||||||
|
person_block::PersonBlock,
|
||||||
tagline::Tagline,
|
tagline::Tagline,
|
||||||
};
|
};
|
||||||
use lemmy_db_views::structs::{CustomEmojiView, LocalUserView, SiteView};
|
use lemmy_db_views::structs::{CustomEmojiView, LocalUserView, SiteView};
|
||||||
use lemmy_db_views_actor::structs::{
|
use lemmy_db_views_actor::structs::{CommunityFollowerView, CommunityModeratorView, PersonView};
|
||||||
CommunityBlockView,
|
|
||||||
CommunityFollowerView,
|
|
||||||
CommunityModeratorView,
|
|
||||||
InstanceBlockView,
|
|
||||||
PersonBlockView,
|
|
||||||
PersonView,
|
|
||||||
};
|
|
||||||
use lemmy_utils::{
|
use lemmy_utils::{
|
||||||
error::{LemmyError, LemmyErrorExt, LemmyErrorType, LemmyResult},
|
error::{LemmyError, LemmyErrorExt, LemmyErrorType, LemmyResult},
|
||||||
CACHE_DURATION_API,
|
CACHE_DURATION_API,
|
||||||
|
@ -81,9 +77,9 @@ pub async fn get_site(
|
||||||
discussion_languages,
|
discussion_languages,
|
||||||
) = lemmy_db_schema::try_join_with_pool!(pool => (
|
) = lemmy_db_schema::try_join_with_pool!(pool => (
|
||||||
|pool| CommunityFollowerView::for_person(pool, person_id),
|
|pool| CommunityFollowerView::for_person(pool, person_id),
|
||||||
|pool| CommunityBlockView::for_person(pool, person_id),
|
|pool| CommunityBlock::for_person(pool, person_id),
|
||||||
|pool| InstanceBlockView::for_person(pool, person_id),
|
|pool| InstanceBlock::for_person(pool, person_id),
|
||||||
|pool| PersonBlockView::for_person(pool, person_id),
|
|pool| PersonBlock::for_person(pool, person_id),
|
||||||
|pool| CommunityModeratorView::for_person(pool, person_id, Some(&local_user_view.local_user)),
|
|pool| CommunityModeratorView::for_person(pool, person_id, Some(&local_user_view.local_user)),
|
||||||
|pool| LocalUserLanguage::read(pool, local_user_id)
|
|pool| LocalUserLanguage::read(pool, local_user_id)
|
||||||
))
|
))
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
newtypes::{CommunityId, PersonId},
|
newtypes::{CommunityId, PersonId},
|
||||||
schema::community_block::dsl::{community_block, community_id, person_id},
|
schema::{community, community_block},
|
||||||
source::community_block::{CommunityBlock, CommunityBlockForm},
|
source::{
|
||||||
|
community::Community,
|
||||||
|
community_block::{CommunityBlock, CommunityBlockForm},
|
||||||
|
},
|
||||||
traits::Blockable,
|
traits::Blockable,
|
||||||
utils::{get_conn, DbPool},
|
utils::{get_conn, DbPool},
|
||||||
};
|
};
|
||||||
|
@ -9,6 +12,7 @@ use diesel::{
|
||||||
dsl::{exists, insert_into},
|
dsl::{exists, insert_into},
|
||||||
result::Error,
|
result::Error,
|
||||||
select,
|
select,
|
||||||
|
ExpressionMethods,
|
||||||
QueryDsl,
|
QueryDsl,
|
||||||
};
|
};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
|
@ -21,11 +25,27 @@ impl CommunityBlock {
|
||||||
) -> Result<bool, Error> {
|
) -> Result<bool, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
select(exists(
|
select(exists(
|
||||||
community_block.find((for_person_id, for_community_id)),
|
community_block::table.find((for_person_id, for_community_id)),
|
||||||
))
|
))
|
||||||
.get_result(conn)
|
.get_result(conn)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn for_person(
|
||||||
|
pool: &mut DbPool<'_>,
|
||||||
|
person_id: PersonId,
|
||||||
|
) -> Result<Vec<Community>, Error> {
|
||||||
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
community_block::table
|
||||||
|
.inner_join(community::table)
|
||||||
|
.select(community::all_columns)
|
||||||
|
.filter(community_block::person_id.eq(person_id))
|
||||||
|
.filter(community::deleted.eq(false))
|
||||||
|
.filter(community::removed.eq(false))
|
||||||
|
.order_by(community_block::published)
|
||||||
|
.load::<Community>(conn)
|
||||||
|
.await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
|
@ -33,9 +53,9 @@ impl Blockable for CommunityBlock {
|
||||||
type Form = CommunityBlockForm;
|
type Form = CommunityBlockForm;
|
||||||
async fn block(pool: &mut DbPool<'_>, community_block_form: &Self::Form) -> Result<Self, Error> {
|
async fn block(pool: &mut DbPool<'_>, community_block_form: &Self::Form) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(community_block)
|
insert_into(community_block::table)
|
||||||
.values(community_block_form)
|
.values(community_block_form)
|
||||||
.on_conflict((person_id, community_id))
|
.on_conflict((community_block::person_id, community_block::community_id))
|
||||||
.do_update()
|
.do_update()
|
||||||
.set(community_block_form)
|
.set(community_block_form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
|
@ -46,7 +66,7 @@ impl Blockable for CommunityBlock {
|
||||||
community_block_form: &Self::Form,
|
community_block_form: &Self::Form,
|
||||||
) -> Result<usize, Error> {
|
) -> Result<usize, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::delete(community_block.find((
|
diesel::delete(community_block::table.find((
|
||||||
community_block_form.person_id,
|
community_block_form.person_id,
|
||||||
community_block_form.community_id,
|
community_block_form.community_id,
|
||||||
)))
|
)))
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
newtypes::{InstanceId, PersonId},
|
newtypes::{InstanceId, PersonId},
|
||||||
schema::instance_block::dsl::{instance_block, instance_id, person_id},
|
schema::{instance, instance_block},
|
||||||
source::instance_block::{InstanceBlock, InstanceBlockForm},
|
source::{
|
||||||
|
instance::Instance,
|
||||||
|
instance_block::{InstanceBlock, InstanceBlockForm},
|
||||||
|
},
|
||||||
traits::Blockable,
|
traits::Blockable,
|
||||||
utils::{get_conn, DbPool},
|
utils::{get_conn, DbPool},
|
||||||
};
|
};
|
||||||
|
@ -9,6 +12,7 @@ use diesel::{
|
||||||
dsl::{exists, insert_into},
|
dsl::{exists, insert_into},
|
||||||
result::Error,
|
result::Error,
|
||||||
select,
|
select,
|
||||||
|
ExpressionMethods,
|
||||||
QueryDsl,
|
QueryDsl,
|
||||||
};
|
};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
|
@ -21,11 +25,25 @@ impl InstanceBlock {
|
||||||
) -> Result<bool, Error> {
|
) -> Result<bool, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
select(exists(
|
select(exists(
|
||||||
instance_block.find((for_person_id, for_instance_id)),
|
instance_block::table.find((for_person_id, for_instance_id)),
|
||||||
))
|
))
|
||||||
.get_result(conn)
|
.get_result(conn)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn for_person(
|
||||||
|
pool: &mut DbPool<'_>,
|
||||||
|
person_id: PersonId,
|
||||||
|
) -> Result<Vec<Instance>, Error> {
|
||||||
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
instance_block::table
|
||||||
|
.inner_join(instance::table)
|
||||||
|
.select(instance::all_columns)
|
||||||
|
.filter(instance_block::person_id.eq(person_id))
|
||||||
|
.order_by(instance_block::published)
|
||||||
|
.load::<Instance>(conn)
|
||||||
|
.await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
|
@ -33,9 +51,9 @@ impl Blockable for InstanceBlock {
|
||||||
type Form = InstanceBlockForm;
|
type Form = InstanceBlockForm;
|
||||||
async fn block(pool: &mut DbPool<'_>, instance_block_form: &Self::Form) -> Result<Self, Error> {
|
async fn block(pool: &mut DbPool<'_>, instance_block_form: &Self::Form) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(instance_block)
|
insert_into(instance_block::table)
|
||||||
.values(instance_block_form)
|
.values(instance_block_form)
|
||||||
.on_conflict((person_id, instance_id))
|
.on_conflict((instance_block::person_id, instance_block::instance_id))
|
||||||
.do_update()
|
.do_update()
|
||||||
.set(instance_block_form)
|
.set(instance_block_form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
|
@ -46,7 +64,7 @@ impl Blockable for InstanceBlock {
|
||||||
instance_block_form: &Self::Form,
|
instance_block_form: &Self::Form,
|
||||||
) -> Result<usize, Error> {
|
) -> Result<usize, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::delete(instance_block.find((
|
diesel::delete(instance_block::table.find((
|
||||||
instance_block_form.person_id,
|
instance_block_form.person_id,
|
||||||
instance_block_form.instance_id,
|
instance_block_form.instance_id,
|
||||||
)))
|
)))
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
newtypes::PersonId,
|
newtypes::PersonId,
|
||||||
schema::person_block::dsl::{person_block, person_id, target_id},
|
schema::{person, person_block},
|
||||||
source::person_block::{PersonBlock, PersonBlockForm},
|
source::{
|
||||||
|
person::Person,
|
||||||
|
person_block::{PersonBlock, PersonBlockForm},
|
||||||
|
},
|
||||||
traits::Blockable,
|
traits::Blockable,
|
||||||
utils::{get_conn, DbPool},
|
utils::{get_conn, DbPool},
|
||||||
};
|
};
|
||||||
|
@ -9,6 +12,8 @@ use diesel::{
|
||||||
dsl::{exists, insert_into},
|
dsl::{exists, insert_into},
|
||||||
result::Error,
|
result::Error,
|
||||||
select,
|
select,
|
||||||
|
ExpressionMethods,
|
||||||
|
JoinOnDsl,
|
||||||
QueryDsl,
|
QueryDsl,
|
||||||
};
|
};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
|
@ -20,10 +25,32 @@ impl PersonBlock {
|
||||||
for_recipient_id: PersonId,
|
for_recipient_id: PersonId,
|
||||||
) -> Result<bool, Error> {
|
) -> Result<bool, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
select(exists(person_block.find((for_person_id, for_recipient_id))))
|
select(exists(
|
||||||
|
person_block::table.find((for_person_id, for_recipient_id)),
|
||||||
|
))
|
||||||
.get_result(conn)
|
.get_result(conn)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn for_person(
|
||||||
|
pool: &mut DbPool<'_>,
|
||||||
|
person_id: PersonId,
|
||||||
|
) -> Result<Vec<Person>, Error> {
|
||||||
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
let target_person_alias = diesel::alias!(person as person1);
|
||||||
|
|
||||||
|
person_block::table
|
||||||
|
.inner_join(person::table.on(person_block::person_id.eq(person::id)))
|
||||||
|
.inner_join(
|
||||||
|
target_person_alias.on(person_block::target_id.eq(target_person_alias.field(person::id))),
|
||||||
|
)
|
||||||
|
.select(target_person_alias.fields(person::all_columns))
|
||||||
|
.filter(person_block::person_id.eq(person_id))
|
||||||
|
.filter(target_person_alias.field(person::deleted).eq(false))
|
||||||
|
.order_by(person_block::published)
|
||||||
|
.load::<Person>(conn)
|
||||||
|
.await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
|
@ -34,9 +61,9 @@ impl Blockable for PersonBlock {
|
||||||
person_block_form: &PersonBlockForm,
|
person_block_form: &PersonBlockForm,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(person_block)
|
insert_into(person_block::table)
|
||||||
.values(person_block_form)
|
.values(person_block_form)
|
||||||
.on_conflict((person_id, target_id))
|
.on_conflict((person_block::person_id, person_block::target_id))
|
||||||
.do_update()
|
.do_update()
|
||||||
.set(person_block_form)
|
.set(person_block_form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
|
@ -44,7 +71,9 @@ impl Blockable for PersonBlock {
|
||||||
}
|
}
|
||||||
async fn unblock(pool: &mut DbPool<'_>, person_block_form: &Self::Form) -> Result<usize, Error> {
|
async fn unblock(pool: &mut DbPool<'_>, person_block_form: &Self::Form) -> Result<usize, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::delete(person_block.find((person_block_form.person_id, person_block_form.target_id)))
|
diesel::delete(
|
||||||
|
person_block::table.find((person_block_form.person_id, person_block_form.target_id)),
|
||||||
|
)
|
||||||
.execute(conn)
|
.execute(conn)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
use crate::structs::CommunityBlockView;
|
|
||||||
use diesel::{result::Error, ExpressionMethods, QueryDsl};
|
|
||||||
use diesel_async::RunQueryDsl;
|
|
||||||
use lemmy_db_schema::{
|
|
||||||
newtypes::PersonId,
|
|
||||||
schema::{community, community_block, person},
|
|
||||||
utils::{get_conn, DbPool},
|
|
||||||
};
|
|
||||||
|
|
||||||
impl CommunityBlockView {
|
|
||||||
pub async fn for_person(pool: &mut DbPool<'_>, person_id: PersonId) -> Result<Vec<Self>, Error> {
|
|
||||||
let conn = &mut get_conn(pool).await?;
|
|
||||||
community_block::table
|
|
||||||
.inner_join(person::table)
|
|
||||||
.inner_join(community::table)
|
|
||||||
.select((person::all_columns, community::all_columns))
|
|
||||||
.filter(community_block::person_id.eq(person_id))
|
|
||||||
.filter(community::deleted.eq(false))
|
|
||||||
.filter(community::removed.eq(false))
|
|
||||||
.order_by(community_block::published)
|
|
||||||
.load::<CommunityBlockView>(conn)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
use crate::structs::InstanceBlockView;
|
|
||||||
use diesel::{result::Error, ExpressionMethods, JoinOnDsl, NullableExpressionMethods, QueryDsl};
|
|
||||||
use diesel_async::RunQueryDsl;
|
|
||||||
use lemmy_db_schema::{
|
|
||||||
newtypes::PersonId,
|
|
||||||
schema::{instance, instance_block, person, site},
|
|
||||||
utils::{get_conn, DbPool},
|
|
||||||
};
|
|
||||||
|
|
||||||
impl InstanceBlockView {
|
|
||||||
pub async fn for_person(pool: &mut DbPool<'_>, person_id: PersonId) -> Result<Vec<Self>, Error> {
|
|
||||||
let conn = &mut get_conn(pool).await?;
|
|
||||||
instance_block::table
|
|
||||||
.inner_join(person::table)
|
|
||||||
.inner_join(instance::table)
|
|
||||||
.left_join(site::table.on(site::instance_id.eq(instance::id)))
|
|
||||||
.select((
|
|
||||||
person::all_columns,
|
|
||||||
instance::all_columns,
|
|
||||||
site::all_columns.nullable(),
|
|
||||||
))
|
|
||||||
.filter(instance_block::person_id.eq(person_id))
|
|
||||||
.order_by(instance_block::published)
|
|
||||||
.load::<InstanceBlockView>(conn)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +1,6 @@
|
||||||
#[cfg(feature = "full")]
|
#[cfg(feature = "full")]
|
||||||
pub mod comment_reply_view;
|
pub mod comment_reply_view;
|
||||||
#[cfg(feature = "full")]
|
#[cfg(feature = "full")]
|
||||||
pub mod community_block_view;
|
|
||||||
#[cfg(feature = "full")]
|
|
||||||
pub mod community_follower_view;
|
pub mod community_follower_view;
|
||||||
#[cfg(feature = "full")]
|
#[cfg(feature = "full")]
|
||||||
pub mod community_moderator_view;
|
pub mod community_moderator_view;
|
||||||
|
@ -11,10 +9,6 @@ pub mod community_person_ban_view;
|
||||||
#[cfg(feature = "full")]
|
#[cfg(feature = "full")]
|
||||||
pub mod community_view;
|
pub mod community_view;
|
||||||
#[cfg(feature = "full")]
|
#[cfg(feature = "full")]
|
||||||
pub mod instance_block_view;
|
|
||||||
#[cfg(feature = "full")]
|
|
||||||
pub mod person_block_view;
|
|
||||||
#[cfg(feature = "full")]
|
|
||||||
pub mod person_mention_view;
|
pub mod person_mention_view;
|
||||||
#[cfg(feature = "full")]
|
#[cfg(feature = "full")]
|
||||||
pub mod person_view;
|
pub mod person_view;
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
use crate::structs::PersonBlockView;
|
|
||||||
use diesel::{result::Error, ExpressionMethods, JoinOnDsl, QueryDsl};
|
|
||||||
use diesel_async::RunQueryDsl;
|
|
||||||
use lemmy_db_schema::{
|
|
||||||
newtypes::PersonId,
|
|
||||||
schema::{person, person_block},
|
|
||||||
utils::{get_conn, DbPool},
|
|
||||||
};
|
|
||||||
|
|
||||||
impl PersonBlockView {
|
|
||||||
pub async fn for_person(pool: &mut DbPool<'_>, person_id: PersonId) -> Result<Vec<Self>, Error> {
|
|
||||||
let conn = &mut get_conn(pool).await?;
|
|
||||||
let target_person_alias = diesel::alias!(person as person1);
|
|
||||||
|
|
||||||
person_block::table
|
|
||||||
.inner_join(person::table.on(person_block::person_id.eq(person::id)))
|
|
||||||
.inner_join(
|
|
||||||
target_person_alias.on(person_block::target_id.eq(target_person_alias.field(person::id))),
|
|
||||||
)
|
|
||||||
.select((
|
|
||||||
person::all_columns,
|
|
||||||
target_person_alias.fields(person::all_columns),
|
|
||||||
))
|
|
||||||
.filter(person_block::person_id.eq(person_id))
|
|
||||||
.filter(target_person_alias.field(person::deleted).eq(false))
|
|
||||||
.order_by(person_block::published)
|
|
||||||
.load::<PersonBlockView>(conn)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -6,11 +6,9 @@ use lemmy_db_schema::{
|
||||||
comment::Comment,
|
comment::Comment,
|
||||||
comment_reply::CommentReply,
|
comment_reply::CommentReply,
|
||||||
community::Community,
|
community::Community,
|
||||||
instance::Instance,
|
|
||||||
person::Person,
|
person::Person,
|
||||||
person_mention::PersonMention,
|
person_mention::PersonMention,
|
||||||
post::Post,
|
post::Post,
|
||||||
site::Site,
|
|
||||||
},
|
},
|
||||||
SubscribedType,
|
SubscribedType,
|
||||||
};
|
};
|
||||||
|
@ -19,28 +17,6 @@ use serde_with::skip_serializing_none;
|
||||||
#[cfg(feature = "full")]
|
#[cfg(feature = "full")]
|
||||||
use ts_rs::TS;
|
use ts_rs::TS;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
||||||
#[cfg_attr(feature = "full", derive(TS, Queryable))]
|
|
||||||
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
|
||||||
#[cfg_attr(feature = "full", ts(export))]
|
|
||||||
/// A community block.
|
|
||||||
pub struct CommunityBlockView {
|
|
||||||
pub person: Person,
|
|
||||||
pub community: Community,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[skip_serializing_none]
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
||||||
#[cfg_attr(feature = "full", derive(TS, Queryable))]
|
|
||||||
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
|
||||||
#[cfg_attr(feature = "full", ts(export))]
|
|
||||||
/// An instance block by a user.
|
|
||||||
pub struct InstanceBlockView {
|
|
||||||
pub person: Person,
|
|
||||||
pub instance: Instance,
|
|
||||||
pub site: Option<Site>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
#[cfg_attr(feature = "full", derive(TS, Queryable))]
|
#[cfg_attr(feature = "full", derive(TS, Queryable))]
|
||||||
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
||||||
|
@ -83,16 +59,6 @@ pub struct CommunityView {
|
||||||
pub banned_from_community: bool,
|
pub banned_from_community: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
||||||
#[cfg_attr(feature = "full", derive(TS, Queryable))]
|
|
||||||
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
|
||||||
#[cfg_attr(feature = "full", ts(export))]
|
|
||||||
/// A person block.
|
|
||||||
pub struct PersonBlockView {
|
|
||||||
pub person: Person,
|
|
||||||
pub target: Person,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[skip_serializing_none]
|
#[skip_serializing_none]
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
|
||||||
#[cfg_attr(feature = "full", derive(TS, Queryable))]
|
#[cfg_attr(feature = "full", derive(TS, Queryable))]
|
||||||
|
|
Loading…
Reference in a new issue