Spiegel von
https://github.com/dani-garcia/vaultwarden.git
synchronisiert 2024-11-06 02:38:00 +01:00
make attachments / ciphers support multi-domains
Dieser Commit ist enthalten in:
Ursprung
f82a142cee
Commit
b5dea32ea5
2 geänderte Dateien mit 11 neuen und 7 gelöschten Zeilen
|
@ -35,15 +35,17 @@ impl Attachment {
|
||||||
format!("{}/{}/{}", CONFIG.attachments_folder(), self.cipher_uuid, self.id)
|
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()));
|
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!({
|
json!({
|
||||||
"Id": self.id,
|
"Id": self.id,
|
||||||
"Url": self.get_url(host),
|
"Url": self.get_url(base_url, ()),
|
||||||
"FileName": self.file_name,
|
"FileName": self.file_name,
|
||||||
"Size": self.file_size.to_string(),
|
"Size": self.file_size.to_string(),
|
||||||
"SizeName": crate::util::get_display_size(self.file_size),
|
"SizeName": crate::util::get_display_size(self.file_size),
|
||||||
|
|
|
@ -113,25 +113,27 @@ use crate::error::MapResult;
|
||||||
|
|
||||||
/// Database methods
|
/// Database methods
|
||||||
impl Cipher {
|
impl Cipher {
|
||||||
|
// TODO: Change back
|
||||||
pub async fn to_json(
|
pub async fn to_json(
|
||||||
&self,
|
&self,
|
||||||
host: &str,
|
base_url: &str,
|
||||||
user_uuid: &str,
|
user_uuid: &str,
|
||||||
cipher_sync_data: Option<&CipherSyncData>,
|
cipher_sync_data: Option<&CipherSyncData>,
|
||||||
sync_type: CipherSyncType,
|
sync_type: CipherSyncType,
|
||||||
conn: &mut DbConn,
|
conn: &mut DbConn,
|
||||||
|
_parameter_to_break_existing_uses: (),
|
||||||
) -> Value {
|
) -> Value {
|
||||||
use crate::util::format_date;
|
use crate::util::format_date;
|
||||||
|
|
||||||
let mut attachments_json: Value = Value::Null;
|
let mut attachments_json: Value = Value::Null;
|
||||||
if let Some(cipher_sync_data) = cipher_sync_data {
|
if let Some(cipher_sync_data) = cipher_sync_data {
|
||||||
if let Some(attachments) = cipher_sync_data.cipher_attachments.get(&self.uuid) {
|
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 {
|
} else {
|
||||||
let attachments = Attachment::find_by_cipher(&self.uuid, conn).await;
|
let attachments = Attachment::find_by_cipher(&self.uuid, conn).await;
|
||||||
if !attachments.is_empty() {
|
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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Laden …
In neuem Issue referenzieren