move read_receipt feature up one level out of rooms.edus.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-03-31 17:06:59 -07:00 committed by June
parent 22b123de7b
commit 89a919ce75
13 changed files with 11 additions and 16 deletions

View file

@ -59,7 +59,6 @@ pub async fn set_read_marker_route(body: Ruma<set_read_marker::v3::Request>) ->
};
services()
.rooms
.edus
.read_receipt
.private_read_set(&body.room_id, sender_user, count)?;
}
@ -80,7 +79,7 @@ pub async fn set_read_marker_route(body: Ruma<set_read_marker::v3::Request>) ->
let mut receipt_content = BTreeMap::new();
receipt_content.insert(event.to_owned(), receipts);
services().rooms.edus.read_receipt.readreceipt_update(
services().rooms.read_receipt.readreceipt_update(
sender_user,
&body.room_id,
ruma::events::receipt::ReceiptEvent {
@ -138,7 +137,7 @@ pub async fn create_receipt_route(body: Ruma<create_receipt::v3::Request>) -> Re
let mut receipt_content = BTreeMap::new();
receipt_content.insert(body.event_id.clone(), receipts);
services().rooms.edus.read_receipt.readreceipt_update(
services().rooms.read_receipt.readreceipt_update(
sender_user,
&body.room_id,
ruma::events::receipt::ReceiptEvent {
@ -164,7 +163,6 @@ pub async fn create_receipt_route(body: Ruma<create_receipt::v3::Request>) -> Re
};
services()
.rooms
.edus
.read_receipt
.private_read_set(&body.room_id, sender_user, count)?;
},

View file

@ -997,7 +997,6 @@ async fn load_joined_room(
let mut edus: Vec<_> = services()
.rooms
.edus
.read_receipt
.readreceipts_since(room_id, since)
.filter_map(Result::ok) // Filter out buggy events

View file

@ -386,7 +386,6 @@ pub async fn send_transaction_message_route(
};
services()
.rooms
.edus
.read_receipt
.readreceipt_update(&user_id, &room_id, event)?;
} else {

View file

@ -1,5 +1,4 @@
mod presence;
mod read_receipt;
use crate::{database::KeyValueDatabase, service};

View file

@ -6,6 +6,7 @@ mod lazy_load;
mod metadata;
mod outlier;
mod pdu_metadata;
mod read_receipt;
mod search;
mod short;
mod state;

View file

@ -4,7 +4,7 @@ use ruma::{events::receipt::ReceiptEvent, serde::Raw, CanonicalJsonObject, Owned
use crate::{database::KeyValueDatabase, service, services, utils, Error, Result};
impl service::rooms::edus::read_receipt::Data for KeyValueDatabase {
impl service::rooms::read_receipt::Data for KeyValueDatabase {
fn readreceipt_update(&self, user_id: &UserId, room_id: &RoomId, event: ReceiptEvent) -> Result<()> {
let mut prefix = room_id.as_bytes().to_vec();
prefix.push(0xFF);

View file

@ -73,9 +73,6 @@ impl Services<'_> {
presence: rooms::edus::presence::Service {
db,
},
read_receipt: rooms::edus::read_receipt::Service {
db,
},
typing: rooms::edus::typing::Service {
typing: RwLock::new(BTreeMap::new()),
last_typing_update: RwLock::new(BTreeMap::new()),
@ -96,6 +93,9 @@ impl Services<'_> {
pdu_metadata: rooms::pdu_metadata::Service {
db,
},
read_receipt: rooms::read_receipt::Service {
db,
},
search: rooms::search::Service {
db,
},

View file

@ -1,11 +1,9 @@
pub mod presence;
pub mod read_receipt;
pub mod typing;
pub trait Data: presence::Data + read_receipt::Data + 'static {}
pub trait Data: presence::Data + 'static {}
pub struct Service {
pub presence: presence::Service,
pub read_receipt: read_receipt::Service,
pub typing: typing::Service,
}

View file

@ -7,6 +7,7 @@ pub mod lazy_loading;
pub mod metadata;
pub mod outlier;
pub mod pdu_metadata;
pub mod read_receipt;
pub mod search;
pub mod short;
pub mod spaces;
@ -27,6 +28,7 @@ pub trait Data:
+ metadata::Data
+ outlier::Data
+ pdu_metadata::Data
+ read_receipt::Data
+ search::Data
+ short::Data
+ state::Data
@ -49,6 +51,7 @@ pub struct Service {
pub metadata: metadata::Service,
pub outlier: outlier::Service,
pub pdu_metadata: pdu_metadata::Service,
pub read_receipt: read_receipt::Service,
pub search: search::Service,
pub short: short::Service,
pub state: state::Service,

View file

@ -296,7 +296,6 @@ impl Service {
// appending fails
services()
.rooms
.edus
.read_receipt
.private_read_set(&pdu.room_id, &pdu.sender, count1)?;
services()

View file

@ -521,7 +521,6 @@ pub fn select_edus_receipts(
) -> Result<bool> {
for r in services()
.rooms
.edus
.read_receipt
.readreceipts_since(room_id, since)
{