[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,12 +143,17 @@ class Note extends Model
} }
// Figure the locale of the note when possible // Figure the locale of the note when possible
$locale = null;
if (\is_array($type_note->get('@context'))) {
$locale = array_column($type_note->get('@context'), '@language'); $locale = array_column($type_note->get('@context'), '@language');
if ($locale !== []) { if ($locale !== []) {
$locale = $locale[0]; $locale = $locale[0];
if ($locale === 'und') { if ($locale === 'und') {
$locale = null; $locale = null;
} }
} else {
$locale = null;
}
} }
$map = [ $map = [
@ -178,7 +183,7 @@ class Note extends Model
} else { } else {
// Either Followers-only or Direct // Either Followers-only or Direct
if ($type_note->get('type') === 'ChatMessage' // Is DM explicitly? 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; $map['scope'] = VisibilityScope::MESSAGE;
} else { // Then is collection } else { // Then is collection
$map['scope'] = VisibilityScope::COLLECTION; $map['scope'] = VisibilityScope::COLLECTION;