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

Remote follow #1875

Merged
merged 31 commits into from
Sep 26, 2023
Merged

Remote follow #1875

merged 31 commits into from
Sep 26, 2023

Conversation

SleeplessOne1917
Copy link
Member

@SleeplessOne1917 SleeplessOne1917 commented Jul 8, 2023

Description

Taking @Nutomic's suggestion from #1804 to make a flow for federating with communities from remote instances. So far I've only made a modal for it. I could add a route to the UI to handle these redirects, but what about Mastodon, Pleroma, Calckey, etc? Is there any standard path to target for this sort of thing?

Screenshots

image

Remote Fetch Page

Success

remote_fetch_success

Loading

Screenshot_20230722_223219

Failed

Screenshot_20230722_223538

@wiki-me
Copy link

wiki-me commented Jul 8, 2023

It's a nice feature, but TBH most users will probably be served better by some browser extension that sets their "home instance" (lemmy tools?), maybe suggesting that also can make people think lemmy can be less of a hassle?

@Madis0
Copy link

Madis0 commented Jul 10, 2023

How about showing all three options in the modal and therefore removing the blue info box from the right?

  • Log in to subscribe on instance.example
  • Enter instance to subscribe on it: ________
  • Search !community@instance.example on your instance to subscribe

@Nutomic
Copy link
Member

Nutomic commented Jul 10, 2023

Based on this comment the path is available via webfinger. So it will also require some backend changes.

@dessalines
Copy link
Member

That means we will need to add a front end route for this:

https://MY_INSTANCE/activitypub/externalInteraction?uri={uri}

@SleeplessOne1917
Copy link
Member Author

@Nutomic @dessalines @jsit @alectrocute I updated this to have a page to redirect to. I could use some eyes on this.

@SleeplessOne1917 SleeplessOne1917 marked this pull request as ready for review July 23, 2023 02:47
Copy link
Member

@dessalines dessalines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The components and everything seem to work okay, but I'm struggling coming up with a way we can actually test this, besides putting it on our federation test instances.

src/shared/components/home/login.tsx Outdated Show resolved Hide resolved
src/shared/components/remote-fetch.tsx Outdated Show resolved Hide resolved
src/shared/components/remote-fetch.tsx Outdated Show resolved Hide resolved
src/shared/components/remote-fetch.tsx Outdated Show resolved Hide resolved
@poVoq
Copy link

poVoq commented Aug 1, 2023

No, that is exactly what I understood and I still think the name part is unnecessary and confusing.

For the redirect to your home server to work, you need to be logged in, thus your home community already knows your account name.

@SleeplessOne1917
Copy link
Member Author

The way the flow is currently implemented in this PR is closer to what @poVoq describes than the flow laid out in @Nutomic's comment. The way it works right now is:

  1. User has an account on lemmy.ml
  2. User browses sopuli.xyz and finds an interesting community
  3. User clicks on "remote follow" button, enters domain lemmy.ml and submits.
  4. If user is logged in they go directly to step 5. If not, they are brought to the login page and redirected after logging in.
  5. User is sent to https://lemmy.ml/activitypub/externalInteraction?uri=https://sopuli.xyz/c/interestingCommunity (community uri not encoded here for readability)
  6. resolveObject request is made with user's auth and a query in the form of !interestingCommunity@sopuli.xyz.
  7. Based on the resolveObject response:
    • Success: display the community's info in a card with a button for the user to subscribe.
    • Loading: Loading spinner
    • Failure: Failure screen displayed

@Nutomic
Copy link
Member

Nutomic commented Aug 3, 2023

User is sent to https://lemmy.ml/activitypub/externalInteraction?uri=https://sopuli.xyz/c/interestingCommunity (community uri not encoded here for readability)

This is going to break if the user is on another platform. There it needs to go to https://mastodon.social/authorize_interaction?uri={uri}". Thats why the webfinger query is necessary, and for that we need the username.

@poVoq
Copy link

poVoq commented Aug 3, 2023

Mastodon does not require this, see:

image

And I have used this exact form with just a instance domain redirecting to Hubzilla before and it worked fine. However I just tried it with Akkoma and it doesn't seem to work there (with the full name it does though).

@SleeplessOne1917
Copy link
Member Author

I'm struggling to figure out what the right way forward on this is given the lack of consensus. @Nutomic @poVoq @dessalines

@dessalines
Copy link
Member

@Nutomic is any of this PR necessary then? LemmyNet/lemmy#3738

If not, I'd say we should merge this, and use the federation test instances to debug / tweak it.

@Nutomic
Copy link
Member

Nutomic commented Aug 31, 2023

You can already test this with the setup in Lemmy repo docker/federation, by manually building a lemmy-ui image from this branch and putting that in the docker-compose file.

@poVoq I think that approach only works with platforms that use the same endpoint /authorize_interaction?uri={uri}. I tried with peertube just now and it gives an error 404 because it uses /remote-interaction?uri=. So the backend PR is necessary if we want to support different platforms such as Peertube.

@SleeplessOne1917
Copy link
Member Author

I'm going to work on this again. @Nutomic I'm not sure what steps need to be taken to make this work with the backend change. What endpoint should I be hitting for this? It might make sense to add logic for this to the JS client as well.

@Nutomic
Copy link
Member

Nutomic commented Sep 19, 2023

The Lemmy backend tells other Fediverse software that remote follow is available at /activitypub/externalInteraction?uri={{uri}}. Where {{uri}} is the actor_id of a community which can be passed to /api/v3/site/resolve_object. So you need to add a handler in lemmy-ui for /activitypub/externalInteraction which resolves the given community, and then shows a dialog "Do you want to follow this community yes/no?"

@SleeplessOne1917
Copy link
Member Author

@Nutomic the existing flow is already the same as what you described in your most recent comment. See this video:

remote_fetch_demo.mp4

The only rub is that even though the remote community is resolved, the subscribed state never stops being pending. I don't know if this is due to a flaw in how I implemented it or if it's a quirk of testing locally.

@Nutomic
Copy link
Member

Nutomic commented Sep 20, 2023

I tested it locally and can reproduce that problem. Its weird because the follow goes through if I fetch another community manually and press the sidebar subscribe button. Is there any difference between that and the new follow button you added for the remote follow dialog?

Im also getting various API error: unknown logged by lemmy-ui when viewing a remote community. Any idea what that is? Seems like the backend is returning 404 for some reason, would be good if lemmy-ui returned the actual backend error.

@SleeplessOne1917
Copy link
Member Author

SleeplessOne1917 commented Sep 22, 2023

I just tested this with the existing way of fetching remote communities by using the search page and ran into the exact same problem. I think this might only be an issue with testing federation locally, as opposed to an issue caused by my changes.

@SleeplessOne1917 SleeplessOne1917 enabled auto-merge (squash) September 23, 2023 03:00
@SleeplessOne1917
Copy link
Member Author

I just added the remote follow logic to the subscribe buttons on the communities page too:
image

I'm unsure if I should keep the button look here or go back to making it look like a link like it was before.

Copy link
Member

@dessalines dessalines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a huge fan of that button, for some reason they don't look great in tables. But I leave that up to you.

Once you fix the conflicts, feel free to merge. Then I'll make some RC's, because this is going to need some playing around with on the test instances for sure.

@SleeplessOne1917 SleeplessOne1917 merged commit d9fe7d1 into main Sep 26, 2023
0 of 2 checks passed
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

Successfully merging this pull request may close these issues.

None yet

6 participants