feat: add image upload for avatar and banner
This commit is contained in:
@@ -14,6 +14,7 @@ chrono = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
futures = { workspace = true }
|
||||
url = { workspace = true }
|
||||
bytes = { workspace = true }
|
||||
sha2 = { version = "0.10", optional = true }
|
||||
hex = { version = "0.4", optional = true }
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use std::collections::HashMap;
|
||||
use std::pin::Pin;
|
||||
|
||||
use crate::{
|
||||
errors::DomainError,
|
||||
@@ -19,6 +20,17 @@ use crate::{
|
||||
},
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use bytes::Bytes;
|
||||
|
||||
pub type DataStream =
|
||||
Pin<Box<dyn futures::stream::Stream<Item = Result<Bytes, DomainError>> + Send>>;
|
||||
|
||||
#[async_trait]
|
||||
pub trait MediaStore: Send + Sync {
|
||||
async fn put(&self, key: &str, data: DataStream) -> Result<(), DomainError>;
|
||||
async fn get(&self, key: &str) -> Result<DataStream, DomainError>;
|
||||
async fn delete(&self, key: &str) -> Result<(), DomainError>;
|
||||
}
|
||||
|
||||
pub struct GeneratedToken {
|
||||
pub token: String,
|
||||
|
||||
@@ -134,11 +134,21 @@ impl UserWriter for TestStore {
|
||||
.iter_mut()
|
||||
.find(|u| &u.id == user_id)
|
||||
{
|
||||
u.display_name = input.display_name;
|
||||
u.bio = input.bio;
|
||||
u.avatar_url = input.avatar_url;
|
||||
u.header_url = input.header_url;
|
||||
u.custom_css = input.custom_css;
|
||||
if let Some(v) = input.display_name {
|
||||
u.display_name = Some(v);
|
||||
}
|
||||
if let Some(v) = input.bio {
|
||||
u.bio = Some(v);
|
||||
}
|
||||
if let Some(v) = input.avatar_url {
|
||||
u.avatar_url = Some(v);
|
||||
}
|
||||
if let Some(v) = input.header_url {
|
||||
u.header_url = Some(v);
|
||||
}
|
||||
if let Some(v) = input.custom_css {
|
||||
u.custom_css = Some(v);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user