diff --git a/config.ini b/config.ini index 9718fc2..74a86c4 100644 --- a/config.ini +++ b/config.ini @@ -1,6 +1,7 @@ [generic] protocol = 'https' -externaldomain = 'your.fqdn' +externaldomain = 'federator.your.fqdn' +sourcedomain = 'your.fqdn' [database] host = '127.0.0.1' diff --git a/php/federator/api/fedusers.php b/php/federator/api/fedusers.php index bb7b38d..11ecc7b 100644 --- a/php/federator/api/fedusers.php +++ b/php/federator/api/fedusers.php @@ -127,6 +127,7 @@ class FedUsers implements APIInterface } $config = $this->main->getConfig(); $domain = $config['generic']['externaldomain']; + $sourcedomain = $config['generic']['sourcedomain']; $jsonKey = json_encode($user->publicKey); if (!is_string($jsonKey)) { throw new \Federator\Exceptions\FileNotFound(); @@ -137,6 +138,7 @@ class FedUsers implements APIInterface 'imageMediaType' => $user->imageMediaType, 'imageURL' => $user->imageURL, 'fqdn' => $domain, + 'sourcedomain' => $sourcedomain, 'name' => $user->name, 'username' => $user->id, 'publickey' => trim($jsonKey, '"'), diff --git a/php/federator/api/wellknown/webfinger.php b/php/federator/api/wellknown/webfinger.php index 72555e3..584c53d 100644 --- a/php/federator/api/wellknown/webfinger.php +++ b/php/federator/api/wellknown/webfinger.php @@ -48,7 +48,8 @@ class WebFinger $matches = []; $config = $this->main->getConfig(); $domain = $config['generic']['externaldomain']; - if (preg_match("/^acct:([^@]+)@(.*)$/", $_resource, $matches) != 1 || $matches[2] !== $domain) { + $sourcedomain = $config['generic']['sourcedomain']; + if (preg_match("/^acct:([^@]+)@(.*)$/", $_resource, $matches) != 1 || $matches[2] !== $sourcedomain) { throw new \Federator\Exceptions\InvalidArgument(); } $user = \Federator\DIO\User::getUserByName( @@ -63,6 +64,7 @@ class WebFinger $data = [ 'username' => $user->id, 'domain' => $domain, + 'sourcedomain' => $sourcedomain, ]; $response = $this->main->renderTemplate('webfinger_acct.json', $data); $this->wellKnown->setResponse($response); diff --git a/templates/federator/user.json b/templates/federator/user.json index 13a2aaf..58648f6 100644 --- a/templates/federator/user.json +++ b/templates/federator/user.json @@ -58,24 +58,24 @@ {rdelim} {rdelim} ], - "id":"https://{$fqdn}/{$username}", + "id":"https://{$sourcedomain}/{$username}", "type":"{$type}", "following":"https://{$fqdn}/{$username}/following", "followers":"https://{$fqdn}/{$username}/followers", "inbox":"https://{$fqdn}/{$username}/inbox", "outbox":"https://{$fqdn}/{$username}/outbox", - "featured":"https://{$fqdn}/{$username}/collections/featured", - "featuredTags":"https://{$fqdn}/{$username}/collections/tags", + {*"featured":"https://{$fqdn}/{$username}/collections/featured", + "featuredTags":"https://{$fqdn}/{$username}/collections/tags",*} "preferredUsername":"{$username}", "name":"{$name}", "summary":"{$summary}", - "url":"https://{$fqdn}/@{$username}", + "url":"https://{$sourcedomain}/@{$username}", "manuallyApprovesFollowers":false, "discoverable":true, "published":"{$registered}", "publicKey":{ldelim} "id":"https://{$fqdn}/{$username}#main-key", - "owner":"https://{$fqdn}/{$username}", + "owner":"https://{$sourcedomain}/{$username}", "publicKeyPem":"{$publickey}" {rdelim}, "tag":[], @@ -83,7 +83,7 @@ {if $type==='group'}{ldelim} "type":"PropertyValue", "name":"website", - "value":"\u003ca href=\"https://{$fqdn}/@{$username}\" target=\"_blank\" rel=\"nofollow noopener noreferrer me\"\u003e\u003cspan class=\"invisible\"\u003ehttps://\u003c/span\u003e\u003cspan class=\"\"\u003e{$fqdn}/@{$username}\u003c/span\u003e\u003cspan class=\"invisible\"\u003e\u003c/span\u003e\u003c/a\u003e" + "value":"\u003ca href=\"https://{$sourcedomain}/@{$username}\" target=\"_blank\" rel=\"nofollow noopener noreferrer me\"\u003e\u003cspan class=\"invisible\"\u003ehttps://\u003c/span\u003e\u003cspan class=\"\"\u003e{$fqdn}/@{$username}\u003c/span\u003e\u003cspan class=\"invisible\"\u003e\u003c/span\u003e\u003c/a\u003e" {rdelim}{/if} ], "endpoints":{ldelim} diff --git a/templates/federator/webfinger_acct.json b/templates/federator/webfinger_acct.json index 9d043d7..51547a7 100644 --- a/templates/federator/webfinger_acct.json +++ b/templates/federator/webfinger_acct.json @@ -1,10 +1,10 @@ {ldelim} - "subject": "acct:{$username}@{$domain}", + "subject": "acct:{$username}@{$sourcedomain}", "aliases": [ - "https://{$domain}/@{$username}" + "https://{$sourcedomain}/@{$username}" ], "links": [ - {ldelim}"rel": "self", "type": "application/activity+json", "href": "https://{$domain}/{$username}"{rdelim}, + {ldelim}"rel": "self", "type": "application/activity+json", "href": "https://{$domain}/@{$username}"{rdelim}, {if $type=='Group'} {ldelim}"rel": "http://webfinger.net/rel/profile-page", "type": "text/html", "href": "https://{$domain}/@{$username}/"{rdelim}, {/if}