diff options
author | Miroslav Prasil <[email protected]> | 2018-08-21 12:20:55 +0100 |
---|---|---|
committer | Miroslav Prasil <[email protected]> | 2018-08-21 12:20:55 +0100 |
commit | a5ef8aef0f7e6051578fc8138ec7dc627808aa40 (patch) | |
tree | 6f08398ad57ccacb25790c08caec6f47a38814bb /src/db/models/collection.rs | |
parent | 6fdeeb56ce2361aac89aca7a69d9c9177b764254 (diff) | |
download | vaultwarden-a5ef8aef0f7e6051578fc8138ec7dc627808aa40.tar.gz vaultwarden-a5ef8aef0f7e6051578fc8138ec7dc627808aa40.zip |
Update affected users revision when there are collection changes
Diffstat (limited to 'src/db/models/collection.rs')
-rw-r--r-- | src/db/models/collection.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/db/models/collection.rs b/src/db/models/collection.rs index fa16ec28..2bf116c5 100644 --- a/src/db/models/collection.rs +++ b/src/db/models/collection.rs @@ -185,6 +185,8 @@ impl CollectionUser { } pub fn save(user_uuid: &str, collection_uuid: &str, read_only:bool, conn: &DbConn) -> QueryResult<()> { + User::update_uuid_revision(&user_uuid, conn); + diesel::replace_into(users_collections::table) .values(( users_collections::user_uuid.eq(user_uuid), @@ -194,6 +196,8 @@ impl CollectionUser { } pub fn delete(self, conn: &DbConn) -> QueryResult<()> { + User::update_uuid_revision(&self.user_uuid, conn); + diesel::delete(users_collections::table .filter(users_collections::user_uuid.eq(&self.user_uuid)) .filter(users_collections::collection_uuid.eq(&self.collection_uuid))) @@ -216,12 +220,20 @@ impl CollectionUser { } pub fn delete_all_by_collection(collection_uuid: &str, conn: &DbConn) -> QueryResult<()> { + CollectionUser::find_by_collection(&collection_uuid, conn) + .iter() + .for_each(|collection| { + User::update_uuid_revision(&collection.user_uuid, conn) + }); + diesel::delete(users_collections::table .filter(users_collections::collection_uuid.eq(collection_uuid)) ).execute(&**conn).and(Ok(())) } pub fn delete_all_by_user(user_uuid: &str, conn: &DbConn) -> QueryResult<()> { + User::update_uuid_revision(&user_uuid, conn); + diesel::delete(users_collections::table .filter(users_collections::user_uuid.eq(user_uuid)) ).execute(&**conn).and(Ok(())) |