Skip to content

Commit ec24523

Browse files
committed
only disable comments for replies from the fediverse
1 parent 742fbda commit ec24523

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

includes/class-comment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public static function comment_reply_link( $link, $args, $comment ) {
5454
public static function are_comments_allowed( $comment ) {
5555
$comment = \get_comment( $comment );
5656

57-
if ( self::is_local( $comment ) ) {
57+
if ( ! self::was_received( $comment ) ) {
5858
return true;
5959
}
6060

includes/class-debug.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,32 @@ class Debug {
1414
* Initialize the class, registering WordPress hooks
1515
*/
1616
public static function init() {
17-
if ( WP_DEBUG && WP_DEBUG_LOG ) {
17+
if ( WP_DEBUG_LOG ) {
1818
\add_action( 'activitypub_safe_remote_post_response', array( self::class, 'log_remote_post_responses' ), 10, 4 );
1919
}
20+
if ( is_user_logged_in() ) {
21+
\add_filter( 'comment_text', array( self::class, 'show_comment_source' ), 10, 2 );
22+
}
23+
}
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;
2040
}
2141

42+
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed, VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
2243
public static function log_remote_post_responses( $response, $url, $body, $user_id ) {
2344
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log, WordPress.PHP.DevelopmentFunctions.error_log_print_r
2445
\error_log( "Request to: {$url} with response: " . \print_r( $response, true ) );

0 commit comments

Comments
 (0)