[PLUGIN][ActivityPub] Improve flexibility of Type layer, accomodate more elaborate understanding of Group Announces after FEP-2100 development

This commit is contained in:
2022-03-28 20:58:48 +01:00
parent 7305a725cb
commit be33c20614
8 changed files with 64 additions and 51 deletions

View File

@@ -166,6 +166,7 @@ class Note extends Model
'reply_to' => $reply_to = $handleInReplyTo($type_note),
'modified' => new DateTime(),
'type' => match ($type_note->get('type')) {
'Article' => 'article',
'Page' => 'page',
default => 'note'
},
@@ -361,7 +362,7 @@ class Note extends Model
* @throws InvalidArgumentException
* @throws ServerException
*/
public static function toJson(mixed $object, int $options = \JSON_UNESCAPED_SLASHES): string
public static function toType(mixed $object): AbstractObject
{
if ($object::class !== GSNote::class) {
throw new InvalidArgumentException('First argument type must be a Note.');
@@ -469,6 +470,6 @@ class Note extends Model
$type = self::jsonToType($attr);
Event::handle('ActivityPubAddActivityStreamsTwoData', [$type->get('type'), &$type]);
return $type->toJson($options);
return $type;
}
}