fix: gif emoji uploading

fix: external image proxy
This commit is contained in:
trisua 2025-05-10 22:11:12 -04:00
parent 275dd0a1eb
commit 8e241b3435
5 changed files with 17 additions and 20 deletions

View file

@ -191,7 +191,7 @@
id="avatar_file" id="avatar_file"
name="file" name="file"
type="file" type="file"
accept="image/png,image/jpeg,image/avif,image/webp" accept="image/png,image/jpeg,image/avif,image/webp,image/gif"
class="w-content" class="w-content"
/> />

View file

@ -447,12 +447,9 @@
<li>Use custom CSS on your profile</li> <li>Use custom CSS on your profile</li>
<li> <li>
Ability to use community emojis outside of Ability to use community emojis outside of
their community <b>(soon)</b> their community
</li>
<li>
Ability to upload and use gif emojis
<b>(soon)</b>
</li> </li>
<li>Ability to upload and use gif emojis</li>
<li>Create infinite stack timelines</li> <li>Create infinite stack timelines</li>
</ul> </ul>

View file

@ -141,17 +141,19 @@ pub async fn create_request(
.await .await
{ {
Ok(_) => { Ok(_) => {
if is_animated {
if let Err(e) = upload.write(&data.0, &img.0) {
return Json(Error::MiscError(e.to_string()).into());
}
} else {
if let Err(e) = save_buffer( if let Err(e) = save_buffer(
&upload.path(&data.0).to_string(), &upload.path(&data.0).to_string(),
img.0.to_vec(), img.0.to_vec(),
if is_animated { ImageFormat::WebP,
ImageFormat::Gif
} else {
ImageFormat::WebP
},
) { ) {
return Json(Error::MiscError(e.to_string()).into()); return Json(Error::MiscError(e.to_string()).into());
} }
}
Json(ApiReturn { Json(ApiReturn {
ok: true, ok: true,

View file

@ -66,9 +66,7 @@ impl Display for Error {
Self::UsernameInUse => "Username in use".to_string(), Self::UsernameInUse => "Username in use".to_string(),
Self::TitleInUse => "Title in use".to_string(), Self::TitleInUse => "Title in use".to_string(),
Self::QuestionsDisabled => "You are not allowed to ask questions there".to_string(), Self::QuestionsDisabled => "You are not allowed to ask questions there".to_string(),
Self::RequiresSupporter => { Self::RequiresSupporter => "Only site supporters can do this".to_string(),
"Only site supporters can upload GIF files as their avatar/banner".to_string()
}
_ => format!("An unknown error as occurred: ({:?})", self), _ => format!("An unknown error as occurred: ({:?})", self),
}) })
} }

View file

@ -39,7 +39,7 @@ pub fn render_markdown(input: &str) -> String {
.to_string() .to_string()
.replace( .replace(
"src=\"http", "src=\"http",
"loading=\"lazy\" src=\"/api/v1/util/proxy?url=", "loading=\"lazy\" src=\"/api/v1/util/proxy?url=http",
) )
.replace("<video loading=", "<video controls loading=") .replace("<video loading=", "<video controls loading=")
.replace("--&gt;", "<align class=\"right\">") .replace("--&gt;", "<align class=\"right\">")