[PLUGIN][ActivityPub] Improve has/get checks

Fixes an issue where GtS posts were not being processed because of stripped @context
This commit is contained in:
tsmethurst 2022-10-22 17:47:14 +02:00
parent c3477ea56b
commit 2da614e344

View File

@ -144,7 +144,7 @@ class Note extends Model
// Figure the locale of the note when possible
$locale = null;
if (\is_array($type_note->get('@context'))) {
if ($type_note->has('@context') && \is_array($type_note->get('@context'))) {
$locale = array_column($type_note->get('@context'), '@language');
if ($locale !== []) {
$locale = $locale[0];
@ -241,7 +241,7 @@ class Note extends Model
$map['content'] = $type_note->get('content') ?? null;
$map['content_type'] = \is_null($map['content']) ? null : 'text/html';
$map['rendered'] = \is_null($map['content']) ? null : HTML::sanitize($map['content']);
if ($type_note->has('source')) {
if ($type_note->has('source') && !empty($type_note->get('source'))) {
$map['content_type'] = $type_note->get('source')['mediaType'] ?? null;
$map['content'] = $type_note->get('source')['content'];
if (\is_null($map['rendered'])) {