From 66a2930a6f9dd03a6e367c6b8593e0412a67d5f8 Mon Sep 17 00:00:00 2001
From: Martin Loffler <git@fatalerrorcoded.eu>
Date: Tue, 5 Jan 2021 14:49:56 +0100
Subject: [PATCH] Code cleanup Cleaned up - matches in routes remove_friend and
 unblock_user - production warnings in util/variables

---
 src/routes/users/remove_friend.rs |  7 ++-----
 src/routes/users/unblock_user.rs  |  9 ++-------
 src/util/variables.rs             | 14 ++++----------
 3 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/src/routes/users/remove_friend.rs b/src/routes/users/remove_friend.rs
index ebec7c6..7d16277 100644
--- a/src/routes/users/remove_friend.rs
+++ b/src/routes/users/remove_friend.rs
@@ -16,10 +16,6 @@ pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
     let col = get_collection("users");
 
     match get_relationship(&user, &target) {
-        RelationshipStatus::Blocked
-        | RelationshipStatus::BlockedOther
-        | RelationshipStatus::User
-        | RelationshipStatus::None => Err(Error::NoEffect),
         RelationshipStatus::Friend
         | RelationshipStatus::Outgoing
         | RelationshipStatus::Incoming => {
@@ -79,6 +75,7 @@ pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
                     with: "user",
                 }),
             }
-        }
+        },
+        _ => Err(Error::NoEffect),
     }
 }
diff --git a/src/routes/users/unblock_user.rs b/src/routes/users/unblock_user.rs
index 2d7a13b..7115868 100644
--- a/src/routes/users/unblock_user.rs
+++ b/src/routes/users/unblock_user.rs
@@ -16,12 +16,6 @@ pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
     let col = get_collection("users");
 
     match get_relationship(&user, &target) {
-        RelationshipStatus::None
-        | RelationshipStatus::User
-        | RelationshipStatus::BlockedOther
-        | RelationshipStatus::Incoming
-        | RelationshipStatus::Outgoing
-        | RelationshipStatus::Friend => Err(Error::NoEffect),
         RelationshipStatus::Blocked => {
             match get_relationship(&target.fetch_user().await?, &user.as_ref()) {
                 RelationshipStatus::Blocked => {
@@ -114,6 +108,7 @@ pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
                 }
                 _ => Err(Error::InternalError),
             }
-        }
+        },
+        _ => Err(Error::NoEffect),
     }
 }
diff --git a/src/util/variables.rs b/src/util/variables.rs
index 2826984..9e630dd 100644
--- a/src/util/variables.rs
+++ b/src/util/variables.rs
@@ -42,12 +42,8 @@ lazy_static! {
 pub fn preflight_checks() {
     if *USE_EMAIL == false {
         #[cfg(not(debug_assertions))]
-        {
-            if !env::var("REVOLT_UNSAFE_NO_EMAIL").map_or(false, |v| v == *"1") {
-                panic!(
-                    "Not letting you run this in production, set REVOLT_UNSAFE_NO_EMAIL=1 to run."
-                );
-            }
+        if !env::var("REVOLT_UNSAFE_NO_EMAIL").map_or(false, |v| v == *"1") {
+            panic!("Running in production without email is not recommended, set REVOLT_UNSAFE_NO_EMAIL=1 to override.");
         }
 
         #[cfg(debug_assertions)]
@@ -56,10 +52,8 @@ pub fn preflight_checks() {
 
     if *USE_HCAPTCHA == false {
         #[cfg(not(debug_assertions))]
-        {
-            if !env::var("REVOLT_UNSAFE_NO_CAPTCHA").map_or(false, |v| v == *"1") {
-                panic!("Not letting you run this in production, set REVOLT_UNSAFE_NO_CAPTCHA=1 to run.");
-            }
+        if !env::var("REVOLT_UNSAFE_NO_CAPTCHA").map_or(false, |v| v == *"1") {
+            panic!("Running in production without CAPTCHA is not recommended, set REVOLT_UNSAFE_NO_CAPTCHA=1 to override.");
         }
 
         #[cfg(debug_assertions)]
-- 
GitLab