From 45344c80d186b08fff54244fb2b6a5f7338d6997 Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Wed, 23 Mar 2022 13:16:24 +0000 Subject: [PATCH] [PLUGIN][ActivityPub][Model][Note] Fix @language handling --- plugins/ActivityPub/Util/Model/Note.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/plugins/ActivityPub/Util/Model/Note.php b/plugins/ActivityPub/Util/Model/Note.php index 18392359ec..9ec59a99a5 100644 --- a/plugins/ActivityPub/Util/Model/Note.php +++ b/plugins/ActivityPub/Util/Model/Note.php @@ -143,10 +143,15 @@ class Note extends Model } // Figure the locale of the note when possible - $locale = array_column($type_note->get('@context'), '@language'); - if ($locale !== []) { - $locale = $locale[0]; - if ($locale === 'und') { + $locale = null; + if (\is_array($type_note->get('@context'))) { + $locale = array_column($type_note->get('@context'), '@language'); + if ($locale !== []) { + $locale = $locale[0]; + if ($locale === 'und') { + $locale = null; + } + } else { $locale = null; } } @@ -178,7 +183,7 @@ class Note extends Model } else { // Either Followers-only or Direct if ($type_note->get('type') === 'ChatMessage' // Is DM explicitly? - || (empty($type_note->get('cc')))) { // Only has TO targets + || ($type_note->get('cc') === [])) { // Only has TO targets $map['scope'] = VisibilityScope::MESSAGE; } else { // Then is collection $map['scope'] = VisibilityScope::COLLECTION;