move and deduplicate read receipt flusher.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-03-29 00:27:10 -07:00 committed by June
parent 6fa2e0814c
commit f956e8c3b5
2 changed files with 5 additions and 6 deletions

View file

@ -88,8 +88,6 @@ pub async fn set_read_marker_route(body: Ruma<set_read_marker::v3::Request>) ->
room_id: body.room_id.clone(),
},
)?;
services().sending.flush_room(&body.room_id)?;
}
Ok(set_read_marker::v3::Response {})
@ -148,8 +146,6 @@ pub async fn create_receipt_route(body: Ruma<create_receipt::v3::Request>) -> Re
room_id: body.room_id.clone(),
},
)?;
services().sending.flush_room(&body.room_id)?;
},
create_receipt::v3::ReceiptType::ReadPrivate => {
let count = services()

View file

@ -3,7 +3,7 @@ mod data;
pub use data::Data;
use ruma::{events::receipt::ReceiptEvent, serde::Raw, OwnedUserId, RoomId, UserId};
use crate::Result;
use crate::{services, Result};
pub struct Service {
pub db: &'static dyn Data,
@ -12,7 +12,10 @@ pub struct Service {
impl Service {
/// Replaces the previous read receipt.
pub fn readreceipt_update(&self, user_id: &UserId, room_id: &RoomId, event: ReceiptEvent) -> Result<()> {
self.db.readreceipt_update(user_id, room_id, event)
self.db.readreceipt_update(user_id, room_id, event)?;
services().sending.flush_room(room_id)?;
Ok(())
}
/// Returns an iterator over the most recent read_receipts in a room that