mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-07-05 12:15:10 +02:00
Support optional device_id's in lazy-loading context.
Co-authored-by: Jade Ellis <jade@ellis.link> Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
49f7a2487f
commit
2051c22a28
4 changed files with 17 additions and 19 deletions
|
@ -111,7 +111,7 @@ pub(crate) async fn get_context_route(
|
||||||
|
|
||||||
let lazy_loading_context = lazy_loading::Context {
|
let lazy_loading_context = lazy_loading::Context {
|
||||||
user_id: sender_user,
|
user_id: sender_user,
|
||||||
device_id: sender_device,
|
device_id: Some(sender_device),
|
||||||
room_id,
|
room_id,
|
||||||
token: Some(base_count.into_unsigned()),
|
token: Some(base_count.into_unsigned()),
|
||||||
options: Some(&filter.lazy_load_options),
|
options: Some(&filter.lazy_load_options),
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
use core::panic;
|
|
||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Result, at,
|
Err, Result, at,
|
||||||
|
@ -34,6 +32,7 @@ use ruma::{
|
||||||
},
|
},
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
};
|
};
|
||||||
|
use tracing::warn;
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::Ruma;
|
||||||
|
|
||||||
|
@ -73,7 +72,7 @@ pub(crate) async fn get_message_events_route(
|
||||||
) -> Result<get_message_events::v3::Response> {
|
) -> Result<get_message_events::v3::Response> {
|
||||||
debug_assert!(IGNORED_MESSAGE_TYPES.is_sorted(), "IGNORED_MESSAGE_TYPES is not sorted");
|
debug_assert!(IGNORED_MESSAGE_TYPES.is_sorted(), "IGNORED_MESSAGE_TYPES is not sorted");
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.sender_user();
|
||||||
let sender_device = body.sender_device.as_ref();
|
let sender_device = body.sender_device.as_deref();
|
||||||
let room_id = &body.room_id;
|
let room_id = &body.room_id;
|
||||||
let filter = &body.filter;
|
let filter = &body.filter;
|
||||||
|
|
||||||
|
@ -137,18 +136,17 @@ pub(crate) async fn get_message_events_route(
|
||||||
|
|
||||||
let lazy_loading_context = lazy_loading::Context {
|
let lazy_loading_context = lazy_loading::Context {
|
||||||
user_id: sender_user,
|
user_id: sender_user,
|
||||||
device_id: match sender_device {
|
device_id: sender_device.or_else(|| {
|
||||||
| Some(device_id) => device_id,
|
if let Some(registration) = body.appservice_info.as_ref() {
|
||||||
| None =>
|
Some(<&DeviceId>::from(registration.registration.id.as_str()))
|
||||||
if let Some(registration) = body.appservice_info.as_ref() {
|
} else {
|
||||||
<&DeviceId>::from(registration.registration.id.as_str())
|
warn!(
|
||||||
} else {
|
"No device_id provided and no appservice registration found, this should be \
|
||||||
panic!(
|
unreachable"
|
||||||
"No device_id provided and no appservice registration found, this \
|
);
|
||||||
should be unreachable"
|
None
|
||||||
);
|
}
|
||||||
},
|
}),
|
||||||
},
|
|
||||||
room_id,
|
room_id,
|
||||||
token: Some(from.into_unsigned()),
|
token: Some(from.into_unsigned()),
|
||||||
options: Some(&filter.lazy_load_options),
|
options: Some(&filter.lazy_load_options),
|
||||||
|
|
|
@ -645,7 +645,7 @@ async fn load_joined_room(
|
||||||
|
|
||||||
let lazy_loading_context = &lazy_loading::Context {
|
let lazy_loading_context = &lazy_loading::Context {
|
||||||
user_id: sender_user,
|
user_id: sender_user,
|
||||||
device_id: sender_device,
|
device_id: Some(sender_device),
|
||||||
room_id,
|
room_id,
|
||||||
token: Some(since),
|
token: Some(since),
|
||||||
options: Some(&filter.room.state.lazy_load_options),
|
options: Some(&filter.room.state.lazy_load_options),
|
||||||
|
|
|
@ -27,7 +27,7 @@ pub trait Options: Send + Sync {
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Context<'a> {
|
pub struct Context<'a> {
|
||||||
pub user_id: &'a UserId,
|
pub user_id: &'a UserId,
|
||||||
pub device_id: &'a DeviceId,
|
pub device_id: Option<&'a DeviceId>,
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: &'a RoomId,
|
||||||
pub token: Option<u64>,
|
pub token: Option<u64>,
|
||||||
pub options: Option<&'a LazyLoadOptions>,
|
pub options: Option<&'a LazyLoadOptions>,
|
||||||
|
@ -40,7 +40,7 @@ pub enum Status {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type Witness = HashSet<OwnedUserId>;
|
pub type Witness = HashSet<OwnedUserId>;
|
||||||
type Key<'a> = (&'a UserId, &'a DeviceId, &'a RoomId, &'a UserId);
|
type Key<'a> = (&'a UserId, Option<&'a DeviceId>, &'a RoomId, &'a UserId);
|
||||||
|
|
||||||
impl crate::Service for Service {
|
impl crate::Service for Service {
|
||||||
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
|
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
|
||||||
|
|
Loading…
Add table
Reference in a new issue