Implement Collection-Cipher mapping

This commit is contained in:
Miroslav Prasil
2018-05-09 11:55:05 +01:00
parent 032134aabc
commit 34f2aa68f4
8 changed files with 125 additions and 3 deletions

View File

@@ -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![])
}
}