mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
feat: Return SENDER_IGNORED error for context and relations
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Event, Result, at, debug_warn, err, ref_at,
|
Err, Error, Event, Result, at, debug_warn, err, ref_at,
|
||||||
utils::{
|
utils::{
|
||||||
IterStream,
|
IterStream,
|
||||||
future::TryExtExt,
|
future::TryExtExt,
|
||||||
@@ -12,11 +12,18 @@ use futures::{
|
|||||||
FutureExt, StreamExt, TryFutureExt, TryStreamExt,
|
FutureExt, StreamExt, TryFutureExt, TryStreamExt,
|
||||||
future::{OptionFuture, join, join3, try_join3},
|
future::{OptionFuture, join, join3, try_join3},
|
||||||
};
|
};
|
||||||
use ruma::{OwnedEventId, UserId, api::client::context::get_context, events::StateEventType};
|
use ruma::{
|
||||||
|
OwnedEventId, UserId,
|
||||||
|
api::client::{context::get_context, error::ErrorKind},
|
||||||
|
events::StateEventType,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Ruma,
|
Ruma,
|
||||||
client::message::{event_filter, ignored_filter, lazy_loading_witness, visibility_filter},
|
client::{
|
||||||
|
is_ignored_pdu,
|
||||||
|
message::{event_filter, ignored_filter, lazy_loading_witness, visibility_filter},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const LIMIT_MAX: usize = 100;
|
const LIMIT_MAX: usize = 100;
|
||||||
@@ -78,6 +85,9 @@ pub(crate) async fn get_context_route(
|
|||||||
return Err!(Request(NotFound("Event not found.")));
|
return Err!(Request(NotFound("Event not found.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return M_SENDER_IGNORED if the sender of base_event is ignored (MSC4406)
|
||||||
|
is_ignored_pdu(&services, &base_pdu, sender_user).await?;
|
||||||
|
|
||||||
let base_count = base_id.pdu_count();
|
let base_count = base_id.pdu_count();
|
||||||
|
|
||||||
let base_event = ignored_filter(&services, (base_count, base_pdu), sender_user);
|
let base_event = ignored_filter(&services, (base_count, base_pdu), sender_user);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Result, at, debug_warn,
|
Err, Result, at, debug_warn, err,
|
||||||
matrix::{Event, event::RelationTypeEqual, pdu::PduCount},
|
matrix::{Event, event::RelationTypeEqual, pdu::PduCount},
|
||||||
utils::{IterStream, ReadyExt, result::FlatOk, stream::WidebandExt},
|
utils::{IterStream, ReadyExt, result::FlatOk, stream::WidebandExt},
|
||||||
};
|
};
|
||||||
@@ -18,7 +18,7 @@ use ruma::{
|
|||||||
events::{TimelineEventType, relation::RelationType},
|
events::{TimelineEventType, relation::RelationType},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::{Ruma, client::is_ignored_pdu};
|
||||||
|
|
||||||
/// # `GET /_matrix/client/r0/rooms/{roomId}/relations/{eventId}/{relType}/{eventType}`
|
/// # `GET /_matrix/client/r0/rooms/{roomId}/relations/{eventId}/{relType}/{eventType}`
|
||||||
pub(crate) async fn get_relating_events_with_rel_type_and_event_type_route(
|
pub(crate) async fn get_relating_events_with_rel_type_and_event_type_route(
|
||||||
@@ -118,6 +118,14 @@ async fn paginate_relations_with_filter(
|
|||||||
debug_warn!(req_evt = %target, %room_id, "Event relations requested by {sender_user} but is not allowed to see it, returning 404");
|
debug_warn!(req_evt = %target, %room_id, "Event relations requested by {sender_user} but is not allowed to see it, returning 404");
|
||||||
return Err!(Request(NotFound("Event not found.")));
|
return Err!(Request(NotFound("Event not found.")));
|
||||||
}
|
}
|
||||||
|
let target_pdu = services
|
||||||
|
.rooms
|
||||||
|
.timeline
|
||||||
|
.get_pdu(target)
|
||||||
|
.await
|
||||||
|
.map_err(|_| err!(Request(NotFound("Event not found."))))?;
|
||||||
|
// Return M_SENDER_IGNORED if the sender of base_event is ignored (MSC4406)
|
||||||
|
is_ignored_pdu(services, &target_pdu, sender_user).await?;
|
||||||
|
|
||||||
let start: PduCount = from
|
let start: PduCount = from
|
||||||
.map(str::parse)
|
.map(str::parse)
|
||||||
|
|||||||
Reference in New Issue
Block a user