chore(timeline): add extra logs to investigate edit issues

This commit is contained in:
Benjamin Bouvier
2024-10-10 14:43:48 +02:00
parent 22c765b9ab
commit 85682ac37f
3 changed files with 14 additions and 4 deletions

View File

@@ -812,7 +812,7 @@ impl<P: RoomDataProvider> TimelineController<P> {
}
}
warn!("Timeline item not found, can't add event ID");
warn!("Timeline item not found, can't update send state");
return;
};

View File

@@ -523,6 +523,7 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> {
let Some(message) = event_item.content.as_message() else { return };
let Some(in_reply_to) = message.in_reply_to() else { return };
if replacement.event_id == in_reply_to.event_id {
trace!(reply_event_id = ?event_item.identifier(), "Updating response to edited event");
let in_reply_to = InReplyToDetails {
event_id: in_reply_to.event_id.clone(),
event: TimelineDetails::Ready(Box::new(
@@ -554,6 +555,7 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> {
}
/// Try to stash a pending edit, if it makes sense to do so.
#[instrument(skip(self, replacement))]
fn stash_pending_edit(
&mut self,
position: TimelineItemPosition,
@@ -604,6 +606,7 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> {
event_id: &EventId,
) -> Option<PendingEdit> {
let pos = edits.iter().position(|edit| edit.edited_event() == event_id)?;
trace!(edited_event = %event_id, "unstashed pending edit");
Some(edits.remove(pos).unwrap())
}

View File

@@ -37,7 +37,7 @@ use ruma::{
serde::Raw,
OwnedEventId, OwnedUserId, RoomVersionId, UserId,
};
use tracing::error;
use tracing::{error, trace};
use super::TimelineItemContent;
use crate::{
@@ -99,6 +99,7 @@ impl Message {
/// Apply an edit to the current message.
pub(crate) fn apply_edit(&mut self, mut new_content: RoomMessageEventContentWithoutRelation) {
trace!("applying edit to a Message");
// Edit's content is never supposed to contain the reply fallback.
new_content.msgtype.sanitize(DEFAULT_SANITIZER_MODE, RemoveReplyFallback::No);
self.msgtype = new_content.msgtype;
@@ -191,7 +192,10 @@ pub(crate) fn extract_room_msg_edit_content(
.content
.relates_to
{
Some(Relation::Replacement(re)) => Some(re.new_content),
Some(Relation::Replacement(re)) => {
trace!("found a bundled edit event in a room message");
Some(re.new_content)
}
_ => {
error!("got m.room.message event with an edit without a valid m.replace relation");
None
@@ -215,7 +219,10 @@ pub(crate) fn extract_poll_edit_content(
match *relations.replace? {
AnySyncMessageLikeEvent::UnstablePollStart(SyncUnstablePollStartEvent::Original(ev)) => {
match ev.content {
UnstablePollStartEventContent::Replacement(re) => Some(re.relates_to.new_content),
UnstablePollStartEventContent::Replacement(re) => {
trace!("found a bundled edit event in a poll");
Some(re.relates_to.new_content)
}
_ => {
error!("got new poll start event in a bundled edit");
None