mirror of
https://gitlab.com/famedly/conduit.git
synced 2025-10-15 19:42:07 +00:00
feat(media): save user id of uploader
This commit is contained in:
parent
19d0ea408c
commit
3171b779c6
5 changed files with 36 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
|||
use ruma::ServerName;
|
||||
use ruma::{ServerName, UserId};
|
||||
use sha2::{digest::Output, Sha256};
|
||||
|
||||
use crate::Result;
|
||||
|
@ -6,6 +6,7 @@ use crate::Result;
|
|||
use super::DbFileMeta;
|
||||
|
||||
pub trait Data: Send + Sync {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn create_file_metadata(
|
||||
&self,
|
||||
sha256_digest: Output<Sha256>,
|
||||
|
@ -14,6 +15,7 @@ pub trait Data: Send + Sync {
|
|||
media_id: &str,
|
||||
filename: Option<&str>,
|
||||
content_type: Option<&str>,
|
||||
user_id: Option<&UserId>,
|
||||
) -> Result<()>;
|
||||
|
||||
fn search_file_metadata(&self, servername: &ServerName, media_id: &str) -> Result<DbFileMeta>;
|
||||
|
|
|
@ -5,7 +5,7 @@ pub use data::Data;
|
|||
use ruma::{
|
||||
api::client::{error::ErrorKind, media::is_safe_inline_content_type},
|
||||
http_headers::{ContentDisposition, ContentDispositionType},
|
||||
ServerName,
|
||||
ServerName, UserId,
|
||||
};
|
||||
use sha2::{digest::Output, Digest, Sha256};
|
||||
|
||||
|
@ -43,6 +43,7 @@ impl Service {
|
|||
filename: Option<&str>,
|
||||
content_type: Option<&str>,
|
||||
file: &[u8],
|
||||
user_id: Option<&UserId>,
|
||||
) -> Result<()> {
|
||||
let (sha256_digest, sha256_hex) = generate_digests(file);
|
||||
|
||||
|
@ -53,6 +54,7 @@ impl Service {
|
|||
media_id,
|
||||
filename,
|
||||
content_type,
|
||||
user_id,
|
||||
)?;
|
||||
|
||||
create_file(&sha256_hex, file).await
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue