Skip to content

Commit 0152fc3

Browse files
committed
fix accept-header bug
1 parent acca7d0 commit 0152fc3

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ Where 'blog' is the path to the subdirectory at which your blog resides.
8484

8585
Project maintained on GitHub at [pfefferle/wordpress-activitypub](https://github.com/pfefferle/wordpress-activitypub).
8686

87+
### 0.8.3 ###
88+
89+
* fixed accept header bug
90+
8791
### 0.8.2 ###
8892

8993
* add all required accept header

activitypub.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: ActivityPub
44
* Plugin URI: https://github.com/pfefferle/wordpress-activitypub/
55
* Description: The ActivityPub protocol is a decentralized social networking protocol based upon the ActivityStreams 2.0 data format.
6-
* Version: 0.8.2
6+
* Version: 0.8.3
77
* Author: Matthias Pfefferle
88
* Author URI: https://notiz.blog/
99
* License: MIT
@@ -64,8 +64,8 @@ function init() {
6464
require_once dirname( __FILE__ ) . '/includes/class-debug.php';
6565
\Activitypub\Debug::init();
6666

67-
#require_once dirname( __FILE__ ) . '/includes/class-health-check.php';
68-
#\Activitypub\Health_Check::init();
67+
require_once dirname( __FILE__ ) . '/includes/class-health-check.php';
68+
\Activitypub\Health_Check::init();
6969
}
7070
add_action( 'plugins_loaded', '\Activitypub\init' );
7171

includes/class-activitypub.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public static function init() {
2424
}
2525

2626
\add_action( 'transition_post_status', array( '\Activitypub\Activitypub', 'schedule_post_activity' ), 10, 3 );
27+
28+
\add_action( 'trash_post', array( '\Activitypub\Activitypub', 'schedule_delete_activity' ), 10 );
2729
}
2830

2931
/**
@@ -60,22 +62,22 @@ public static function render_json_template( $template ) {
6062
stristr( $accept_header, 'application/activity+json' ) ||
6163
stristr( $accept_header, 'application/ld+json' )
6264
) {
63-
return $template;
65+
return $json_template;
6466
}
6567

6668
// accept header as an array
6769
$accept = \explode( ',', trim( $accept_header ) );
6870

6971
if (
70-
! \in_array( 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', $accept, true ) &&
71-
! \in_array( 'application/activity+json', $accept, true ) &&
72-
! \in_array( 'application/ld+json', $accept, true ) &&
73-
! \in_array( 'application/json', $accept, true )
72+
\in_array( 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', $accept, true ) ||
73+
\in_array( 'application/activity+json', $accept, true ) ||
74+
\in_array( 'application/ld+json', $accept, true ) ||
75+
\in_array( 'application/json', $accept, true )
7476
) {
75-
return $template;
77+
return $json_template;
7678
}
7779

78-
return $json_template;
80+
return $template;
7981
}
8082

8183
/**
@@ -113,9 +115,11 @@ public static function schedule_post_activity( $new_status, $old_status, $post )
113115
}
114116

115117
if ( 'publish' === $new_status && 'publish' !== $old_status ) {
116-
\wp_schedule_single_event( time() + \wp_rand( 0, 120 ), 'activitypub_send_post_activity', array( $post->ID ) );
118+
\wp_schedule_single_event( time(), 'activitypub_send_post_activity', array( $post->ID ) );
117119
} elseif ( 'publish' === $new_status ) {
118-
\wp_schedule_single_event( time() + \wp_rand( 0, 120 ), 'activitypub_send_update_activity', array( $post->ID ) );
120+
\wp_schedule_single_event( time(), 'activitypub_send_update_activity', array( $post->ID ) );
121+
} elseif ( 'trash' === $new_status ) {
122+
\wp_schedule_single_event( time(), 'activitypub_send_delete_activity', array( get_permalink( $post ) ) );
119123
}
120124
}
121125

languages/activitypub.pot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# This file is distributed under the MIT.
33
msgid ""
44
msgstr ""
5-
"Project-Id-Version: ActivityPub 0.8.2\n"
5+
"Project-Id-Version: ActivityPub 0.8.3\n"
66
"Report-Msgid-Bugs-To: "
77
"https://wordpress.org/support/plugin/wordpress-activitypub\n"
8-
"POT-Creation-Date: 2019-09-29 18:04:39+00:00\n"
8+
"POT-Creation-Date: 2019-09-30 05:58:15+00:00\n"
99
"MIME-Version: 1.0\n"
1010
"Content-Type: text/plain; charset=utf-8\n"
1111
"Content-Transfer-Encoding: 8bit\n"

readme.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ Where 'blog' is the path to the subdirectory at which your blog resides.
8484

8585
Project maintained on GitHub at [pfefferle/wordpress-activitypub](https://github.com/pfefferle/wordpress-activitypub).
8686

87+
= 0.8.3 =
88+
89+
* fixed accept header bug
90+
8791
= 0.8.2 =
8892

8993
* add all required accept header

0 commit comments

Comments
 (0)