[ENTITY] Rename 'getFrom' to 'getBy'
This commit is contained in:
@@ -65,24 +65,24 @@ class Note extends Model
|
||||
*/
|
||||
public static function fromJson(string|AbstractObject $json, array $options = []): GSNote
|
||||
{
|
||||
$source = $options['source'];
|
||||
$source = $options['source'];
|
||||
$actor_uri = $options['actor_uri'];
|
||||
$actor_id = $options['actor_id'];
|
||||
$type_note = is_string($json) ? self::jsonToType($json) : $json;
|
||||
$actor_id = $options['actor_id'];
|
||||
$type_note = \is_string($json) ? self::jsonToType($json) : $json;
|
||||
|
||||
if (is_null($actor_uri) || $actor_uri !== $type_note->get('attributedTo')) {
|
||||
if (\is_null($actor_uri) || $actor_uri !== $type_note->get('attributedTo')) {
|
||||
$actor_id = ActivityPub::getActorByUri($type_note->get('attributedTo'))->getId();
|
||||
}
|
||||
$map = [
|
||||
'is_local' => false,
|
||||
'created' => new DateTime($type_note->get('published') ?? 'now'),
|
||||
'content' => $type_note->get('content') ?? null,
|
||||
'is_local' => false,
|
||||
'created' => new DateTime($type_note->get('published') ?? 'now'),
|
||||
'content' => $type_note->get('content') ?? null,
|
||||
'content_type' => 'text/html',
|
||||
'language_id' => $type_note->get('contentLang') ?? null,
|
||||
'url' => $type_note->get('url') ?? $type_note->get('id'),
|
||||
'actor_id' => $actor_id,
|
||||
'modified' => new DateTime(),
|
||||
'source' => $source,
|
||||
'language_id' => $type_note->get('contentLang') ?? null,
|
||||
'url' => $type_note->get('url') ?? $type_note->get('id'),
|
||||
'actor_id' => $actor_id,
|
||||
'modified' => new DateTime(),
|
||||
'source' => $source,
|
||||
];
|
||||
if ($map['content'] !== null) {
|
||||
$mentions = [];
|
||||
@@ -98,8 +98,8 @@ class Note extends Model
|
||||
|
||||
$obj = new GSNote();
|
||||
|
||||
if (!is_null($map['language_id'])) {
|
||||
$map['language_id'] = Language::getFromLocale($map['language_id'])->getId();
|
||||
if (!\is_null($map['language_id'])) {
|
||||
$map['language_id'] = Language::getByLocale($map['language_id'])->getId();
|
||||
} else {
|
||||
$map['language_id'] = null;
|
||||
}
|
||||
@@ -128,13 +128,13 @@ class Note extends Model
|
||||
}
|
||||
|
||||
$attr = [
|
||||
'@context' => 'https://www.w3.org/ns/activitystreams',
|
||||
'id' => Router::url('note_view', ['id' => $object->getId()], Router::ABSOLUTE_URL),
|
||||
'published' => $object->getCreated()->format(DateTimeInterface::RFC3339),
|
||||
'@context' => 'https://www.w3.org/ns/activitystreams',
|
||||
'id' => Router::url('note_view', ['id' => $object->getId()], Router::ABSOLUTE_URL),
|
||||
'published' => $object->getCreated()->format(DateTimeInterface::RFC3339),
|
||||
'attributedTo' => $object->getActor()->getUri(Router::ABSOLUTE_URL),
|
||||
'to' => ['https://www.w3.org/ns/activitystreams#Public'], // TODO: implement proper scope address
|
||||
'cc' => ['https://www.w3.org/ns/activitystreams#Public'],
|
||||
'content' => $object->getRendered(),
|
||||
'to' => ['https://www.w3.org/ns/activitystreams#Public'], // TODO: implement proper scope address
|
||||
'cc' => ['https://www.w3.org/ns/activitystreams#Public'],
|
||||
'content' => $object->getRendered(),
|
||||
//'tag' => $tags
|
||||
];
|
||||
|
||||
@@ -142,4 +142,4 @@ class Note extends Model
|
||||
Event::handle('ActivityPubAddActivityStreamsTwoData', [$type->get('type'), &$type]);
|
||||
return $type->toJson($options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user