Revert "feat: Distinguish between ignore and block internally"

This reverts commit 028a5194fbc4e9380e11dfc4b49186ed11603fba.
This commit is contained in:
Ginger committed 2025-09-11 16:21:03 +00:00
1 parent dacdeef4a2
commit 0743e18a45
10 files changed
+35 -98

No files matched your search

+1 -7
View File
@@ -122,13 +122,7 @@ pub async fn update_membership(
},
| MembershipState::Invite => {
// We want to know if the sender is ignored by the receiver
if !self
.services
.users
.user_filter_level(sender, user_id)
.await
.allowed()
{
if self.services.users.user_is_ignored(sender, user_id).await {
return Ok(());
}
+2 -2
View File
@@ -193,9 +193,9 @@ where
.state_cache
.active_local_users_in_room(pdu.room_id())
.map(ToOwned::to_owned)
// Don't notify the sender of their own events, and don't send from ignored users
// Don't notify the sender of their own events, and dont send from ignored users
.ready_filter(|user| *user != pdu.sender())
.filter_map(|recipient_user| async move { (self.services.users.user_filter_level(pdu.sender(), &recipient_user).await.allowed()).then_some(recipient_user) })
.filter_map(|recipient_user| async move { (!self.services.users.user_is_ignored(pdu.sender(), &recipient_user).await).then_some(recipient_user) })
.collect()
.await;
+5 -9
View File
@@ -12,11 +12,7 @@ use ruma::{
};
use tokio::sync::{RwLock, broadcast};
use crate::{
Dep, globals,
sending::{self, EduBuf},
users::{self},
};
use crate::{Dep, globals, sending, sending::EduBuf, users};
pub struct Service {
server: Arc<Server>,
@@ -201,11 +197,11 @@ impl Service {
.into_keys()
.stream()
.filter_map(|typing_user_id| async move {
self.services
(!self
.services
.users
.user_filter_level(&typing_user_id, sender_user)
.await
.allowed()
.user_is_ignored(&typing_user_id, sender_user)
.await)
.then_some(typing_user_id)
})
.collect()
+6 -34
View File
@@ -39,22 +39,6 @@ pub struct UserSuspension {
pub suspended_by: String,
}
/// Represents a user's level of filtering on actions from another user.
/// "Ignore" and "block" are defined in [MSC4283].
/// This may be moved into Ruwuma in the future.
///
/// MSC4283: https://github.com/matrix-org/matrix-spec-proposals/pull/4283
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum UserFilterLevel {
Allow,
Ignore,
Block,
}
impl UserFilterLevel {
pub fn allowed(&self) -> bool { return *self == UserFilterLevel::Allow; }
}
pub struct Service {
services: Services,
db: Data,
@@ -139,32 +123,20 @@ impl crate::Service for Service {
}
impl Service {
/// Returns a UserActionResult based on whether the recipient/receiving user
/// has ignored or blocked the sender
pub async fn user_filter_level(
&self,
sender_user: &UserId,
recipient_user: &UserId,
) -> UserFilterLevel {
// can only return Allow or Ignore for now
/// Returns true/false based on whether the recipient/receiving user has
/// blocked the sender
pub async fn user_is_ignored(&self, sender_user: &UserId, recipient_user: &UserId) -> bool {
self.services
.account_data
.get_global(recipient_user, GlobalAccountDataEventType::IgnoredUserList)
.await
.map(|ignored: IgnoredUserListEvent| {
let sender_ignored_recipient = ignored
.is_ok_and(|ignored: IgnoredUserListEvent| {
ignored
.content
.ignored_users
.keys()
.any(|blocked_user| blocked_user == sender_user);
if sender_ignored_recipient {
UserFilterLevel::Ignore
} else {
UserFilterLevel::Allow
}
.any(|blocked_user| blocked_user == sender_user)
})
.unwrap_or(UserFilterLevel::Allow)
}
/// Check if a user is an admin