diff --git a/AUTHORS b/AUTHORS index d6c8f3f6f00..a15a5cd061e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -619,6 +619,7 @@ - szaimen - tbartenstein - tbelau666 + - TechnicalSuwako - tgrant - timm2k - tux-rampage diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php index 4a1c446ac6c..d28451dd401 100644 --- a/lib/private/Accounts/AccountManager.php +++ b/lib/private/Accounts/AccountManager.php @@ -729,7 +729,7 @@ class AccountManager implements IAccountManager { try { // try the public account lookup API of mastodon - $response = $client->get("https://{$instance}/api/v1/accounts/lookup?acct={$username}@{$instance}"); + $response = $client->get("https://{$instance}/.well-known/webfinger?resource=acct:{$username}@{$instance}"); // should be a json response with account information $data = $response->getBody(); if (is_resource($data)) { @@ -738,7 +738,7 @@ class AccountManager implements IAccountManager { $decoded = json_decode($data, true); // ensure the username is the same the user passed // in this case we can assume this is a valid fediverse server and account - if (!is_array($decoded) || ($decoded['username'] ?? '') !== $username) { + if (!is_array($decoded) || ($decoded['subject'] ?? '') !== "acct:{$username}@{$instance}") { throw new InvalidArgumentException(); } } catch (InvalidArgumentException) { diff --git a/tests/lib/Accounts/AccountManagerTest.php b/tests/lib/Accounts/AccountManagerTest.php index 2d3daf942b9..23a2cd7d996 100644 --- a/tests/lib/Accounts/AccountManagerTest.php +++ b/tests/lib/Accounts/AccountManagerTest.php @@ -833,12 +833,12 @@ class AccountManagerTest extends TestCase { ->willReturn($serverResponse); $client->expects(self::once()) ->method('get') - ->with('https://example.com/api/v1/accounts/lookup?acct=foo@example.com') + ->with('https://example.com/.well-known/webfinger?resource=acct:foo@example.com') ->willReturn($response); } else { $client->expects(self::once()) ->method('get') - ->with('https://example.com/api/v1/accounts/lookup?acct=foo@example.com') + ->with('https://example.com/.well-known/webfinger?resource=acct:foo@example.com') ->willThrowException(new \Exception('404')); }