Skip to content

Commit

Permalink
Revert "Send read reciept and typing indicator EDUs to appservices wi…
Browse files Browse the repository at this point in the history
…th receive_ephemeral"

This reverts commit 3675c94.
  • Loading branch information
girlbossceo committed Dec 18, 2024
1 parent 9040ad0 commit f54a62d
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 135 deletions.
26 changes: 13 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ version = "0.1.2"
[workspace.dependencies.ruma]
git = "https://github.com/girlbossceo/ruwuma"
#branch = "conduwuit-changes"
rev = "112ccc24cb14de26757715d611285d0806d5d91f"
rev = "a204cb56dbc20f72a1cbd0e9d6c827bbfd4082f2"
features = [
"compat",
"rand",
Expand All @@ -350,6 +350,7 @@ features = [
"compat-upload-signatures",
"identifiers-validation",
"unstable-unspecified",
"unstable-msc2409",
"unstable-msc2448",
"unstable-msc2666",
"unstable-msc2867",
Expand All @@ -365,7 +366,6 @@ features = [
"unstable-msc4121",
"unstable-msc4125",
"unstable-msc4186",
"unstable-msc4203", # sending to-device events to appservices
"unstable-msc4210", # remove legacy mentions
"unstable-extensible-events",
]
Expand Down
14 changes: 9 additions & 5 deletions src/api/client/read_marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,14 @@ pub(crate) async fn set_read_marker_route(
services
.rooms
.read_receipt
.readreceipt_update(sender_user, &body.room_id, ruma::events::receipt::ReceiptEvent {
content: ruma::events::receipt::ReceiptEventContent(receipt_content),
room_id: body.room_id.clone(),
})
.readreceipt_update(
sender_user,
&body.room_id,
&ruma::events::receipt::ReceiptEvent {
content: ruma::events::receipt::ReceiptEventContent(receipt_content),
room_id: body.room_id.clone(),
},
)
.await;
}

Expand Down Expand Up @@ -167,7 +171,7 @@ pub(crate) async fn create_receipt_route(
.readreceipt_update(
sender_user,
&body.room_id,
ruma::events::receipt::ReceiptEvent {
&ruma::events::receipt::ReceiptEvent {
content: ruma::events::receipt::ReceiptEventContent(receipt_content),
room_id: body.room_id.clone(),
},
Expand Down
2 changes: 1 addition & 1 deletion src/api/server/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ async fn handle_edu_receipt(
services
.rooms
.read_receipt
.readreceipt_update(&user_id, &room_id, event)
.readreceipt_update(&user_id, &room_id, &event)
.await;
}
} else {
Expand Down
18 changes: 3 additions & 15 deletions src/service/rooms/read_receipt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ mod data;

use std::{collections::BTreeMap, sync::Arc};

use conduwuit::{debug, err, result::LogErr, warn, PduCount, PduId, RawPduId, Result};
use conduwuit::{debug, err, warn, PduCount, PduId, RawPduId, Result};
use futures::{try_join, Stream, TryFutureExt};
use ruma::{
api::appservice::event::push_events::v1::EphemeralData,
events::{
receipt::{ReceiptEvent, ReceiptEventContent, Receipts},
AnySyncEphemeralRoomEvent, SyncEphemeralRoomEvent,
Expand Down Expand Up @@ -49,25 +48,14 @@ impl Service {
&self,
user_id: &UserId,
room_id: &RoomId,
event: ReceiptEvent,
event: &ReceiptEvent,
) {
self.db.readreceipt_update(user_id, room_id, &event).await;
self.db.readreceipt_update(user_id, room_id, event).await;
self.services
.sending
.flush_room(room_id)
.await
.expect("room flush failed");
// update appservices
let edu = EphemeralData::Receipt(event);
let _ = self
.services
.sending
.send_edu_appservice_room(
room_id,
serde_json::to_vec(&edu).expect("Serialized EphemeralData::Receipt"),
)
.await
.log_err();
}

/// Gets the latest private read receipt from the user in the room
Expand Down
54 changes: 8 additions & 46 deletions src/service/rooms/typing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ use conduwuit::{
};
use futures::StreamExt;
use ruma::{
api::{
appservice::event::push_events::v1::EphemeralData,
federation::transactions::edu::{Edu, TypingContent},
},
events::{typing::TypingEventContent, EphemeralRoomEvent, SyncEphemeralRoomEvent},
api::federation::transactions::edu::{Edu, TypingContent},
events::SyncEphemeralRoomEvent,
OwnedRoomId, OwnedUserId, RoomId, UserId,
};
use tokio::sync::{broadcast, RwLock};
Expand Down Expand Up @@ -79,9 +76,6 @@ impl Service {
trace!("receiver found what it was looking for and is no longer interested");
}

// update appservices
self.appservice_send(room_id).await?;

// update federation
if self.services.globals.user_is_local(user_id) {
self.federation_send(room_id, user_id, true).await?;
Expand Down Expand Up @@ -109,8 +103,7 @@ impl Service {
if self.typing_update_sender.send(room_id.to_owned()).is_err() {
trace!("receiver found what it was looking for and is no longer interested");
}
// update appservices
self.appservice_send(room_id).await?;

// update federation
if self.services.globals.user_is_local(user_id) {
self.federation_send(room_id, user_id, false).await?;
Expand Down Expand Up @@ -164,9 +157,6 @@ impl Service {
trace!("receiver found what it was looking for and is no longer interested");
}

// update appservices
self.appservice_send(room_id).await?;

// update federation
for user in &removable {
if self.services.globals.user_is_local(user) {
Expand All @@ -190,30 +180,17 @@ impl Service {
.unwrap_or(0))
}

/// Returns a new typing EDU.
pub async fn typings_content(&self, room_id: &RoomId) -> Result<TypingEventContent> {
let room_typing_indicators = self.typing.read().await.get(room_id).cloned();

let Some(typing_indicators) = room_typing_indicators else {
return Ok(TypingEventContent { user_ids: Vec::new() });
};

let user_ids: Vec<_> = typing_indicators.into_keys().collect();

Ok(TypingEventContent { user_ids })
}

/// Returns a new typing EDU.
pub async fn typings_all(
&self,
room_id: &RoomId,
sender_user: &UserId,
) -> Result<SyncEphemeralRoomEvent<TypingEventContent>> {
) -> Result<SyncEphemeralRoomEvent<ruma::events::typing::TypingEventContent>> {
let room_typing_indicators = self.typing.read().await.get(room_id).cloned();

let Some(typing_indicators) = room_typing_indicators else {
return Ok(SyncEphemeralRoomEvent {
content: TypingEventContent { user_ids: Vec::new() },
content: ruma::events::typing::TypingEventContent { user_ids: Vec::new() },
});
};

Expand All @@ -231,7 +208,9 @@ impl Service {
.collect()
.await;

Ok(SyncEphemeralRoomEvent { content: TypingEventContent { user_ids } })
Ok(SyncEphemeralRoomEvent {
content: ruma::events::typing::TypingEventContent { user_ids },
})
}

async fn federation_send(
Expand All @@ -258,21 +237,4 @@ impl Service {

Ok(())
}

async fn appservice_send(&self, room_id: &RoomId) -> Result<()> {
let edu = EphemeralData::Typing(EphemeralRoomEvent {
content: self.typings_content(room_id).await?,
room_id: room_id.into(),
});

self.services
.sending
.send_edu_appservice_room(
room_id,
serde_json::to_vec(&edu).expect("Serialized EphemeralData::Typing"),
)
.await?;

Ok(())
}
}
Loading

0 comments on commit f54a62d

Please sign in to comment.