Refactor permission handling in get_message_with_permission function

- Updated the logic to determine final_permission by checking if permission is Some, simplifying the condition.
- Improved error handling for non-public threads when no permissions are provided.
This commit is contained in:
dal 2025-01-06 15:21:37 -07:00
parent c77018abbd
commit a7ae1b1dfd
1 changed files with 3 additions and 1 deletions

View File

@ -84,7 +84,9 @@ pub async fn get_message_with_permission(
}
};
let final_permission = if permission.is_none() && !is_public_thread {
let final_permission = if permission.is_some() {
permission.unwrap()
} else if !is_public_thread {
return Err(anyhow!("No message found with permissions"));
} else {
AssetPermissionRole::Viewer