Skip to content
Snippets Groups Projects
Commit 08ca47ca authored by Miroslav Prasil's avatar Miroslav Prasil
Browse files

Update revision when adding or removing cipher from collection

parent 0bd3a260
No related branches found
No related tags found
No related merge requests found
......@@ -278,6 +278,7 @@ pub struct CollectionCipher {
/// Database methods
impl CollectionCipher {
pub fn save(cipher_uuid: &str, collection_uuid: &str, conn: &DbConn) -> EmptyResult {
Self::update_users_revision(&collection_uuid, conn);
diesel::replace_into(ciphers_collections::table)
.values((
ciphers_collections::cipher_uuid.eq(cipher_uuid),
......@@ -288,6 +289,7 @@ impl CollectionCipher {
}
pub fn delete(cipher_uuid: &str, collection_uuid: &str, conn: &DbConn) -> EmptyResult {
Self::update_users_revision(&collection_uuid, conn);
diesel::delete(
ciphers_collections::table
.filter(ciphers_collections::cipher_uuid.eq(cipher_uuid))
......@@ -308,4 +310,10 @@ impl CollectionCipher {
.execute(&**conn)
.map_res("Error removing ciphers from collection")
}
pub fn update_users_revision(collection_uuid: &str, conn: &DbConn) {
if let Some(collection) = Collection::find_by_uuid(collection_uuid, conn) {
collection.update_users_revision(conn);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment