}
// Remove/Restore their data if that's desired
- if data.remove_data.unwrap_or_default() {
+ if data.remove_data.unwrap_or(false) {
// Posts
blocking(context.pool(), move |conn: &'_ _| {
Post::update_removed_for_creator(conn, banned_person_id, Some(community_id), true)
}
// Remove their data if that's desired
- if data.remove_data.unwrap_or_default() {
+ if data.remove_data.unwrap_or(false) {
// Posts
blocking(context.pool(), move |conn: &'_ _| {
Post::update_removed_for_creator(conn, banned_person_id, None, true)
// If its saved only, you don't care what creator it was
// Or, if its not saved, then you only want it for that specific creator
- if !saved_only.unwrap_or_default() {
+ if !saved_only.unwrap_or(false) {
posts_query = posts_query.creator_id(person_details_id);
comments_query = comments_query.creator_id(person_details_id);
}
}
pub fn from_opt_str_to_opt_enum<T: std::str::FromStr>(opt: &Option<String>) -> Option<T> {
- match opt {
- Some(t) => match T::from_str(&t) {
- Ok(r) => Some(r),
- Err(_) => None,
- },
- None => None,
- }
+ opt.as_ref().map(|t| T::from_str(t).ok()).flatten()
}
pub fn fuzzy_search(q: &str) -> String {
.filter(comment::removed.eq(false));
}
- if self.unread_only.unwrap_or_default() {
+ if self.unread_only.unwrap_or(false) {
query = query.filter(comment::read.eq(false));
}
if let Some(listing_type) = self.listing_type {
query = match listing_type {
- // ListingType::Subscribed => query.filter(community_follower::subscribed.eq(true)),
ListingType::Subscribed => query.filter(community_follower::person_id.is_not_null()), // TODO could be this: and(community_follower::person_id.eq(person_id_join)),
ListingType::Local => query.filter(community::local.eq(true)),
_ => query,
};
}
- if self.saved_only.unwrap_or_default() {
+ if self.saved_only.unwrap_or(false) {
query = query.filter(comment_saved::id.is_not_null());
}
if let Some(listing_type) = self.listing_type {
query = match listing_type {
- ListingType::Subscribed => query.filter(community_follower::person_id.is_not_null()), // TODO could be this: and(community_follower::person_id.eq(person_id_join)),
+ ListingType::Subscribed => query.filter(community_follower::person_id.is_not_null()),
ListingType::Local => query.filter(community::local.eq(true)),
_ => query,
};
query = query.filter(person::bot_account.eq(false));
};
- // TODO These two might be wrong
- if self.saved_only.unwrap_or_default() {
+ if self.saved_only.unwrap_or(false) {
query = query.filter(post_saved::id.is_not_null());
};
- if self.unread_only.unwrap_or_default() {
+ if self.unread_only.unwrap_or(false) {
query = query.filter(post_read::id.is_not_null());
};
.into_boxed();
// If its unread, I only want the ones to me
- if self.unread_only.unwrap_or_default() {
+ if self.unread_only.unwrap_or(false) {
query = query
.filter(private_message::read.eq(false))
.filter(private_message::recipient_id.eq(self.recipient_id));
query = query.filter(person_mention::recipient_id.eq(recipient_id));
}
- if self.unread_only.unwrap_or_default() {
+ if self.unread_only.unwrap_or(false) {
query = query.filter(person_mention::read.eq(false));
}