Merge branch 'trunk' into improve/actor-mode

This commit is contained in:
Matthias Pfefferle 2024-10-02 18:48:00 +02:00 committed by GitHub
commit dbdfaaf47c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 83 additions and 24 deletions

View file

@ -144,7 +144,6 @@ class Activity_Dispatcher {
// build the update
$activity = new Activity();
$activity->set_id( $user->get_url() . '#update' );
$activity->set_type( 'Update' );
$activity->set_actor( $user->get_url() );
$activity->set_object( $user->get_url() );

View file

@ -65,33 +65,11 @@ class Post extends Base {
$post = $this->wp_object;
$object = parent::to_object();
$published = \strtotime( $post->post_date_gmt );
$object->set_published( \gmdate( 'Y-m-d\TH:i:s\Z', $published ) );
$updated = \strtotime( $post->post_modified_gmt );
if ( $updated > $published ) {
$object->set_updated( \gmdate( 'Y-m-d\TH:i:s\Z', $updated ) );
}
$object->set_content_map(
array(
$this->get_locale() => $this->get_content(),
)
);
$object->set_to(
array(
'https://www.w3.org/ns/activitystreams#Public',
$this->get_actor_object()->get_followers(),
)
);
$content_warning = get_content_warning( $post );
if ( ! empty( $content_warning ) ) {
$object->set_sensitive( true );
$object->set_summary( $content_warning );
$object->set_summary_map( null );
}
return $object;
@ -934,6 +912,88 @@ class Post extends Base {
return null;
}
/**
* Returns the recipient of the post.
*
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-to
*
* @return array The recipient URLs of the post.
*/
public function get_to() {
return array(
'https://www.w3.org/ns/activitystreams#Public',
$this->get_actor_object()->get_followers(),
);
}
/**
* Returns the published date of the post.
*
* @return string The published date of the post.
*/
public function get_published() {
$published = \strtotime( $this->wp_object->post_date_gmt );
return \gmdate( 'Y-m-d\TH:i:s\Z', $published );
}
/**
* Returns the updated date of the post.
*
* @return string|null The updated date of the post.
*/
public function get_updated() {
$published = \strtotime( $this->wp_object->post_date_gmt );
$updated = \strtotime( $this->wp_object->post_modified_gmt );
if ( $updated > $published ) {
return \gmdate( 'Y-m-d\TH:i:s\Z', $updated );
}
return null;
}
/**
* Returns the content map for the post.
*
* @return array The content map for the post.
*/
public function get_content_map() {
return array(
$this->get_locale() => $this->get_content(),
);
}
/**
* Returns the name map for the post.
*
* @return array The name map for the post.
*/
public function get_name_map() {
if ( ! $this->get_name() ) {
return null;
}
return array(
$this->get_locale() => $this->get_name(),
);
}
/**
* Returns the summary map for the post.
*
* @return array The summary map for the post.
*/
public function get_summary_map() {
if ( ! $this->get_summary() ) {
return null;
}
return array(
$this->get_locale() => $this->get_summary(),
);
}
/**
* Transform Embed blocks to block level link.
*