mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
refactor(sync/v3): Split load_joined_room into smaller functions
This commit is contained in:
@@ -7,7 +7,7 @@ use conduwuit::{
|
||||
use database::{Deserialized, Json, Map};
|
||||
use futures::{Stream, StreamExt};
|
||||
use ruma::{
|
||||
CanonicalJsonObject, RoomId, UserId,
|
||||
CanonicalJsonObject, OwnedUserId, RoomId, UserId,
|
||||
events::{AnySyncEphemeralRoomEvent, receipt::ReceiptEvent},
|
||||
serde::Raw,
|
||||
};
|
||||
@@ -25,7 +25,7 @@ struct Services {
|
||||
globals: Dep<globals::Service>,
|
||||
}
|
||||
|
||||
pub(super) type ReceiptItem<'a> = (&'a UserId, u64, Raw<AnySyncEphemeralRoomEvent>);
|
||||
pub(super) type ReceiptItem = (OwnedUserId, u64, Raw<AnySyncEphemeralRoomEvent>);
|
||||
|
||||
impl Data {
|
||||
pub(super) fn new(args: &crate::Args<'_>) -> Self {
|
||||
@@ -65,7 +65,7 @@ impl Data {
|
||||
&'a self,
|
||||
room_id: &'a RoomId,
|
||||
since: u64,
|
||||
) -> impl Stream<Item = ReceiptItem<'a>> + Send + 'a {
|
||||
) -> impl Stream<Item = ReceiptItem> + Send + 'a {
|
||||
type Key<'a> = (&'a RoomId, u64, &'a UserId);
|
||||
type KeyVal<'a> = (Key<'a>, CanonicalJsonObject);
|
||||
|
||||
@@ -81,7 +81,7 @@ impl Data {
|
||||
|
||||
let event = serde_json::value::to_raw_value(&json)?;
|
||||
|
||||
Ok((user_id, count, Raw::from_json(event)))
|
||||
Ok((user_id.to_owned(), count, Raw::from_json(event)))
|
||||
})
|
||||
.ignore_err()
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ impl Service {
|
||||
&'a self,
|
||||
room_id: &'a RoomId,
|
||||
since: Option<u64>,
|
||||
) -> impl Stream<Item = ReceiptItem<'a>> + Send + 'a {
|
||||
) -> impl Stream<Item = ReceiptItem> + Send + 'a {
|
||||
self.db.readreceipts_since(room_id, since.unwrap_or(0))
|
||||
}
|
||||
|
||||
|
||||
@@ -530,7 +530,7 @@ impl Service {
|
||||
}
|
||||
|
||||
max_edu_count.fetch_max(count, Ordering::Relaxed);
|
||||
if !self.services.globals.user_is_local(user_id) {
|
||||
if !self.services.globals.user_is_local(&user_id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -554,7 +554,7 @@ impl Service {
|
||||
let receipt = receipt
|
||||
.remove(&ReceiptType::Read)
|
||||
.expect("our read receipts always set this")
|
||||
.remove(user_id)
|
||||
.remove(&user_id)
|
||||
.expect("our read receipts always have the user here");
|
||||
|
||||
let receipt_data = ReceiptData {
|
||||
@@ -562,7 +562,7 @@ impl Service {
|
||||
event_ids: vec![event_id.clone()],
|
||||
};
|
||||
|
||||
if read.insert(user_id.to_owned(), receipt_data).is_none() {
|
||||
if read.insert(user_id, receipt_data).is_none() {
|
||||
*num = num.saturating_add(1);
|
||||
if *num >= SELECT_RECEIPT_LIMIT {
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user