Fix empty images

This commit is contained in:
2024-02-05 15:04:50 +01:00
parent b5d71f3418
commit d777104332
3 changed files with 138 additions and 35 deletions
+3 -2
View File
@@ -4,7 +4,7 @@ use megalodon::entities::UploadMedia;
use megalodon::generator;
use megalodon::megalodon::PostStatusInputOptions;
use megalodon::{self, megalodon::UploadMediaInputOptions};
use std::io::Cursor;
use std::io::{Cursor, Seek, SeekFrom};
use crate::{StdError, APP_USER_AGENT};
@@ -25,7 +25,8 @@ pub async fn toot(text: &str, img: Option<Box<Cursor<Vec<u8>>>>) -> StdError<()>
Some(APP_USER_AGENT.into()),
);
let mut ops = PostStatusInputOptions::default();
if let Some(img) = img {
if let Some(mut img) = img {
img.as_mut().seek(SeekFrom::Start(0))?;
let media = client
.upload_media_reader(img, Some(&UploadMediaInputOptions::default()))
.await?;