PluginProbe
ActivityPub / 3.2.4
ActivityPub v3.2.4
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
← All changes | includes/class-debug.php +16 -27 2.1.03.2.4 View file →
@@ -3,8 +3,10 @@
3 3
4 4 use WP_DEBUG;
5 5 use WP_DEBUG_LOG;
6 6
7 +use function Activitypub\object_to_uri;
8 +
7 9 /**
8 10 * ActivityPub Debug Class
9 11 *
10 12 * @author Matthias Pfefferle
@@ -15,43 +17,30 @@
15 17 */
16 18 public static function init() {
17 19 if ( WP_DEBUG_LOG ) {
18 20 \add_action( 'activitypub_safe_remote_post_response', array( self::class, 'log_remote_post_responses' ), 10, 4 );
21 + \add_action( 'activitypub_inbox', array( self::class, 'log_inbox' ), 10, 4 );
19 22 }
20 - if ( is_user_logged_in() ) {
21 - \add_filter( 'comment_text', array( self::class, 'show_comment_source' ), 10, 2 );
22 - }
23 23 }
24 24
25 - public static function show_comment_source( $comment_text, $comment ) {
26 - $was_sent = \get_comment_meta( $comment->comment_ID, 'activitypub_status', true );
27 -
28 - if ( $was_sent ) {
29 - // translators: %s is the federation state of the comment
30 - $comment_text .= '<p><small>' . sprintf( \__( 'Activitypub → (%s)', 'activitypub' ), $was_sent ) . '</small></p>';
31 - }
32 -
33 - $was_received = \get_comment_meta( $comment->comment_ID, 'protocol', true );
34 -
35 - if ( 'activitypub' === $was_received ) {
36 - $comment_text .= '<p><small>' . \__( '← ActivityPub', 'activitypub' ) . '</small></p>';
37 - }
38 -
39 - return $comment_text;
40 - }
41 -
42 25 // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed, VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
43 26 public static function log_remote_post_responses( $response, $url, $body, $user_id ) {
44 27 // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log, WordPress.PHP.DevelopmentFunctions.error_log_print_r
45 - \error_log( "Request to: {$url} with response: " . \print_r( $response, true ) );
28 + \error_log( "[OUTBOX] Request to: {$url} with Response: " . \print_r( $response, true ) );
46 29 }
47 30
48 - public static function write_log( $log ) {
49 - if ( \is_array( $log ) || \is_object( $log ) ) {
31 + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed, VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
32 + public static function log_inbox( $data, $user_id, $type, $activity ) {
33 + $type = strtolower( $type );
34 +
35 + if ( 'delete' !== $type ) {
36 + $url = object_to_uri( $data['actor'] );
50 37 // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log, WordPress.PHP.DevelopmentFunctions.error_log_print_r
51 - \error_log( \print_r( $log, true ) );
52 - } else {
53 - // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
54 - \error_log( $log );
38 + \error_log( "[INBOX] Request From: {$url} with Activity: " . \print_r( $data, true ) );
55 39 }
40 + }
41 +
42 + public static function write_log( $log ) {
43 + // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log, WordPress.PHP.DevelopmentFunctions.error_log_print_r
44 + \error_log( \print_r( $log, true ) );
56 45 }
57 46 }