From 18111629fa3b30cb499be9decadc7be9366db5d6 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 22 Oct 2020 12:23:25 -0500 Subject: [PATCH] Fix invalid url error when removing icons. Fixes #1219 --- lemmy_api/src/community.rs | 8 ++++---- lemmy_api/src/lib.rs | 4 ++-- lemmy_api/src/post.rs | 2 +- lemmy_api/src/user.rs | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lemmy_api/src/community.rs b/lemmy_api/src/community.rs index 8b1a43bc..4149053f 100644 --- a/lemmy_api/src/community.rs +++ b/lemmy_api/src/community.rs @@ -140,8 +140,8 @@ impl Perform for CreateCommunity { let icon = diesel_option_overwrite(&data.icon); let banner = diesel_option_overwrite(&data.banner); - check_optional_url(&data.icon)?; - check_optional_url(&data.banner)?; + check_optional_url(&icon)?; + check_optional_url(&banner)?; // When you create a community, make sure the user becomes a moderator and a follower let keypair = generate_actor_keypair()?; @@ -240,8 +240,8 @@ impl Perform for EditCommunity { let icon = diesel_option_overwrite(&data.icon); let banner = diesel_option_overwrite(&data.banner); - check_optional_url(&data.icon)?; - check_optional_url(&data.banner)?; + check_optional_url(&icon)?; + check_optional_url(&banner)?; let community_form = CommunityForm { name: read_community.name, diff --git a/lemmy_api/src/lib.rs b/lemmy_api/src/lib.rs index 21be1819..0f0367cf 100644 --- a/lemmy_api/src/lib.rs +++ b/lemmy_api/src/lib.rs @@ -100,8 +100,8 @@ pub(in crate) async fn check_community_ban( } } -pub(in crate) fn check_optional_url(item: &Option) -> Result<(), LemmyError> { - if let Some(item) = &item { +pub(in crate) fn check_optional_url(item: &Option>) -> Result<(), LemmyError> { + if let Some(Some(item)) = &item { if Url::parse(item).is_err() { return Err(APIError::err("invalid_url").into()); } diff --git a/lemmy_api/src/post.rs b/lemmy_api/src/post.rs index c013cbbd..755b98af 100644 --- a/lemmy_api/src/post.rs +++ b/lemmy_api/src/post.rs @@ -59,7 +59,7 @@ impl Perform for CreatePost { check_community_ban(user.id, data.community_id, context.pool()).await?; - check_optional_url(&data.url)?; + check_optional_url(&Some(data.url.to_owned()))?; // Fetch Iframely and pictrs cached image let (iframely_title, iframely_description, iframely_html, pictrs_thumbnail) = diff --git a/lemmy_api/src/user.rs b/lemmy_api/src/user.rs index 58d119a6..02accc87 100644 --- a/lemmy_api/src/user.rs +++ b/lemmy_api/src/user.rs @@ -349,8 +349,8 @@ impl Perform for SaveUserSettings { let matrix_user_id = diesel_option_overwrite(&data.matrix_user_id); // Check to make sure the avatar and banners are urls - check_optional_url(&data.avatar)?; - check_optional_url(&data.banner)?; + check_optional_url(&avatar)?; + check_optional_url(&banner)?; if let Some(Some(bio)) = &bio { if bio.chars().count() > 300 { -- 2.44.1