element-hq / element-x-ios

Next generation Matrix client for iOS built with SwiftUI on top of matrix-rust-sdk.
https://element.io/labs/element-x
GNU Affero General Public License v3.0
426 stars 103 forks source link

Late decryptions don't update `RepliedToEvent` #3113

Open ara4n opened 3 months ago

ara4n commented 3 months ago

“Unsupported event” shown as reply, despite event being supported

Steps to reproduce

  1. Flip through scrollback
  2. Note that some embedded replies are corrupt, saying “unsupported event”.
  3. Tap on the embedded reply, which takes you to a perfectly valid event (higlighted in the example below):

IMG_7948

My guess is that at the point the reply was rendered the original event hadn’t been backpaginated or decrypted yet, hence the corruption. Perhaps the reply doesn’t update once the msg keys are fished out of backup? And the “unsupported event” is a lie and should be “unable to decrypt”?

the wobbly reply is:

https://matrix.to/#/!cnVVNLKqgUzNTOFQkz:matrix.org/$0LXqcUfxoYTiFq2KLgi9tYb8MpG0FAqnEPRiTvcy9rc?via=matrix.org&via=element.io&via=jki.re


EventTimelineItem {
    sender: "@matthew:matrix.org",
    sender_profile: Ready(
        Profile {
            display_name: Some(
                "Matthew",
            ),
            display_name_ambiguous: false,
            avatar_url: Some(
                "mxc://matrix.org/oUxxDyzQOHdVDMxgwFzyCWEe",
            ),
        },
    ),
    timestamp: 2024-07-30T17:20:02.024,
    content: Message(
        Message {
            in_reply_to: Some(
                InReplyToDetails {
                    event_id: "$OyqahQ2M3d8M7zXZ8jFy0thYsrV51ejEzf9P-GWA-OA",
                    event: Ready(
                        RepliedToEvent {
                            content: UnableToDecrypt(
                                MegolmV1AesSha2 {
                                    sender_key: "8U6RZ9St2kR6IZd8PCNXt4NGsLlMNUhKhq8C12mBPF8",
                                    device_id: "OCBXEUUWBE",
                                    session_id: "u9mUgbw9wjYuRSr7IoGEfBwa6Rk9N6i+teWGv9tSGYM",
                                    cause: Unknown,
                                },
                            ),
                            sender: "@matthew:matrix.org",
                            sender_profile: Ready(
                                Profile {
                                    display_name: Some(
                                        "Matthew",
                                    ),
                                    display_name_ambiguous: false,
                                    avatar_url: Some(
                                        "mxc://matrix.org/oUxxDyzQOHdVDMxgwFzyCWEe",
                                    ),
                                },
                            ),
                        },
                    ),
                },
            ),
            thread_root: None,
            edited: false,
            ..
        },
    ),
    kind: Remote(
        RemoteEventTimelineItem {
            event_id: "$I6hNJYaQHDoPUKfWJCoCyrsOTt2YP9fawoLHTF0W2z0",
            transaction_id: None,
            reactions: {},
            read_receipts: {},
            is_own: true,
            is_highlighted: false,
            encryption_info: Some(
                EncryptionInfo {
                    sender: "@matthew:matrix.org",
                    sender_device: None,
                    algorithm_info: MegolmV1AesSha2 {
                        curve25519_key: "74mkEb0CXv/l34cGsSvuODR2bOQ/E3aVKzdX+rlKfmQ",
                        sender_claimed_keys: {
                            "ed25519": "fhmV+gOftT4tWim9ZTbMjTDmJr5aBZ5cicd3wTE/afY",
                        },
                    },
                    verification_state: Unverified(
                        None(
                            InsecureSource,
                        ),
                    ),
                },
            ),
            origin: Pagination,
            ..
        },
    ),
}

{
  "sender" : "@matthew:matrix.org",
  "content" : {
    "body" : "> <@matthew:matrix.org> although these did eventually resolve; it might have been super slow sync? or perhaps it fished them out of backup\n\nhttps:\/\/github.com\/element-hq\/element-x-ios-rageshakes\/issues\/2036",
    "format" : "org.matrix.custom.html",
    "formatted_body" : "<mx-reply><blockquote><a href=\"https:\/\/matrix.to\/#\/!cnVVNLKqgUzNTOFQkz:matrix.org\/$OyqahQ2M3d8M7zXZ8jFy0thYsrV51ejEzf9P-GWA-OA\">In reply to<\/a> <a href=\"https:\/\/matrix.to\/#\/@matthew:matrix.org\">@matthew:matrix.org<\/a><br>although these did eventually resolve; it might have been super slow sync? or perhaps it fished them out of backup<\/blockquote><\/mx-reply>https:\/\/github.com\/element-hq\/element-x-ios-rageshakes\/issues\/2036",
    "m.relates_to" : {
      "m.in_reply_to" : {
        "event_id" : "$OyqahQ2M3d8M7zXZ8jFy0thYsrV51ejEzf9P-GWA-OA"
      }
    },
    "m.mentions" : {

    },
    "msgtype" : "m.text"
  },
  "origin_server_ts" : 1722360002024,
  "room_id" : "!cnVVNLKqgUzNTOFQkz:matrix.org",
  "event_id" : "$I6hNJYaQHDoPUKfWJCoCyrsOTt2YP9fawoLHTF0W2z0",
  "type" : "m.room.message",
  "unsigned" : {
    "age" : 416775976,
    "membership" : "join"
  }
}

Outcome

What did you expect?

accurate replies

What happened instead?

corrupt reply previews

Your phone model

No response

Operating system version

No response

Application version

666

Homeserver

No response

Will you send logs?

No

pixlwave commented 3 months ago

Closing as duplicate of #1286.

pixlwave commented 3 months ago

Ooops, they're rendered differently.