]> Untitled Git - lemmy.git/blobdiff - crates/api/src/local_user.rs
Merge branch 'main' into feature/mark_post_as_read
[lemmy.git] / crates / api / src / local_user.rs
index c0ca8e32e8f460ca0364999495345d02ca92ec18..7fb4b83f9f4874dc77176ba151470a61f9b6209d 100644 (file)
@@ -16,6 +16,7 @@ use lemmy_api_common::{
 use lemmy_db_queries::{
   diesel_option_overwrite,
   diesel_option_overwrite_to_url,
+  from_opt_str_to_opt_enum,
   source::{
     comment::Comment_,
     local_user::LocalUser_,
@@ -68,7 +69,6 @@ use lemmy_websocket::{
   LemmyContext,
   UserOperation,
 };
-use std::str::FromStr;
 
 #[async_trait::async_trait(?Send)]
 impl Perform for Login {
@@ -398,7 +398,7 @@ impl Perform for BanPerson {
     }
 
     // Remove their data if that's desired
-    if data.remove_data {
+    if data.remove_data.unwrap_or(false) {
       // Posts
       blocking(context.pool(), move |conn: &'_ _| {
         Post::update_removed_for_creator(conn, banned_person_id, None, true)
@@ -463,7 +463,7 @@ impl Perform for GetReplies {
     let data: &GetReplies = &self;
     let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;
 
-    let sort = SortType::from_str(&data.sort)?;
+    let sort: Option<SortType> = from_opt_str_to_opt_enum(&data.sort);
 
     let page = data.page;
     let limit = data.limit;
@@ -473,7 +473,7 @@ impl Perform for GetReplies {
 
     let replies = blocking(context.pool(), move |conn| {
       CommentQueryBuilder::create(conn)
-        .sort(&sort)
+        .sort(sort)
         .unread_only(unread_only)
         .recipient_id(person_id)
         .show_bot_accounts(show_bot_accounts)
@@ -500,7 +500,7 @@ impl Perform for GetPersonMentions {
     let data: &GetPersonMentions = &self;
     let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;
 
-    let sort = SortType::from_str(&data.sort)?;
+    let sort: Option<SortType> = from_opt_str_to_opt_enum(&data.sort);
 
     let page = data.page;
     let limit = data.limit;
@@ -510,7 +510,7 @@ impl Perform for GetPersonMentions {
       PersonMentionQueryBuilder::create(conn)
         .recipient_id(person_id)
         .my_person_id(person_id)
-        .sort(&sort)
+        .sort(sort)
         .unread_only(unread_only)
         .page(page)
         .limit(limit)