simplify acl brick-check conditions
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -211,7 +211,7 @@ async fn allowed_to_send_state_event(
|
|||||||
// irreversible mistakes
|
// irreversible mistakes
|
||||||
match json.deserialize_as::<RoomServerAclEventContent>() {
|
match json.deserialize_as::<RoomServerAclEventContent>() {
|
||||||
| Ok(acl_content) => {
|
| Ok(acl_content) => {
|
||||||
if acl_content.allow.is_empty() {
|
if acl_content.allow_is_empty() {
|
||||||
return Err!(Request(BadJson(debug_warn!(
|
return Err!(Request(BadJson(debug_warn!(
|
||||||
?room_id,
|
?room_id,
|
||||||
"Sending an ACL event with an empty allow key will permanently \
|
"Sending an ACL event with an empty allow key will permanently \
|
||||||
@@ -220,9 +220,7 @@ async fn allowed_to_send_state_event(
|
|||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
|
|
||||||
if acl_content.deny.contains(&String::from("*"))
|
if acl_content.deny_contains("*") && acl_content.allow_contains("*") {
|
||||||
&& acl_content.allow.contains(&String::from("*"))
|
|
||||||
{
|
|
||||||
return Err!(Request(BadJson(debug_warn!(
|
return Err!(Request(BadJson(debug_warn!(
|
||||||
?room_id,
|
?room_id,
|
||||||
"Sending an ACL event with a deny and allow key value of \"*\" will \
|
"Sending an ACL event with a deny and allow key value of \"*\" will \
|
||||||
@@ -231,11 +229,9 @@ async fn allowed_to_send_state_event(
|
|||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
|
|
||||||
if acl_content.deny.contains(&String::from("*"))
|
if acl_content.deny_contains("*")
|
||||||
&& !acl_content.is_allowed(services.globals.server_name())
|
&& !acl_content.is_allowed(services.globals.server_name())
|
||||||
&& !acl_content
|
&& !acl_content.allow_contains(services.globals.server_name().as_str())
|
||||||
.allow
|
|
||||||
.contains(&services.globals.server_name().to_string())
|
|
||||||
{
|
{
|
||||||
return Err!(Request(BadJson(debug_warn!(
|
return Err!(Request(BadJson(debug_warn!(
|
||||||
?room_id,
|
?room_id,
|
||||||
@@ -245,11 +241,9 @@ async fn allowed_to_send_state_event(
|
|||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
|
|
||||||
if !acl_content.allow.contains(&String::from("*"))
|
if !acl_content.allow_contains("*")
|
||||||
&& !acl_content.is_allowed(services.globals.server_name())
|
&& !acl_content.is_allowed(services.globals.server_name())
|
||||||
&& !acl_content
|
&& !acl_content.allow_contains(services.globals.server_name().as_str())
|
||||||
.allow
|
|
||||||
.contains(&services.globals.server_name().to_string())
|
|
||||||
{
|
{
|
||||||
return Err!(Request(BadJson(debug_warn!(
|
return Err!(Request(BadJson(debug_warn!(
|
||||||
?room_id,
|
?room_id,
|
||||||
|
|||||||
Reference in New Issue
Block a user