Merge branch 'refactor2' into 'next'

Remove unnecessary uses of event enums

See merge request famedly/conduit!300
This commit is contained in:
Timo Kösters 2022-02-12 11:50:23 +00:00
commit 8709c3ae7b
4 changed files with 14 additions and 15 deletions

View file

@ -4,7 +4,7 @@ use ruma::{
error::ErrorKind, error::ErrorKind,
r0::{read_marker::set_read_marker, receipt::create_receipt}, r0::{read_marker::set_read_marker, receipt::create_receipt},
}, },
events::{AnyEphemeralRoomEvent, EventType}, events::EventType,
receipt::ReceiptType, receipt::ReceiptType,
MilliSecondsSinceUnixEpoch, MilliSecondsSinceUnixEpoch,
}; };
@ -73,10 +73,10 @@ pub async fn set_read_marker_route(
db.rooms.edus.readreceipt_update( db.rooms.edus.readreceipt_update(
sender_user, sender_user,
&body.room_id, &body.room_id,
AnyEphemeralRoomEvent::Receipt(ruma::events::receipt::ReceiptEvent { ruma::events::receipt::ReceiptEvent {
content: ruma::events::receipt::ReceiptEventContent(receipt_content), content: ruma::events::receipt::ReceiptEventContent(receipt_content),
room_id: body.room_id.clone(), room_id: body.room_id.clone(),
}), },
&db.globals, &db.globals,
)?; )?;
} }
@ -130,10 +130,10 @@ pub async fn create_receipt_route(
db.rooms.edus.readreceipt_update( db.rooms.edus.readreceipt_update(
sender_user, sender_user,
&body.room_id, &body.room_id,
AnyEphemeralRoomEvent::Receipt(ruma::events::receipt::ReceiptEvent { ruma::events::receipt::ReceiptEvent {
content: ruma::events::receipt::ReceiptEventContent(receipt_content), content: ruma::events::receipt::ReceiptEventContent(receipt_content),
room_id: body.room_id.clone(), room_id: body.room_id.clone(),
}), },
&db.globals, &db.globals,
)?; )?;

View file

@ -7,7 +7,7 @@ use ruma::{
}, },
events::{ events::{
room::member::{MembershipState, RoomMemberEventContent}, room::member::{MembershipState, RoomMemberEventContent},
AnySyncEphemeralRoomEvent, EventType, EventType,
}, },
serde::Raw, serde::Raw,
DeviceId, RoomId, UserId, DeviceId, RoomId, UserId,
@ -656,10 +656,8 @@ async fn sync_helper(
if db.rooms.edus.last_typing_update(&room_id, &db.globals)? > since { if db.rooms.edus.last_typing_update(&room_id, &db.globals)? > since {
edus.push( edus.push(
serde_json::from_str( serde_json::from_str(
&serde_json::to_string(&AnySyncEphemeralRoomEvent::Typing( &serde_json::to_string(&db.rooms.edus.typings_all(&room_id)?)
db.rooms.edus.typings_all(&room_id)?, .expect("event is valid, we just created it"),
))
.expect("event is valid, we just created it"),
) )
.expect("event is valid, we just created it"), .expect("event is valid, we just created it"),
); );

View file

@ -2,7 +2,8 @@ use crate::{database::abstraction::Tree, utils, Error, Result};
use ruma::{ use ruma::{
events::{ events::{
presence::{PresenceEvent, PresenceEventContent}, presence::{PresenceEvent, PresenceEventContent},
AnyEphemeralRoomEvent, SyncEphemeralRoomEvent, receipt::ReceiptEvent,
SyncEphemeralRoomEvent,
}, },
presence::PresenceState, presence::PresenceState,
serde::Raw, serde::Raw,
@ -31,7 +32,7 @@ impl RoomEdus {
&self, &self,
user_id: &UserId, user_id: &UserId,
room_id: &RoomId, room_id: &RoomId,
event: AnyEphemeralRoomEvent, event: ReceiptEvent,
globals: &super::super::globals::Globals, globals: &super::super::globals::Globals,
) -> Result<()> { ) -> Result<()> {
let mut prefix = room_id.as_bytes().to_vec(); let mut prefix = room_id.as_bytes().to_vec();

View file

@ -46,7 +46,7 @@ use ruma::{
member::{MembershipState, RoomMemberEventContent}, member::{MembershipState, RoomMemberEventContent},
server_acl::RoomServerAclEventContent, server_acl::RoomServerAclEventContent,
}, },
AnyEphemeralRoomEvent, EventType, EventType,
}, },
int, int,
receipt::ReceiptType, receipt::ReceiptType,
@ -795,10 +795,10 @@ pub async fn send_transaction_message_route(
let mut receipt_content = BTreeMap::new(); let mut receipt_content = BTreeMap::new();
receipt_content.insert(event_id.to_owned(), receipts); receipt_content.insert(event_id.to_owned(), receipts);
let event = AnyEphemeralRoomEvent::Receipt(ReceiptEvent { let event = ReceiptEvent {
content: ReceiptEventContent(receipt_content), content: ReceiptEventContent(receipt_content),
room_id: room_id.clone(), room_id: room_id.clone(),
}); };
db.rooms.edus.readreceipt_update( db.rooms.edus.readreceipt_update(
&user_id, &user_id,
&room_id, &room_id,