mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-09-12 16:53:57 +02:00
add functions to delete media from specific local users
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
a79ae7d1a2
commit
6b65a8fc86
2 changed files with 51 additions and 5 deletions
|
@ -6,7 +6,7 @@ use conduit::{
|
|||
Err, Error, Result,
|
||||
};
|
||||
use database::{Database, Map};
|
||||
use ruma::{api::client::error::ErrorKind, http_headers::ContentDisposition, Mxc, UserId};
|
||||
use ruma::{api::client::error::ErrorKind, http_headers::ContentDisposition, Mxc, OwnedMxcUri, UserId};
|
||||
|
||||
use super::preview::UrlPreviewData;
|
||||
|
||||
|
@ -176,6 +176,23 @@ impl Data {
|
|||
})
|
||||
}
|
||||
|
||||
/// Gets all the MXCs associated with a user
|
||||
pub(super) fn get_all_user_mxcs(&self, user_id: &UserId) -> Vec<OwnedMxcUri> {
|
||||
let user_id = user_id.as_bytes().to_vec();
|
||||
|
||||
self.mediaid_user
|
||||
.iter()
|
||||
.filter_map(|(key, user)| {
|
||||
if *user == user_id {
|
||||
let mxc_s = string_from_bytes(&key).ok()?;
|
||||
Some(OwnedMxcUri::from(mxc_s))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Gets all the media keys in our database (this includes all the metadata
|
||||
/// associated with it such as width, height, content-type, etc)
|
||||
pub(crate) fn get_all_media_keys(&self) -> Vec<Vec<u8>> { self.mediaid_file.iter().map(|(key, _)| key).collect() }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue