From 13d5aadc97b51311c0e9abb9c3290ddd57ff4782 Mon Sep 17 00:00:00 2001 From: Daniel Griesser Date: Wed, 27 Nov 2024 20:35:53 +0100 Subject: [PATCH] Add docs and safeguard --- src/Event/LinkSharedEvent.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Event/LinkSharedEvent.php b/src/Event/LinkSharedEvent.php index 1b966e1..4dff067 100644 --- a/src/Event/LinkSharedEvent.php +++ b/src/Event/LinkSharedEvent.php @@ -62,8 +62,18 @@ public function process(): void } } + /** + * Fetch a Discord message + * + * @param string $url The Discord message URL + * @return string The message content + */ private function fetchDiscordMessage(string $url): string { + if (!preg_match('#^https://discord\.com/channels/\d+/\d+/\d+$#', $url)) { + return $url; + } + $parts = explode('/', $url); $channelId = $parts[5]; $messageId = $parts[6];