* Remove listing type community. Fixes #2361
* Have ListingType::All be the default
}
#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy)]
}
#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy)]
use crate::structs::CommentView;
use crate::structs::CommentView;
-use diesel::{
- dsl::*,
- result::{Error, Error::QueryBuilderError},
- *,
-};
+use diesel::{dsl::*, result::Error, *};
use lemmy_db_schema::{
aggregates::structs::CommentAggregates,
newtypes::{CommentId, CommunityId, DbUrl, PersonId, PostId},
use lemmy_db_schema::{
aggregates::structs::CommentAggregates,
newtypes::{CommentId, CommunityId, DbUrl, PersonId, PostId},
pub fn create(conn: &'a PgConnection) -> Self {
CommentQueryBuilder {
conn,
pub fn create(conn: &'a PgConnection) -> Self {
CommentQueryBuilder {
conn,
+ listing_type: Some(ListingType::All),
sort: None,
community_id: None,
community_actor_id: None,
sort: None,
community_id: None,
community_actor_id: None,
.or(community_follower::person_id.eq(person_id_join)),
)
}
.or(community_follower::person_id.eq(person_id_join)),
)
}
- ListingType::Community => {
- if self.community_actor_id.is_none() && self.community_id.is_none() {
- return Err(QueryBuilderError("No community actor or id given".into()));
- } else {
- if let Some(community_id) = self.community_id {
- query = query.filter(post::community_id.eq(community_id));
- }
-
- if let Some(community_actor_id) = self.community_actor_id {
- query = query.filter(community::actor_id.eq(community_actor_id))
- }
- }
- }
+ if let Some(community_id) = self.community_id {
+ query = query.filter(post::community_id.eq(community_id));
+ }
+
+ if let Some(community_actor_id) = self.community_actor_id {
+ query = query.filter(community::actor_id.eq(community_actor_id))
+ }
+
if self.saved_only.unwrap_or(false) {
query = query.filter(comment_saved::id.is_not_null());
}
if self.saved_only.unwrap_or(false) {
query = query.filter(comment_saved::id.is_not_null());
}
use crate::structs::PostView;
use crate::structs::PostView;
-use diesel::{
- dsl::*,
- pg::Pg,
- result::{Error, Error::QueryBuilderError},
- *,
-};
+use diesel::{dsl::*, pg::Pg, result::Error, *};
use lemmy_db_schema::{
aggregates::structs::PostAggregates,
newtypes::{CommunityId, DbUrl, PersonId, PostId},
use lemmy_db_schema::{
aggregates::structs::PostAggregates,
newtypes::{CommunityId, DbUrl, PersonId, PostId},
pub fn create(conn: &'a PgConnection) -> Self {
PostQueryBuilder {
conn,
pub fn create(conn: &'a PgConnection) -> Self {
PostQueryBuilder {
conn,
+ listing_type: Some(ListingType::All),
sort: None,
creator_id: None,
community_id: None,
sort: None,
creator_id: None,
community_id: None,
.or(community_follower::person_id.eq(person_id_join)),
)
}
.or(community_follower::person_id.eq(person_id_join)),
)
}
- ListingType::Community => {
- if self.community_actor_id.is_none() && self.community_id.is_none() {
- return Err(QueryBuilderError("No community actor or id given".into()));
- } else {
- if let Some(community_id) = self.community_id {
- query = query
- .filter(post::community_id.eq(community_id))
- .then_order_by(post_aggregates::stickied.desc());
- }
-
- if let Some(community_actor_id) = self.community_actor_id {
- query = query
- .filter(community::actor_id.eq(community_actor_id))
- .then_order_by(post_aggregates::stickied.desc());
- }
- }
- }
+ if let Some(community_id) = self.community_id {
+ query = query
+ .filter(post::community_id.eq(community_id))
+ .then_order_by(post_aggregates::stickied.desc());
+ }
+
+ if let Some(community_actor_id) = self.community_actor_id {
+ query = query
+ .filter(community::actor_id.eq(community_actor_id))
+ .then_order_by(post_aggregates::stickied.desc());
+ }
+
if let Some(url_search) = self.url_search {
query = query.filter(post::url.eq(url_search));
}
if let Some(url_search) = self.url_search {
query = query.filter(post::url.eq(url_search));
}
},
traits::{Blockable, Crud, Likeable},
utils::establish_unpooled_connection,
},
traits::{Blockable, Crud, Likeable},
utils::establish_unpooled_connection,
SortType,
SubscribedType,
};
SortType,
SubscribedType,
};
};
let read_post_listings_with_person = PostQueryBuilder::create(&conn)
};
let read_post_listings_with_person = PostQueryBuilder::create(&conn)
- .listing_type(ListingType::Community)
.sort(SortType::New)
.show_bot_accounts(false)
.community_id(inserted_community.id)
.sort(SortType::New)
.show_bot_accounts(false)
.community_id(inserted_community.id)
.unwrap();
let read_post_listings_no_person = PostQueryBuilder::create(&conn)
.unwrap();
let read_post_listings_no_person = PostQueryBuilder::create(&conn)
- .listing_type(ListingType::Community)
.sort(SortType::New)
.community_id(inserted_community.id)
.list()
.sort(SortType::New)
.community_id(inserted_community.id)
.list()
CommunityBlock::block(&conn, &community_block).unwrap();
let read_post_listings_with_person_after_block = PostQueryBuilder::create(&conn)
CommunityBlock::block(&conn, &community_block).unwrap();
let read_post_listings_with_person_after_block = PostQueryBuilder::create(&conn)
- .listing_type(ListingType::Community)
.sort(SortType::New)
.show_bot_accounts(false)
.community_id(inserted_community.id)
.sort(SortType::New)
.show_bot_accounts(false)
.community_id(inserted_community.id)
CommunityQueryBuilder {
conn,
my_person_id: None,
CommunityQueryBuilder {
conn,
my_person_id: None,
+ listing_type: Some(ListingType::All),
sort: None,
show_nsfw: None,
search_term: None,
sort: None,
show_nsfw: None,
search_term: None,
let community = Community::read_from_name(conn, community_name, false)?;
let posts = PostQueryBuilder::create(conn)
let community = Community::read_from_name(conn, community_name, false)?;
let posts = PostQueryBuilder::create(conn)
- .listing_type(ListingType::Community)
.sort(*sort_type)
.community_id(community.id)
.limit(RSS_FETCH_LIMIT)
.sort(*sort_type)
.community_id(community.id)
.limit(RSS_FETCH_LIMIT)