<?php
/**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
use Friendica\BaseModule;
use Friendica\Core\System;
use Friendica\Model\Contact;
+use Friendica\Network\HTTPException\NotFoundException;
/**
* Redirects to another URL based on the parameter 'addr'
*/
class Acctlink extends BaseModule
{
- public static function content(array $parameters = [])
+ protected function rawContent(array $request = [])
{
$addr = trim($_GET['addr'] ?? '');
+ if (!$addr) {
+ throw new NotFoundException('Parameter "addr" is missing or empty');
+ }
- if ($addr) {
- $url = Contact::getByURL($addr)['url'] ?? '';
- if ($url) {
- System::externalRedirect($url['url']);
- exit();
- }
+ $contact = Contact::getByURL($addr, null, ['url']) ?? '';
+ if (!$contact) {
+ throw new NotFoundException('Contact not found');
}
+
+ System::externalRedirect($contact['url']);
}
}