diff --git a/src/Endpoint.php b/src/Endpoint.php index 0686690..71d363a 100644 --- a/src/Endpoint.php +++ b/src/Endpoint.php @@ -6,4 +6,29 @@ use Lewisdale\Webmentions\Gateways\WebmentionGatewayInterface; class Endpoint { private readonly WebmentionGatewayInterface $gateway; + + public function validateUrl(string $url) : bool { + return !!filter_var($url, FILTER_VALIDATE_URL); + } + + public function receiveWebmention(string $source, string $target) : void + { + // Validate that both source and target are actual domains + if (!$this->validateUrl($source) || !$this->validateUrl($target)) + { + return; + } + + // Validate that the webmention target is a domain I care about + if (!str_contains($target, "https://lewisdale.dev")) { + // Should throw a Bad Request error + return; + } + + // Parse content from the source + + // Store the webmention + + // Send the appropriate response + } } \ No newline at end of file diff --git a/tests/EndpointTest.php b/tests/EndpointTest.php new file mode 100644 index 0000000..778ef9f --- /dev/null +++ b/tests/EndpointTest.php @@ -0,0 +1,16 @@ +assertEquals($expected, $endpoint->validateUrl($url), "Expected $url"); + } +} +?> \ No newline at end of file