mirror of
https://github.com/dani-garcia/vaultwarden
synced 2024-11-26 13:50:21 +00:00
Merge pull request #387 from mprasil/collections_edit_revision
Update revision when adding or removing cipher from collection
This commit is contained in:
commit
7ce06b3808
1 changed files with 8 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue