matrix-rust-sdk icon indicating copy to clipboard operation
matrix-rust-sdk copied to clipboard

Read receipts do not match number of read receipts from other clients, and some appear multiple times for the same user

Open Velin92 opened this issue 2 years ago • 4 comments

Here is an example of a message sent in the Matrix SDK room:

EventTimelineItem {
    sender: "@jplatte:flipdot.org",
    sender_profile: Ready(
        Profile {
            display_name: Some(
                "Jonas Platte",
            ),
            display_name_ambiguous: false,
            avatar_url: Some(
                "mxc://flipdot.org/KLRdSugnupCyNZKcvDZdhDIa",
            ),
        },
    ),
    timestamp: MilliSecondsSinceUnixEpoch(1686123251420),
    content: Message(
        Message {
            in_reply_to: None,
            edited: false,
            ..
        },
    ),
    kind: Remote(
        RemoteEventTimelineItem {
            event_id: "$RcN5E75_0aJiurp1psLvUOWXZE-Rc4o4eYUAdTg8GqI",
            reactions: {},
            read_receipts: {
                "@alfogrillo:element.io": Receipt {
                    ts: Some(
                        MilliSecondsSinceUnixEpoch(1686126044707),
                    ),
                    thread: Unthreaded,
                },
                "@auronandace:matrix.org": Receipt {
                    ts: Some(
                        MilliSecondsSinceUnixEpoch(1686124538559),
                    ),
                    thread: Unthreaded,
                },
                "@mrkabuduo:matrix.org": Receipt {
                    ts: Some(
                        MilliSecondsSinceUnixEpoch(1686123687255),
                    ),
                    thread: Unthreaded,
                },
                "@paul:luon.net": Receipt {
                    ts: Some(
                        MilliSecondsSinceUnixEpoch(1686123252971),
                    ),
                    thread: Unthreaded,
                },
                "@poljar:matrix.org": Receipt {
                    ts: Some(
                        MilliSecondsSinceUnixEpoch(1686123527025),
                    ),
                    thread: Unthreaded,
                },
                "@spore:mozilla.org": Receipt {
                    ts: Some(
                        MilliSecondsSinceUnixEpoch(1686123256943),
                    ),
                    thread: Unthreaded,
                },
                "@jplatte:flipdot.org": Receipt {
                    ts: Some(
                        MilliSecondsSinceUnixEpoch(1686123251420),
                    ),
                    thread: Unthreaded,
                },
            },
            is_own: false,
            is_highlighted: false,
            encryption_info: None,
            origin: Sync,
            ..
        },
    ),
}

{
  "event_id" : "$RcN5E75_0aJiurp1psLvUOWXZE-Rc4o4eYUAdTg8GqI",
  "content" : {
    "msgtype" : "m.text",
    "body" : "So things like a DM between a bridged user and a native Matrix user are probably currently not supported at all."
  },
  "sender" : "@jplatte:flipdot.org",
  "type" : "m.room.message",
  "unsigned" : {

  },
  "origin_server_ts" : 1686123251420
}

The number of read receipts weirdly does not match the one displayed on other clients such as El-Web, here is a screenshot from it for the same message:

Screenshot 2023-06-07 at 11 27 36

Maybe we are not handling read receipts from events that are hidden?

Also another issue is that some read receipts appears multiple times in the timeline, for example the message before this one:

EventTimelineItem {
    sender: "@spore:mozilla.org",
    sender_profile: Ready(
        Profile {
            display_name: Some(
                "Spore",
            ),
            display_name_ambiguous: false,
            avatar_url: Some(
                "mxc://mozilla.org/1c832148544e7c55d6df39da145d05690e9305a0",
            ),
        },
    ),
    timestamp: MilliSecondsSinceUnixEpoch(1686123197536),
    content: Message(
        Message {
            in_reply_to: None,
            edited: false,
            ..
        },
    ),
    kind: Remote(
        RemoteEventTimelineItem {
            event_id: "$OjL8JwZA3WATlWwDQBP_0c9ZYwQlauY2xeEXz_s-eRo",
            reactions: {},
            read_receipts: {
                "@jplatte:flipdot.org": Receipt {
                    ts: Some(
                        MilliSecondsSinceUnixEpoch(1686123212429),
                    ),
                    thread: Unthreaded,
                },
                "@spore:mozilla.org": Receipt {
                    ts: Some(
                        MilliSecondsSinceUnixEpoch(1686123197536),
                    ),
                    thread: Unthreaded,
                },
            },
            is_own: false,
            is_highlighted: false,
            encryption_info: None,
            origin: Sync,
            ..
        },
    ),
}

{
  "event_id" : "$OjL8JwZA3WATlWwDQBP_0c9ZYwQlauY2xeEXz_s-eRo",
  "content" : {
    "msgtype" : "m.text",
    "body" : "ok then, thank you."
  },
  "sender" : "@spore:mozilla.org",
  "type" : "m.room.message",
  "unsigned" : {

  },
  "origin_server_ts" : 1686123197536
}

Contains also user @jplatte:flipdot.org even if this message comes before the other one with multiple read receipts.

Velin92 avatar Jun 07 '23 09:06 Velin92

A possible cause of that issue is that we currently drop events that we don't want to show, so it's not possible to keep track of read receipts for them.

Element Web keeps all events and exposes the receipts of hidden events on the visible events.

Of course that can only be implemented if the client receives all the events, I'm wondering how that should work with sliding-sync where we really only want to receive the events that should be visible. Ideally the homeserver would expose read receipts of events that are not sent on the right events that are sent.

zecakeh avatar Jun 07 '23 09:06 zecakeh

Also another thing that I found out is this (added it also to the original issue post)

Some read receipts of a user appear multiple times in the timeline, for example the message before the one posted before:

EventTimelineItem {
    sender: "@spore:mozilla.org",
    sender_profile: Ready(
        Profile {
            display_name: Some(
                "Spore",
            ),
            display_name_ambiguous: false,
            avatar_url: Some(
                "mxc://mozilla.org/1c832148544e7c55d6df39da145d05690e9305a0",
            ),
        },
    ),
    timestamp: MilliSecondsSinceUnixEpoch(1686123197536),
    content: Message(
        Message {
            in_reply_to: None,
            edited: false,
            ..
        },
    ),
    kind: Remote(
        RemoteEventTimelineItem {
            event_id: "$OjL8JwZA3WATlWwDQBP_0c9ZYwQlauY2xeEXz_s-eRo",
            reactions: {},
            read_receipts: {
                "@jplatte:flipdot.org": Receipt {
                    ts: Some(
                        MilliSecondsSinceUnixEpoch(1686123212429),
                    ),
                    thread: Unthreaded,
                },
                "@spore:mozilla.org": Receipt {
                    ts: Some(
                        MilliSecondsSinceUnixEpoch(1686123197536),
                    ),
                    thread: Unthreaded,
                },
            },
            is_own: false,
            is_highlighted: false,
            encryption_info: None,
            origin: Sync,
            ..
        },
    ),
}

{
  "event_id" : "$OjL8JwZA3WATlWwDQBP_0c9ZYwQlauY2xeEXz_s-eRo",
  "content" : {
    "msgtype" : "m.text",
    "body" : "ok then, thank you."
  },
  "sender" : "@spore:mozilla.org",
  "type" : "m.room.message",
  "unsigned" : {

  },
  "origin_server_ts" : 1686123197536
}

Contains also user @jplatte:flipdot.org even if this message comes before the other one with multiple read receipts.

Velin92 avatar Jun 07 '23 09:06 Velin92

Btw I think the most problematic part about the read receipts not matching the number of other clients such a s web, is that when I send a read receipt, and the other user reads it from another client, even El-X itself, the SDK is still returning empty read receipts for that timeline event

Velin92 avatar Jun 08 '23 08:06 Velin92

I am curious whether this is still an issue, given the improvements that have been made since then.

zecakeh avatar Aug 20 '24 08:08 zecakeh