Skip to content
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 [email protected].
  • The remote instance will request https://test.nextcloud.com/.well-known/webfinger?resource=acct:[email protected] to obtain the template of an URI (based on OStatus). This should be the result:
{
  "subject": "acct:[email protected]",
  "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 ([email protected]) 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