@ -799,12 +799,16 @@ async fn post_collections_update(
err ! ( "Collection cannot be changed" )
err ! ( "Collection cannot be changed" )
}
}
let Some ( ref org_uuid ) = cipher . organization_uuid else {
err ! ( "Cipher is not owned by an organization" )
} ;
let posted_collections = HashSet ::< CollectionId > ::from_iter ( data . collection_ids ) ;
let posted_collections = HashSet ::< CollectionId > ::from_iter ( data . collection_ids ) ;
let current_collections =
let current_collections =
HashSet ::< CollectionId > ::from_iter ( cipher . get_collections ( headers . user . uuid . clone ( ) , & conn ) . await ) ;
HashSet ::< CollectionId > ::from_iter ( cipher . get_collections ( headers . user . uuid . clone ( ) , & conn ) . await ) ;
for collection in posted_collections . symmetric_difference ( & current_collections ) {
for collection in posted_collections . symmetric_difference ( & current_collections ) {
match Collection ::find_by_uuid_and_org ( collection , cipher . organization _uuid . as_ref ( ) . unwrap ( ) , & conn ) . await {
match Collection ::find_by_uuid_and_org ( collection , org_uuid , & conn ) . await {
None = > err ! ( "Invalid collection ID provided" ) ,
None = > err ! ( "Invalid collection ID provided" ) ,
Some ( collection ) = > {
Some ( collection ) = > {
if collection . is_writable_by_user ( & headers . user . uuid , & conn ) . await {
if collection . is_writable_by_user ( & headers . user . uuid , & conn ) . await {
@ -835,7 +839,7 @@ async fn post_collections_update(
log_event (
log_event (
EventType ::CipherUpdatedCollections as i32 ,
EventType ::CipherUpdatedCollections as i32 ,
& cipher . uuid ,
& cipher . uuid ,
& cipher . organization _uuid . clone ( ) . unwrap ( ) ,
org_uuid ,
& headers . user . uuid ,
& headers . user . uuid ,
headers . device . atype ,
headers . device . atype ,
& headers . ip . ip ,
& headers . ip . ip ,
@ -875,12 +879,16 @@ async fn post_collections_admin(
err ! ( "Collection cannot be changed" )
err ! ( "Collection cannot be changed" )
}
}
let Some ( ref org_uuid ) = cipher . organization_uuid else {
err ! ( "Cipher is not owned by an organization" )
} ;
let posted_collections = HashSet ::< CollectionId > ::from_iter ( data . collection_ids ) ;
let posted_collections = HashSet ::< CollectionId > ::from_iter ( data . collection_ids ) ;
let current_collections =
let current_collections =
HashSet ::< CollectionId > ::from_iter ( cipher . get_admin_collections ( headers . user . uuid . clone ( ) , & conn ) . await ) ;
HashSet ::< CollectionId > ::from_iter ( cipher . get_admin_collections ( headers . user . uuid . clone ( ) , & conn ) . await ) ;
for collection in posted_collections . symmetric_difference ( & current_collections ) {
for collection in posted_collections . symmetric_difference ( & current_collections ) {
match Collection ::find_by_uuid_and_org ( collection , cipher . organization _uuid . as_ref ( ) . unwrap ( ) , & conn ) . await {
match Collection ::find_by_uuid_and_org ( collection , org_uuid , & conn ) . await {
None = > err ! ( "Invalid collection ID provided" ) ,
None = > err ! ( "Invalid collection ID provided" ) ,
Some ( collection ) = > {
Some ( collection ) = > {
if collection . is_writable_by_user ( & headers . user . uuid , & conn ) . await {
if collection . is_writable_by_user ( & headers . user . uuid , & conn ) . await {
@ -911,7 +919,7 @@ async fn post_collections_admin(
log_event (
log_event (
EventType ::CipherUpdatedCollections as i32 ,
EventType ::CipherUpdatedCollections as i32 ,
& cipher . uuid ,
& cipher . uuid ,
& cipher . organization _uuid . unwrap ( ) ,
org_uuid ,
& headers . user . uuid ,
& headers . user . uuid ,
headers . device . atype ,
headers . device . atype ,
& headers . ip . ip ,
& headers . ip . ip ,