element-android icon indicating copy to clipboard operation
element-android copied to clipboard

URL Previews not working for e2e rooms, even with previews enabled

Open logic opened this issue 4 years ago • 5 comments

Describe the bug With the introduction of url previews in 1.0.12, we now have parity with Element web, except for e2e rooms. I'm a member of a large number of e2e rooms with URL previews enabled (in element web) that are not expanding in element android.

(This used to work with the old version of riot-android, fwiw.)

To Reproduce Steps to reproduce the behavior:

  1. Create and enter an e2e room.
  2. In Element web, go to room settings -> General -> URL Previews, and "enable URL previews for this room".
  3. Post a URL in the room, watch as it unfurls in Element web.
  4. Open the room in Element android, watch as it shows a bare URL with no preview.

Expected behavior I was expecting a preview. :)

Smartphone (please complete the following information):

  • Device: Samsung Galaxy S7
  • OS: Android 10 (LineageOS + microg)

Additional context

  • 1.0.12 - Google Play Store
  • Homeserver: private synapse instance

logic avatar Dec 19 '20 18:12 logic

I randomly selected this bug as a potential good "first issue" to familiarize myself with the codebase, but it turns out it's a bit more complicated :-)

Element-Android's current behavior is pretty straight-forward, it simply disables URL previews for all encrypted rooms: https://github.com/vector-im/element-android/pull/2490/files#diff-777e743c40b267f7ad514207dabaf444be1b227ad415e31d86bf798ea3aac2f0R1353. That would have to be replaced with a per-room setting (https://matrix.org/docs/spec/client_server/latest#put-matrix-client-r0-user-userid-rooms-roomid-account-data-type).

However, Element-Web currently uses two different setting keys, one if the room is encrypted, another if the room is not encrypted. Non-encrypted rooms use "org.matrix.room.preview_urls", a key in the official namespace but missing from the spec (https://github.com/matrix-org/matrix-doc/issues/1732) and referred to as "legacy" by comments in the codebase. But for encrypted rooms it uses a dict with key "im.vector.web.settings", containing a setting called "urlPreviewsEnabled_e2ee".

Making Element-Android read from/write to the "im.vector.web" namespace would (although theoretically possible) not be the right way to go. Making it use its own namespace, "im.vector.android", would be possible but then the setting wouldn't be synchronized between Android and Web, also not ideal.

So the right way to tackle this probably involves first creating a formal spec for this setting, then (re-)writing both Element-Web and Element-Android to make use of it. (Although then you could argue whether room accountdata is even the right place for this setting; f.e. someone who trusts their homeserver - because it's ran by themselves or their organization - would probably rather enable e2e URL previews for all rooms with a single setting).

laszlovl avatar Jan 06 '21 17:01 laszlovl

Hi! I'm having this issue with e2e rooms for Android; absolutely no way to make URL previews work.

Have there been any updates on getting this fixed?

justinmcdaniel avatar Mar 07 '22 02:03 justinmcdaniel

Hi!

I also have this issue. No URL previews for encrypted rooms/chats. But I found an option for the windows client in the room options: "URL-Vorschau für dich in diesem Raum" (German, which probably translates back into the English original like "URL previews for you in this room"). So every participant of this room can/must enable this if URL previews are wanted. I tried and it worked!

Unfortunately I do not see this option for the Android and iOS client. For Linux I cannot say as I do not have a Linux machine with a GUI here at the moment.

I googled and read about this option and also if it should be enabled in encrypted rooms. And I noticed that this topic is there for quite a while. So I was not sure if this was the case by purpose (security by design) or not. But after noticing the option in the Windows client I would say that URL previews in encrypted rooms are supported - if enabled by the user.

So my question here is, if the option will be ported to Android and iOS (and maybe Linux), too?

msebald avatar Mar 19 '22 11:03 msebald

@msebald

I just encounter the same issue. Although, I can use the URL preview on linux but not on my mobile devices. So, at least I can confirm that it is working on linux.

giomf avatar Apr 18 '25 10:04 giomf

I can confirm it's also not working on the self-hosted web client, also on linux, in E2E encrypted rooms.

shootie22 avatar May 03 '25 09:05 shootie22