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

ability to add some entries out of rfc7033 #26178

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions lib/public/Http/WellKnown/JrdResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ public function addProperty(string $property, ?string $value): self {
* @param string|null $type https://tools.ietf.org/html/rfc7033#section-4.4.4.2
* @param string|null $href https://tools.ietf.org/html/rfc7033#section-4.4.4.3
* @param string[]|null $titles https://tools.ietf.org/html/rfc7033#section-4.4.4.4
* @param string|null $properties https://tools.ietf.org/html/rfc7033#section-4.4.4.5
* @param string[]|null $properties https://tools.ietf.org/html/rfc7033#section-4.4.4.5
* @param string[] $entries
Copy link
Member

Choose a reason for hiding this comment

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

so what is this? can you link to any docs?

Copy link
Member Author

Choose a reason for hiding this comment

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

That is the problem, it's not in the official RFC ...

When you navigate on a remote instance of mastodon, and wants to follow an account from that instance, there is a 'Follow' button.

  • Clicking on that button will open a popup that ask for your current fediverse account. Let's say my account is maxence@test.nextcloud.com.
  • The remote instance will request https://test.nextcloud.com/.well-known/webfinger?resource=acct:maxence@test.nextcloud.com to obtain the template of an URI (based on OStatus). This should be the result:
{
  "subject": "acct:maxence@test.nextcloud.com",
  "links": [
    {
      "rel": "self",
      "type": "application/activity+json",
      "href": "https://test.nextcloud.com/apps/social/@test"
    },
    {
      "rel": "http://ostatus.org/schema/1.0/subscribe",
      "template": "https://test.nextcloud.com/apps/social/ostatus/follow/?uri={uri}"
    }
  ]
}
  • The remote instance will replace {uri} with the account (maxence@test.nextcloud.com) and open that link in the same popup. The destination is on the instance of Nextcloud
  • The user identify himself on the instance of Nextcloud and click on 'Follow', initiating the process of following the remote account from the user's account on Nextcloud/Social.

Now the problem.

template is not an official entry for webfinger. Theorically, this template URI should be available in /.well-known/host-info, as it is the same value for every account, but mastodon use the info from webfinger, maybe to also check that the account you used in the form exists on the instance.

The array $entries this PR added to addLink allows the Social App to add non official entries to the array at the generation of the Link:

		$subscribe = $this->urlGenerator->linkToRouteAbsolute('social.OStatus.subscribe') . '?uri={uri}';
		$response->addLink(
			'http://ostatus.org/schema/1.0/subscribe',
			'',
			'',
			null,
			null,
			['template' => $subscribe]
		);

*
* @psalm-param array<string,(string|null)>|null $properties https://tools.ietf.org/html/rfc7033#section-4.4.4.5
*
Expand All @@ -132,14 +133,21 @@ public function addLink(string $rel,
?string $type,
?string $href,
?array $titles = [],
?array $properties = []): self {
$this->links[] = array_filter([
'rel' => $rel,
'type' => $type,
'href' => $href,
'titles' => $titles,
'properties' => $properties,
]);
?array $properties = [],
array $entries = []
): self {
$this->links[] = array_filter(
array_merge(
[
'rel' => $rel,
'type' => $type,
'href' => $href,
'titles' => $titles,
'properties' => $properties
],
$entries
)
);

return $this;
}
Expand Down