DanilaFe / matrix-highlight

A decentralized and federated way of annotating the web based on Matrix.
Apache License 2.0
140 stars 3 forks source link

Allow storing highlights on arbitrary rooms #11

Open frandavid100 opened 2 years ago

frandavid100 commented 2 years ago

Right now, every time I want to annotate a webpage, I need to create a room specifically for that. Instead, I would like to be able to store annotations on an existing room of my choice. Consider the following use case:

I have a room where I hang out with a group of friends interested in movies. Whenever one of us reads some movie-related news, and thinks the others will be interested, he sends a link to that room and we comment the parts we found interesting.

It would be great to use Matrix Highlight for that. I would then be able to highlight some text as I read it, and send it to this particular room. My friends would then see some sort of message, e.g. "@david highlighted on example.com: lorem ipsum", and could then start a thread commenting that particular piece of text. Then I would easily find my friends' comments the next time I opened that same webpage, even if time had passed and they were old comments now, long lost in the room's timeline.

frandavid100 commented 2 years ago

Of course, in order to let you do that, the extension would need a way to show you your whole room list, including rooms that are not highlight rooms. Maybe with a checkbox which lets you choose between only seeing highlight rooms, or also seeing regular rooms.

Stvad commented 1 year ago

At a basic level you can probably give people an ability to just enter the roomId.

This also allow people to create and configure rooms the way they like (e.g. make room public).


Implementation-wise the current approach is to write the url of the room into the creation data for the room, instead (or in addition to that) one can use a custom-state event. To configure room to map to a certain url

DanilaFe commented 1 year ago

instead [...] one can use a custom-state event

The hiccup with this is that state events aren't visible before joining a room. It would have to be done in addition (like you mentioned), because otherwise, it would be impossible to tell highlight rooms you're invited to from regular rooms you're invited to.

Stvad commented 1 year ago

Ah, I see.

Trying to do that now, for some reason getting 403 when trying to add new event 🤔. Afaik there are no power level requirements for a custom state event?

The current version of sdk seems to be using an older url scheme 🤔

https://matrix-client.matrix.org/_matrix/client/r0/rooms/!xbzjCqPEplGFOiGRTy:matrix.org/state/com.danilafe.highlight.state/?access_token=... vs ( /_matrix/client/v3/rooms/{roomId}/state/{eventType}/{stateKey})

Tempted to update it to the latest, but that leads to a ton of compilation errors =\

Stvad commented 1 year ago

Looking at the older spec https://matrix.org/docs/spec/client_server/r0.5.0.html#put-matrix-client-r0-rooms-roomid-state-eventtype-statekey it doesn't seem like this should have changed

Stvad commented 1 year ago

It seems Synaps defaults to "50" as a default power level required on unknown state events =. annoying https://github.com/matrix-org/synapse/blob/develop/synapse/event_auth.py#L744

Stvad commented 1 year ago

that's user-side solvable, but a bad UX =. Any suggestions @DanilaFe ?

Stvad commented 1 year ago

Ah, I suppose this ticket also implies that one room can host highlights for a variety of pages, which would require more extensive changes 🤔

Stvad commented 1 year ago

Another thing I'm somewhat confused about is how to trigger proper transition of state in the extension after joining the room.

would appreciate your help on that @DanilaFe !

Stvad commented 1 year ago

For annotating multiple pages in one room - I suppose the approach would be to post a variety of messages with different state keys and then make the room match any of the given URLs internally.

The annotation messages would need to include the URL it's associated with, and be filtered by extension correspondingly.

Longer-term, I imagine there also can be perf concerns: