move read_receipt feature up one level out of rooms.edus.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
22b123de7b
commit
89a919ce75
13 changed files with 11 additions and 16 deletions
|
@ -59,7 +59,6 @@ pub async fn set_read_marker_route(body: Ruma<set_read_marker::v3::Request>) ->
|
||||||
};
|
};
|
||||||
services()
|
services()
|
||||||
.rooms
|
.rooms
|
||||||
.edus
|
|
||||||
.read_receipt
|
.read_receipt
|
||||||
.private_read_set(&body.room_id, sender_user, count)?;
|
.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();
|
let mut receipt_content = BTreeMap::new();
|
||||||
receipt_content.insert(event.to_owned(), receipts);
|
receipt_content.insert(event.to_owned(), receipts);
|
||||||
|
|
||||||
services().rooms.edus.read_receipt.readreceipt_update(
|
services().rooms.read_receipt.readreceipt_update(
|
||||||
sender_user,
|
sender_user,
|
||||||
&body.room_id,
|
&body.room_id,
|
||||||
ruma::events::receipt::ReceiptEvent {
|
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();
|
let mut receipt_content = BTreeMap::new();
|
||||||
receipt_content.insert(body.event_id.clone(), receipts);
|
receipt_content.insert(body.event_id.clone(), receipts);
|
||||||
|
|
||||||
services().rooms.edus.read_receipt.readreceipt_update(
|
services().rooms.read_receipt.readreceipt_update(
|
||||||
sender_user,
|
sender_user,
|
||||||
&body.room_id,
|
&body.room_id,
|
||||||
ruma::events::receipt::ReceiptEvent {
|
ruma::events::receipt::ReceiptEvent {
|
||||||
|
@ -164,7 +163,6 @@ pub async fn create_receipt_route(body: Ruma<create_receipt::v3::Request>) -> Re
|
||||||
};
|
};
|
||||||
services()
|
services()
|
||||||
.rooms
|
.rooms
|
||||||
.edus
|
|
||||||
.read_receipt
|
.read_receipt
|
||||||
.private_read_set(&body.room_id, sender_user, count)?;
|
.private_read_set(&body.room_id, sender_user, count)?;
|
||||||
},
|
},
|
||||||
|
|
|
@ -997,7 +997,6 @@ async fn load_joined_room(
|
||||||
|
|
||||||
let mut edus: Vec<_> = services()
|
let mut edus: Vec<_> = services()
|
||||||
.rooms
|
.rooms
|
||||||
.edus
|
|
||||||
.read_receipt
|
.read_receipt
|
||||||
.readreceipts_since(room_id, since)
|
.readreceipts_since(room_id, since)
|
||||||
.filter_map(Result::ok) // Filter out buggy events
|
.filter_map(Result::ok) // Filter out buggy events
|
||||||
|
|
|
@ -386,7 +386,6 @@ pub async fn send_transaction_message_route(
|
||||||
};
|
};
|
||||||
services()
|
services()
|
||||||
.rooms
|
.rooms
|
||||||
.edus
|
|
||||||
.read_receipt
|
.read_receipt
|
||||||
.readreceipt_update(&user_id, &room_id, event)?;
|
.readreceipt_update(&user_id, &room_id, event)?;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
mod presence;
|
mod presence;
|
||||||
mod read_receipt;
|
|
||||||
|
|
||||||
use crate::{database::KeyValueDatabase, service};
|
use crate::{database::KeyValueDatabase, service};
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ mod lazy_load;
|
||||||
mod metadata;
|
mod metadata;
|
||||||
mod outlier;
|
mod outlier;
|
||||||
mod pdu_metadata;
|
mod pdu_metadata;
|
||||||
|
mod read_receipt;
|
||||||
mod search;
|
mod search;
|
||||||
mod short;
|
mod short;
|
||||||
mod state;
|
mod state;
|
||||||
|
|
|
@ -4,7 +4,7 @@ use ruma::{events::receipt::ReceiptEvent, serde::Raw, CanonicalJsonObject, Owned
|
||||||
|
|
||||||
use crate::{database::KeyValueDatabase, service, services, utils, Error, Result};
|
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<()> {
|
fn readreceipt_update(&self, user_id: &UserId, room_id: &RoomId, event: ReceiptEvent) -> Result<()> {
|
||||||
let mut prefix = room_id.as_bytes().to_vec();
|
let mut prefix = room_id.as_bytes().to_vec();
|
||||||
prefix.push(0xFF);
|
prefix.push(0xFF);
|
|
@ -73,9 +73,6 @@ impl Services<'_> {
|
||||||
presence: rooms::edus::presence::Service {
|
presence: rooms::edus::presence::Service {
|
||||||
db,
|
db,
|
||||||
},
|
},
|
||||||
read_receipt: rooms::edus::read_receipt::Service {
|
|
||||||
db,
|
|
||||||
},
|
|
||||||
typing: rooms::edus::typing::Service {
|
typing: rooms::edus::typing::Service {
|
||||||
typing: RwLock::new(BTreeMap::new()),
|
typing: RwLock::new(BTreeMap::new()),
|
||||||
last_typing_update: RwLock::new(BTreeMap::new()),
|
last_typing_update: RwLock::new(BTreeMap::new()),
|
||||||
|
@ -96,6 +93,9 @@ impl Services<'_> {
|
||||||
pdu_metadata: rooms::pdu_metadata::Service {
|
pdu_metadata: rooms::pdu_metadata::Service {
|
||||||
db,
|
db,
|
||||||
},
|
},
|
||||||
|
read_receipt: rooms::read_receipt::Service {
|
||||||
|
db,
|
||||||
|
},
|
||||||
search: rooms::search::Service {
|
search: rooms::search::Service {
|
||||||
db,
|
db,
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
pub mod presence;
|
pub mod presence;
|
||||||
pub mod read_receipt;
|
|
||||||
pub mod typing;
|
pub mod typing;
|
||||||
|
|
||||||
pub trait Data: presence::Data + read_receipt::Data + 'static {}
|
pub trait Data: presence::Data + 'static {}
|
||||||
|
|
||||||
pub struct Service {
|
pub struct Service {
|
||||||
pub presence: presence::Service,
|
pub presence: presence::Service,
|
||||||
pub read_receipt: read_receipt::Service,
|
|
||||||
pub typing: typing::Service,
|
pub typing: typing::Service,
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ pub mod lazy_loading;
|
||||||
pub mod metadata;
|
pub mod metadata;
|
||||||
pub mod outlier;
|
pub mod outlier;
|
||||||
pub mod pdu_metadata;
|
pub mod pdu_metadata;
|
||||||
|
pub mod read_receipt;
|
||||||
pub mod search;
|
pub mod search;
|
||||||
pub mod short;
|
pub mod short;
|
||||||
pub mod spaces;
|
pub mod spaces;
|
||||||
|
@ -27,6 +28,7 @@ pub trait Data:
|
||||||
+ metadata::Data
|
+ metadata::Data
|
||||||
+ outlier::Data
|
+ outlier::Data
|
||||||
+ pdu_metadata::Data
|
+ pdu_metadata::Data
|
||||||
|
+ read_receipt::Data
|
||||||
+ search::Data
|
+ search::Data
|
||||||
+ short::Data
|
+ short::Data
|
||||||
+ state::Data
|
+ state::Data
|
||||||
|
@ -49,6 +51,7 @@ pub struct Service {
|
||||||
pub metadata: metadata::Service,
|
pub metadata: metadata::Service,
|
||||||
pub outlier: outlier::Service,
|
pub outlier: outlier::Service,
|
||||||
pub pdu_metadata: pdu_metadata::Service,
|
pub pdu_metadata: pdu_metadata::Service,
|
||||||
|
pub read_receipt: read_receipt::Service,
|
||||||
pub search: search::Service,
|
pub search: search::Service,
|
||||||
pub short: short::Service,
|
pub short: short::Service,
|
||||||
pub state: state::Service,
|
pub state: state::Service,
|
||||||
|
|
|
@ -296,7 +296,6 @@ impl Service {
|
||||||
// appending fails
|
// appending fails
|
||||||
services()
|
services()
|
||||||
.rooms
|
.rooms
|
||||||
.edus
|
|
||||||
.read_receipt
|
.read_receipt
|
||||||
.private_read_set(&pdu.room_id, &pdu.sender, count1)?;
|
.private_read_set(&pdu.room_id, &pdu.sender, count1)?;
|
||||||
services()
|
services()
|
||||||
|
|
|
@ -521,7 +521,6 @@ pub fn select_edus_receipts(
|
||||||
) -> Result<bool> {
|
) -> Result<bool> {
|
||||||
for r in services()
|
for r in services()
|
||||||
.rooms
|
.rooms
|
||||||
.edus
|
|
||||||
.read_receipt
|
.read_receipt
|
||||||
.readreceipts_since(room_id, since)
|
.readreceipts_since(room_id, since)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue