1
0
Fork 1
Spiegel von https://github.com/dani-garcia/vaultwarden.git synchronisiert 2024-11-05 02:28:00 +01:00

make attachments / ciphers support multi-domains

Dieser Commit ist enthalten in:
BlockListed 2023-09-09 13:53:19 +02:00
Ursprung f82a142cee
Commit b5dea32ea5
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 2D204777C477B588
2 geänderte Dateien mit 11 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -35,15 +35,17 @@ impl Attachment {
format!("{}/{}/{}", CONFIG.attachments_folder(), self.cipher_uuid, self.id)
}
pub fn get_url(&self, host: &str) -> String {
// TODO: Change back
pub fn get_url(&self, base_url: &str, _parameter_to_break_existing_uses: ()) -> String {
let token = encode_jwt(&generate_file_download_claims(self.cipher_uuid.clone(), self.id.clone()));
format!("{}/attachments/{}/{}?token={}", host, self.cipher_uuid, self.id, token)
format!("{}/attachments/{}/{}?token={}", base_url, self.cipher_uuid, self.id, token)
}
pub fn to_json(&self, host: &str) -> Value {
// TODO: Change back
pub fn to_json(&self, base_url: &str, _parameter_to_break_existing_uses: ()) -> Value {
json!({
"Id": self.id,
"Url": self.get_url(host),
"Url": self.get_url(base_url, ()),
"FileName": self.file_name,
"Size": self.file_size.to_string(),
"SizeName": crate::util::get_display_size(self.file_size),

Datei anzeigen

@ -113,25 +113,27 @@ use crate::error::MapResult;
/// Database methods
impl Cipher {
// TODO: Change back
pub async fn to_json(
&self,
host: &str,
base_url: &str,
user_uuid: &str,
cipher_sync_data: Option<&CipherSyncData>,
sync_type: CipherSyncType,
conn: &mut DbConn,
_parameter_to_break_existing_uses: (),
) -> Value {
use crate::util::format_date;
let mut attachments_json: Value = Value::Null;
if let Some(cipher_sync_data) = cipher_sync_data {
if let Some(attachments) = cipher_sync_data.cipher_attachments.get(&self.uuid) {
attachments_json = attachments.iter().map(|c| c.to_json(host)).collect();
attachments_json = attachments.iter().map(|c| c.to_json(base_url, ())).collect();
}
} else {
let attachments = Attachment::find_by_cipher(&self.uuid, conn).await;
if !attachments.is_empty() {
attachments_json = attachments.iter().map(|c| c.to_json(host)).collect()
attachments_json = attachments.iter().map(|c| c.to_json(base_url, ())).collect()
}
}