[PLUGIN][ActivityPub][Model][Note] Fix @language handling

This commit is contained in:
Diogo Peralta Cordeiro 2022-03-23 13:16:24 +00:00
parent 7eddbd343d
commit 45344c80d1
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0

View File

@ -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;