mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-29 15:51:20 +00:00
Merge pull request #1225 from LemmyNet/fix_remove_icons
Fix invalid url error when removing icons. Fixes #1219
This commit is contained in:
commit
cfa60dcb76
4 changed files with 9 additions and 9 deletions
|
@ -140,8 +140,8 @@ impl Perform for CreateCommunity {
|
||||||
let icon = diesel_option_overwrite(&data.icon);
|
let icon = diesel_option_overwrite(&data.icon);
|
||||||
let banner = diesel_option_overwrite(&data.banner);
|
let banner = diesel_option_overwrite(&data.banner);
|
||||||
|
|
||||||
check_optional_url(&data.icon)?;
|
check_optional_url(&icon)?;
|
||||||
check_optional_url(&data.banner)?;
|
check_optional_url(&banner)?;
|
||||||
|
|
||||||
// When you create a community, make sure the user becomes a moderator and a follower
|
// When you create a community, make sure the user becomes a moderator and a follower
|
||||||
let keypair = generate_actor_keypair()?;
|
let keypair = generate_actor_keypair()?;
|
||||||
|
@ -240,8 +240,8 @@ impl Perform for EditCommunity {
|
||||||
let icon = diesel_option_overwrite(&data.icon);
|
let icon = diesel_option_overwrite(&data.icon);
|
||||||
let banner = diesel_option_overwrite(&data.banner);
|
let banner = diesel_option_overwrite(&data.banner);
|
||||||
|
|
||||||
check_optional_url(&data.icon)?;
|
check_optional_url(&icon)?;
|
||||||
check_optional_url(&data.banner)?;
|
check_optional_url(&banner)?;
|
||||||
|
|
||||||
let community_form = CommunityForm {
|
let community_form = CommunityForm {
|
||||||
name: read_community.name,
|
name: read_community.name,
|
||||||
|
|
|
@ -100,8 +100,8 @@ pub(in crate) async fn check_community_ban(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(in crate) fn check_optional_url(item: &Option<String>) -> Result<(), LemmyError> {
|
pub(in crate) fn check_optional_url(item: &Option<Option<String>>) -> Result<(), LemmyError> {
|
||||||
if let Some(item) = &item {
|
if let Some(Some(item)) = &item {
|
||||||
if Url::parse(item).is_err() {
|
if Url::parse(item).is_err() {
|
||||||
return Err(APIError::err("invalid_url").into());
|
return Err(APIError::err("invalid_url").into());
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ impl Perform for CreatePost {
|
||||||
|
|
||||||
check_community_ban(user.id, data.community_id, context.pool()).await?;
|
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
|
// Fetch Iframely and pictrs cached image
|
||||||
let (iframely_title, iframely_description, iframely_html, pictrs_thumbnail) =
|
let (iframely_title, iframely_description, iframely_html, pictrs_thumbnail) =
|
||||||
|
|
|
@ -349,8 +349,8 @@ impl Perform for SaveUserSettings {
|
||||||
let matrix_user_id = diesel_option_overwrite(&data.matrix_user_id);
|
let matrix_user_id = diesel_option_overwrite(&data.matrix_user_id);
|
||||||
|
|
||||||
// Check to make sure the avatar and banners are urls
|
// Check to make sure the avatar and banners are urls
|
||||||
check_optional_url(&data.avatar)?;
|
check_optional_url(&avatar)?;
|
||||||
check_optional_url(&data.banner)?;
|
check_optional_url(&banner)?;
|
||||||
|
|
||||||
if let Some(Some(bio)) = &bio {
|
if let Some(Some(bio)) = &bio {
|
||||||
if bio.chars().count() > 300 {
|
if bio.chars().count() > 300 {
|
||||||
|
|
Loading…
Reference in a new issue