mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-06-12 05:50:06 +00:00
Added read_only bit to users_collections
This commit is contained in:
parent
0cb58add54
commit
79b4ddcae8
5 changed files with 24 additions and 22 deletions
|
@ -106,15 +106,17 @@ use super::User;
|
|||
pub struct CollectionUsers {
|
||||
pub user_uuid: String,
|
||||
pub collection_uuid: String,
|
||||
pub read_only: bool,
|
||||
}
|
||||
|
||||
/// Database methods
|
||||
impl CollectionUsers {
|
||||
pub fn save(user_uuid: &str, collection_uuid: &str, conn: &DbConn) -> bool {
|
||||
pub fn save(user_uuid: &str, collection_uuid: &str, read_only:bool, conn: &DbConn) -> bool {
|
||||
match diesel::replace_into(users_collections::table)
|
||||
.values((
|
||||
users_collections::user_uuid.eq(user_uuid),
|
||||
users_collections::collection_uuid.eq(collection_uuid)
|
||||
users_collections::collection_uuid.eq(collection_uuid),
|
||||
users_collections::read_only.eq(read_only),
|
||||
)).execute(&**conn) {
|
||||
Ok(1) => true, // One row inserted
|
||||
_ => false,
|
||||
|
|
|
@ -56,6 +56,13 @@ table! {
|
|||
}
|
||||
}
|
||||
|
||||
table! {
|
||||
folders_ciphers (cipher_uuid, folder_uuid) {
|
||||
cipher_uuid -> Text,
|
||||
folder_uuid -> Text,
|
||||
}
|
||||
}
|
||||
|
||||
table! {
|
||||
organizations (uuid) {
|
||||
uuid -> Text,
|
||||
|
@ -90,6 +97,7 @@ table! {
|
|||
users_collections (user_uuid, collection_uuid) {
|
||||
user_uuid -> Text,
|
||||
collection_uuid -> Text,
|
||||
read_only -> Bool,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,24 +114,18 @@ table! {
|
|||
}
|
||||
}
|
||||
|
||||
table! {
|
||||
folders_ciphers (cipher_uuid, folder_uuid) {
|
||||
cipher_uuid -> Text,
|
||||
folder_uuid -> Text,
|
||||
}
|
||||
}
|
||||
|
||||
joinable!(attachments -> ciphers (cipher_uuid));
|
||||
joinable!(ciphers -> organizations (organization_uuid));
|
||||
joinable!(ciphers -> users (user_uuid));
|
||||
joinable!(collections -> organizations (org_uuid));
|
||||
joinable!(devices -> users (user_uuid));
|
||||
joinable!(folders -> users (user_uuid));
|
||||
joinable!(folders_ciphers -> ciphers (cipher_uuid));
|
||||
joinable!(folders_ciphers -> folders (folder_uuid));
|
||||
joinable!(users_collections -> collections (collection_uuid));
|
||||
joinable!(users_collections -> users (user_uuid));
|
||||
joinable!(users_organizations -> organizations (org_uuid));
|
||||
joinable!(users_organizations -> users (user_uuid));
|
||||
joinable!(folders_ciphers -> ciphers (cipher_uuid));
|
||||
joinable!(folders_ciphers -> folders (folder_uuid));
|
||||
|
||||
allow_tables_to_appear_in_same_query!(
|
||||
attachments,
|
||||
|
@ -131,9 +133,9 @@ allow_tables_to_appear_in_same_query!(
|
|||
collections,
|
||||
devices,
|
||||
folders,
|
||||
folders_ciphers,
|
||||
organizations,
|
||||
users,
|
||||
users_collections,
|
||||
users_organizations,
|
||||
folders_ciphers,
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue