mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-09-10 10:45:57 +03:00
Implement Collection-Cipher mapping
This commit is contained in:
@@ -98,7 +98,7 @@ impl Cipher {
|
||||
"OrganizationId": self.organization_uuid,
|
||||
"Attachments": attachments_json,
|
||||
"OrganizationUseTotp": false,
|
||||
"CollectionIds": [],
|
||||
"CollectionIds": self.get_collections(&conn),
|
||||
|
||||
"Name": self.name,
|
||||
"Notes": self.notes,
|
||||
@@ -241,4 +241,11 @@ impl Cipher {
|
||||
.select(ciphers::all_columns)
|
||||
.load::<Self>(&**conn).expect("Error loading ciphers")
|
||||
}
|
||||
|
||||
pub fn get_collections(&self, conn: &DbConn) -> Vec<String> {
|
||||
ciphers_collections::table
|
||||
.filter(ciphers_collections::cipher_uuid.eq(&self.uuid))
|
||||
.select(ciphers_collections::collection_uuid)
|
||||
.load::<String>(&**conn).unwrap_or(vec![])
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user