Log invalid emoji names

This commit is contained in:
silverpill 2023-03-14 18:42:21 +00:00
parent c7fd3ddc83
commit a3a4579e03

View file

@ -244,9 +244,9 @@ pub async fn handle_emoji(
return Ok(None); return Ok(None);
}, },
}; };
let tag_name = tag.name.trim_matches(':'); let emoji_name = tag.name.trim_matches(':');
if validate_emoji_name(tag_name).is_err() { if validate_emoji_name(emoji_name).is_err() {
log::warn!("invalid emoji name"); log::warn!("invalid emoji name: {}", emoji_name);
return Ok(None); return Ok(None);
}; };
let maybe_emoji_id = match get_emoji_by_remote_object_id( let maybe_emoji_id = match get_emoji_by_remote_object_id(
@ -258,7 +258,7 @@ pub async fn handle_emoji(
// Emoji already exists and is up to date // Emoji already exists and is up to date
return Ok(Some(emoji)); return Ok(Some(emoji));
}; };
if emoji.emoji_name != tag_name { if emoji.emoji_name != emoji_name {
log::warn!("emoji name can't be changed"); log::warn!("emoji name can't be changed");
return Ok(None); return Ok(None);
}; };
@ -306,7 +306,7 @@ pub async fn handle_emoji(
.map_err(|_| ValidationError("invalid emoji ID"))?; .map_err(|_| ValidationError("invalid emoji ID"))?;
create_emoji( create_emoji(
db_client, db_client,
tag_name, emoji_name,
Some(&hostname), Some(&hostname),
image, image,
Some(&tag.id), Some(&tag.id),