use post_meta instead of post_content

This commit is contained in:
Matthias Pfefferle 2023-07-06 16:10:48 +02:00
parent 96c1e92151
commit d4f5ad8ec1
2 changed files with 19 additions and 5 deletions

View file

@ -100,6 +100,18 @@ class Followers {
)
);
register_post_meta(
self::POST_TYPE,
'activitypub_actor_json',
array(
'type' => 'string',
'single' => true,
'sanitize_callback' => function( $value ) {
return sanitize_text_field( $value );
},
)
);
do_action( 'activitypub_after_register_post_type' );
}
@ -254,13 +266,14 @@ class Followers {
if ( isset( $object['user_id'] ) ) {
unset( $object['user_id'] );
unset( $object['@context'] );
}
unset( $object['@context'] );
$user = Users::get_by_id( $user_id );
// get inbox
$inbox = $follower->get_inbox();
$inbox = $follower->get_shared_inbox();
// send "Accept" activity
$activity = new Activity();

View file

@ -111,7 +111,6 @@ class Follower extends Actor {
'post_type' => Followers::POST_TYPE,
'post_name' => esc_url_raw( $this->get_id() ),
'post_excerpt' => esc_html( $this->get_summary() ) ? $this->get_summary() : '',
'post_content' => esc_sql( $this->to_json() ),
'post_status' => 'publish',
'meta_input' => $this->get_post_meta_input(),
);
@ -150,7 +149,8 @@ class Follower extends Actor {
*/
protected function get_post_meta_input() {
$meta_input = array();
$meta_input['activitypub_inbox'] = esc_url_raw( $this->get_shared_inbox() );
$meta_input['activitypub_inbox'] = $this->get_shared_inbox();
$meta_input['activitypub_actor_json'] = $this->to_json();
return $meta_input;
}
@ -197,7 +197,8 @@ class Follower extends Actor {
* @return array Activitypub\Model\Follower
*/
public static function init_from_cpt( $post ) {
$object = self::init_from_json( $post->post_content );
$actor_json = get_post_meta( $post->ID, 'activitypub_actor_json', true );
$object = self::init_from_json( $actor_json );
$object->set__id( $post->ID );
$object->set_id( $post->guid );
$object->set_published( gmdate( 'Y-m-d H:i:s', strtotime( $post->post_published ) ) );