diff options
| author | Murtaza Sultani <sultani@data-quest.de> | 2025-07-23 12:00:18 +0200 |
|---|---|---|
| committer | Murtaza Sultani <sultani@data-quest.de> | 2025-07-23 12:00:18 +0200 |
| commit | b49f6aa3258bf3f629dfd951e60ac0e8a97f5468 (patch) | |
| tree | 7c1066249c7bdef8a027ef3b7b7786646f7ae892 | |
| parent | 77312fec6b2a4271e36582e155693c81be73b675 (diff) | |
Resolve "Forum 3/OpenGraph: Leere Objekte sollen nicht angezeigt werden"
Closes #5744
Merge request studip/studip!4378
| -rw-r--r-- | lib/classes/JsonApi/Schemas/Forum/ForumPosting.php | 2 | ||||
| -rw-r--r-- | lib/models/Forum/ForumPosting.php | 5 | ||||
| -rw-r--r-- | resources/vue/components/LinksPreview.vue | 6 |
3 files changed, 6 insertions, 7 deletions
diff --git a/lib/classes/JsonApi/Schemas/Forum/ForumPosting.php b/lib/classes/JsonApi/Schemas/Forum/ForumPosting.php index 5506f55..a03e75d 100644 --- a/lib/classes/JsonApi/Schemas/Forum/ForumPosting.php +++ b/lib/classes/JsonApi/Schemas/Forum/ForumPosting.php @@ -46,7 +46,7 @@ class ForumPosting extends SchemaProvider 'title' => $og['title'], 'description' => $og['description'], 'image' => $og['image'], - ], $posting->getOpenGraphURLs()->toArray()) + ], $posting->getOpenGraphURLs()) ]; } diff --git a/lib/models/Forum/ForumPosting.php b/lib/models/Forum/ForumPosting.php index 11be45d..b442046 100644 --- a/lib/models/Forum/ForumPosting.php +++ b/lib/models/Forum/ForumPosting.php @@ -2,7 +2,6 @@ namespace Forum; use OpenGraph; -use OpenGraphURLCollection; use SimpleORMap; use Forum\Service\PostingNotification; use User; @@ -102,10 +101,10 @@ class ForumPosting extends SimpleORMap ); } - public function getOpenGraphURLs(): OpenGraphURLCollection + public function getOpenGraphURLs(): array { $content = preg_replace("~<blockquote(.*?)>(.*)</blockquote>~si", '', $this['content']); - return OpenGraph::extract($content); + return array_filter(OpenGraph::extract($content)->toArray(), fn($og) => $og['is_opengraph']); } public function onCreate(): void diff --git a/resources/vue/components/LinksPreview.vue b/resources/vue/components/LinksPreview.vue index 7946002..67988ad 100644 --- a/resources/vue/components/LinksPreview.vue +++ b/resources/vue/components/LinksPreview.vue @@ -8,11 +8,11 @@ const props = defineProps({ type: Array, required: true } -}) +}); -const currentIndex = ref(0) +const currentIndex = ref(0); -const currentLink = computed(() => props.links[currentIndex.value]) +const currentLink = computed(() => props.links[currentIndex.value]); </script> <template> |
