web+ap protocol handler #589
No reviewers
Labels
No labels
approved, awaiting change
bug
configuration
documentation
duplicate
enhancement
extremely low priority
feature request
Fix it yourself
help wanted
invalid
mastodon_api
needs docs
needs tests
not a bug
planned
pleroma_api
privacy
question
static_fe
triage
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: AkkomaGang/akkoma#589
Loading…
Reference in a new issue
No description provided.
Delete branch "smitten/akkoma:web-protocol-handler"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This is a pass at implementing a web-based protocol handler which could be used to create URLs that reference remote users or posts, but that open locally at your home server.
This idea has been discussed before in a few places but no project has picked it up yet.
see mastodon issue - https://github.com/mastodon/mastodon/issues/19679
see fediverse-ideas issue - https://codeberg.org/fediverse/fediverse-ideas/issues/1
The goal is to register a web-based protocol handler* so that the following use cases would work:
web+ap://portend.place/smitten
.web+ap://portend.place/notice/AXfa06xMeen4I9wAzI
. The page could even link there with an<a>
tag.There are some open questions for how this should behave -
I've gone with Soni's proposals for both of these questions because they seem straightforward and would be easy to implement for other fedi clients.
Server address of
/.well-known/protocol-handler?target=%s
(see draft for more info)To prevent running authenticated requests at .well-known, this redirects to
/api/v1/akkoma/protocol-handler?target=%s
For the format of the links themselves, I'm using web+ap (see proposal for more info)
Other syntax could be possible in the future, like addressing webfinger handles - e.g.
web+ap:acct:smitten@portend.place
.* note that the UI for registering the handler is not part of this PR and would require some frontend work. The relevant JS is available with a static HTML file in web-protocol-register.js.
If there's any interest in Akkoma working to support this feature let me know. happy to tweak this code too, just a WIP.
Tokodon has implemented the web+ap protocol. Tokodon is a client for Plasma.
https://github.com/KDE/tokodon/blob/master/src/network/networkcontroller.cpp#L63-L112
FediText has also added support. FediText is an iOS client.
3373f6ef66
@ -0,0 +44,4 @@
defp find_and_redirect(%{assigns: %{user: user}} = conn, identifier) do
redirect_to_target(User.get_or_fetch("https://" <> identifier), conn)
|| redirect_to_target(Activity.search(user, "https://" <> identifier, [limit: 1]), conn)
I'm not sure Activity.search is the best method to use here. I couldn't find something like Activity.get_or_fetch() that just took the post URL, but it's probably my unfamiliarity with the code.
The goal would be to find the user or record by their remote URL without doing any fuzzy search querying.
There is
Pleroma.Object.Fetcher.fetch_object_from_id(id)
, which should work with any AP object IDUntested, but I added this code
5bbeeeeedd
@darkkirb
Thanks for taking a look. I'm not finding this able to pull a User, I get
{:error, "Object containment failed."}
For a post I do get a result back, but I'm not sure immediately how to use it because all the IDs in it are the remote URLs, so I can't redirect to the local representation without another step.
Hm, then maybe it should work with only the activity line replaced with my code? I found that particular function by following the code in the search module (Pleroma.Search.DatabaseSearch). Currently working on integrating it with akkoma-fe so I’ll take another look maybe tomorrow
Thanks, it needs to pass through
Activity.get_create_by_object_ap_id
afterwards to get the local 'Create' Activity record. UsingDatabaseSearch.maybe_fetch()
does both those steps, works well!WIP: web+ap protocol handlerto web+ap protocol handlerMy static-fe changes are here:
55bc84da35
. I’m unsure about the icon to use, that icon is currently used for “opening on remote instance” on akkoma-fe where I currently use a phone icon. The other suggestion I received was the same icon firefox uses for “open in app”, which is a pro-only fontawesome icon :/@darkkirb amazing, thanks! I think it does need its own icon, and maybe even a more specific term than 'Open in your client' (although I think that's decently clear).
I made a post to try and get some suggestions around this, I'm really not sure what the best way to represent the idea is.
https://portend.place/notice/AY3f5jqcNfznWGYuIK
I did a poll to try to get feedback and 'Fedi Link' seems to be the most popular. I implemented in akkoma-fe here, using ActivityPub icon:
https://akkoma.dev/AkkomaGang/akkoma-fe/compare/develop...smitten/akkoma-fe:develop
c0c8d13404
to98a117b10b
98a117b10b
tof9feb46d6e
26df052e8f
to637bca14cc
05117a0cb3
to5469a1268e
I received some good feedback on this from a GoToSocial user who primarily uses Semaphore. They were saying that it's more of a client-side feature exclusively, since we can't know what frontend route is relevant to redirect to.
It's making me think that maybe the redirect behavior is not a good idea, and I should implement this in akkoma-fe instead. (I'm not actually sure how Akkoma handles routes for the various frontend apps, I'm assuming they can choose their own routes independently).
So I may try to rework this so that it's just a new search endpoint, just to cover the specific behavior of looking up the user/post by URI. And then akkoma-fe could hit that endpoint and redirect itself.
Have received a lot of feedback that the backend changes to support this behavior are confusing, I may try a similar PR that is frontend-only. It would be helpful to have a new search endpoint that is more precise (returns only objects matching the queried ID instead of fuzzy search) for the frontend to use, but the web-protocol handler could be defined entirely in the client.
see new proposal on FEP: https://socialhub.activitypub.rocks/t/fep-07d7-a-custom-url-scheme-and-web-based-protocol-handlers-for-linking-to-activitypub-resources/3588
Pull request closed