Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for room peeking #141

Closed
4 tasks
akirk opened this issue Nov 29, 2022 · 17 comments
Closed
4 tasks

Add support for room peeking #141

akirk opened this issue Nov 29, 2022 · 17 comments
Assignees

Comments

@akirk
Copy link
Member

akirk commented Nov 29, 2022

It'd be interesting for people not having to join the chat room to see the ongoing conversation. Since Matrix has support for peeking into a room, let's research how we can implement this, ideally completely anonymous, so that only when people want to write a message, they'd log in.

@psrpinto
Copy link
Member

Relevant hydrogen issue: element-hq/hydrogen-web#719
PR showing how guest login could be implemented in hydrogen: element-hq/hydrogen-web#390

@ashfame ashfame mentioned this issue Dec 14, 2022
@ashfame
Copy link
Member

ashfame commented Dec 14, 2022

Update so far:

Contribution to Hydrogen - ashfame/hydrogen-web@master...ashfame:hydrogen-web:guest_account

In Chatrix: Draft PR

I have added an unknown room view model and registers a guest account but at that point it fails to join the room.

Screenshot 2022-12-14 at 12 58 59 PM

@ashfame
Copy link
Member

ashfame commented Dec 22, 2022

Quick update:

I got the guest accounts functionality as I originally thought functional, but it was after joining the room with the guest account. Since, having lots of join notifications are undesirable, I was researching and was glad to learn that its certainly possible to preview room without joining the room. It just requires authentication and doesn't need to join the room. So that's what I have been working on. I am close, but I am stuck on rendering the timeline. View should re-render but it doesn't seem to.

I also researched about utilising a single guest/limited user to preview users and that's a viable route as well, though it requires some additional steps. Its possible to set power level of this limited user as -1 in every room and thus it won't be able to post a message. But it would need to be in every room that we need the preview functionality for and have a negative power level (which is the additional step required with every room). Apart from that, I don't really see any other con with this approach. The only thing malicious a user can attempt to do with this, is to join other rooms on other servers and spam there. Those servers can choose to ban that user, which is the same concern with guest account as well. Unless we block such Client Server calls using Corporal or something. Additionally, we might have to lift rate limiting for this user in that case though.

That being said, I would say, getting it first functional with guest account is the way to go. This way we have all the flexibility (someone can choose a guest account for room previews, someone can have the guest account ready for participation, and someone can designate a specific account for room previews).

@ashfame
Copy link
Member

ashfame commented Jan 11, 2023

Quick update:

I am currently working on bringing the peeking functionality in Hydrogen first, so that it works for all users i.e. regular and guest accounts. This prevents it from getting too complicated to work it all within Chatrix (its codebase, changes in node modules directly for hydrogen and rebuilding vite build files). I also lost some code modifications in node_modules when I picked it back after new year vacations. There are also multiple changes in hydrogen branches, which were merged in a single branch to act as the modified dependency.

So working in hydrogen directly and landing it there is indeed a great way to move forward (thanks @psrpinto) and fact that upgrading hydrogen to the latest would simply bring the feature in, along with guest account functionality makes it a very viable route.

Current work:

@ashfame
Copy link
Member

ashfame commented Jan 26, 2023

Quick update: @psrpinto and I were able to make progress on timeline by stuffing data directly in indexed db and that seems to change the view a little. I am going to continue to put more stuff in there and see if the timeline gets rendered that way.

We also evaluated matrix-public-archive and that works by having the user (whose access token it uses) to be joined to the room.

We also discussed options of bringing peeking functionality since we both find it quite valuable and decided that continuing on current path of landing peeking support in hydrogen is indeed the best path forward.

My hope is that, with more stuff put into indexed db, we would atleast see the timeline rendered properly and it would just be the sync that we would need to write some code for, to keep showing new messages as they come into the room.

@akirk
Copy link
Member Author

akirk commented Jan 26, 2023

Great, thanks for the update!

@ashfame
Copy link
Member

ashfame commented Jan 31, 2023

Quick update: Finally got the timeline to render during today's pairing session with @psrpinto
Still have rough edges to fix but definitely a milestone 🥳

Things that are yet to do:

  1. Reliably sync new messages into the indexed db store. Second message in the room showed up when refreshed but third one didn't
  2. Messages show up in the wrong order
  3. Room name doesn't show up yet
  4. Styling of bottom bar
  5. Actual sync mechanism (which is to be tackled in a later PR)

@ashfame
Copy link
Member

ashfame commented Feb 1, 2023

Draft PR link for review - Automattic/hydrogen-web#2

@akirk
Copy link
Member Author

akirk commented Feb 1, 2023

Actual sync mechanism (which is to be tackled in a later PR)

Yes, I think this is not urgent and I am not sure it is actually implemented even in Element itself.

@psrpinto
Copy link
Member

psrpinto commented Feb 2, 2023

I agree that having new messages come in after the timeline is loaded is something we could look at in the future, once/if "static" peaking gets merged into hydrogen.

@ashfame
Copy link
Member

ashfame commented Feb 2, 2023

Yep, agree sync can come later on. For sake of documentation, Element does support it.

I have made the following changes:

  • Syncing happens correctly irrespective of previous loaded state when page is reloaded
  • All messages now show up correctly
  • Changed the order of fetching messages to be chronological
  • Room name shows up now
  • Context menu on messages are now hidden

What still needs doing:

  • Load members info (currently it shows user identity in absence of that)
  • Back scrolling doesn't work (its only the initial messages that are loaded)
  • Bottom bar styling
  • Generate room summary dynamically

@ashfame
Copy link
Member

ashfame commented Feb 3, 2023

Got a bunch of more things done today:

  • Refactor the function to fetch events so that it can be easily invoked multiple times (for future needs)
  • Generate room summary dynamically
  • move peek() invocation outside of constructor
  • Style bottom bar
  • Room's picture now shows up
  • Load 100 messages to begin with, since not focusing on making back scrolling functional

Couple of things that I would say are remaining:

  • Load members info (user name and picture)
  • Disable right panel view rendering when clicked on user picture

@ashfame
Copy link
Member

ashfame commented Feb 9, 2023

Draft PR for Hydrogen - Automattic/hydrogen-web#3

Members identity are shown instead of names. Apparently loading members list brings in more undesirable effects so that has been left for later. Peeking is functional! 🥳

Getting it reviewed internally before submitting it to upstream.

@Automattic Automattic deleted a comment from akirk Feb 16, 2023
@ashfame
Copy link
Member

ashfame commented Feb 27, 2023

Updated original comment with upstream PR link and next step to follow.

@ashfame
Copy link
Member

ashfame commented Feb 27, 2023

Grand update:

In order to have peeking support in Chatrix, there are 2 user stories to satisfy.

User Story 1

I am already a logged in user on Matrix homeserver and I am browsing different pages where different rooms are embedded. On one of those page, I can land on a room that I haven't joined. But if that room is world readable, I can just peek into it, using my existing account.

This user story is satisfied by the upstream PR for peeking, which is about just using an existing session to peek into an unknown room if its world readable.

The bottom bar only has "Join Room" option.

User Story 2

I am not logged in on Matrix homeserver at all and I am browsing pages where a matrix room is embedded. If any of the rooms are world readable, I should still be able to peek into the room, by having a guest account created for myself behind the scenes.

This user story would be satisfied once upstream PR for peeking is merged and another PR for creating a guest account when trying to render Chatrix in single room mode which would work as following:

  • Introduce the possibility of rendering an unknown room, even without a session instead of redirecting to login screen (specific to Chatrix)
  • While trying to render this unknown room, we will check whether room is world_readable and if so, create a guest session if there isn't already one (client.doGuestLogin() would be contributed to Hydrogen, rest would be specific to Chatrix)
  • Finally just redirect the user to /session/XXXXX/room/YYYY view and it would just work as peeking into a peekable room with a user account's session you have.

So, the user experience is similar to User Story 1, with just the difference between the options shown in bottom bar for participation. It could just be "Login" option for now, but eventually someone can want guest user participation as well (joining room as guest user and send messages in the room)?

Existing work for User story 2

Work in following 2 links would need to be adapted on top of our upstream peeking PR:

I tried running peeking PR branch as Hydrogen dependency in Chatrix, to prepare how this second PR would look like but there are some issues that we first need to resolve prior to update our dependency to Hydrogen version v0.3.7 (we use v0.3.5 and latest is v0.3.8)

PS

Once we attempt to package "Guest as login" proposal to Hydrogen as whole, some of the specific code for user story 2, sitting just in Chatrix could potentially be contributed upstream. Not all of it would be possible, since "Single Room Mode" is a Chatrix's concept.

@ashfame
Copy link
Member

ashfame commented Mar 6, 2023

First comment of issue updated with links to relevant PRs to finish this feature.

@ashfame
Copy link
Member

ashfame commented Mar 16, 2023

Done via #199

@ashfame ashfame closed this as completed Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants