Skip to content

Interactions: Don't show likes and reposts for comments #1735

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 2, 2025
Merged

Conversation

obenland
Copy link
Member

@obenland obenland commented May 27, 2025

Fixes #1498.

Proposed changes:

  • Saves parent comment id when a reaction to a comment is received.
  • Adds check for parent comment id being 0 when querying for reactions.
  • Updates reaction notification email body
  • Adds unit test.

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

  • Publish a new post.
  • Have someone reply to that post ; their reply will appear as a comment on your site.
  • Reply to their comment from your site ; your reply will be federated as expected.
  • Now have someone Like or Repost this reply.
  • Make sure it does not get added to the reactions in the Reaction block.

After

image

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Added - for new features
  • Changed - for changes in existing functionality
  • Deprecated - for soon-to-be removed features
  • Removed - for now removed features
  • Fixed - for any bug fixes
  • Security - in case of vulnerabilities

Message

Likes and Reposts for comments to a post are no longer attributed to the post itself.

@obenland obenland marked this pull request as ready for review May 27, 2025 19:10
@obenland obenland requested review from pfefferle and Copilot and removed request for pfefferle May 27, 2025 19:10
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes issue #1498 by preventing the collection of likes and reposts for comments. The changes include updates to the reaction processing logic in the Interactions class and added unit tests to verify that likes and reposts for comments are not collected.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/includes/collection/class-test-interactions.php Added new test (test_add_like_to_comment) and updated references to the WP_UnitTestCase class
includes/collection/class-interactions.php Refactored add_reaction logic to check for valid post IDs and prevent reactions tied to comments
Comments suppressed due to low confidence (1)

includes/collection/class-interactions.php:95

  • [nitpick] The inline comment 'Not a reply to a post.' could be clarified to indicate that reactions to comments are intentionally not processed. Consider updating the comment to explicitly reference that likes and reposts for comments are ignored.
if ( ! $comment_post_id || is_post_disabled( $comment_post_id ) ) {

@pfefferle
Copy link
Member

Why shouldn't we collect them? I think this is more an issue of how we show the reactions for the output as a storing/collecting issue.

Even if we merge this PR, I think we also have to improve the output by ignoring all reactions that have a comment_parent, to prevent that we do not have the same issue when working on comment-reactions.

@obenland
Copy link
Member Author

Yeah that's a good point, maybe we should start there. We should probably also check wording in the notification email

@obenland obenland changed the title Interactions: Don't collect likes and reposts for comments Interactions: Don't show likes and reposts for comments May 28, 2025
@github-actions github-actions bot added [Block] Reactions [Feature] Reactions [Feature] REST API [Focus] Editor Changes to the ActivityPub experience in the block editor labels May 28, 2025
@obenland obenland requested a review from pfefferle May 28, 2025 18:10
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Comment on lines +101 to +109
$parent_comment = \get_comment( $comment->comment_parent );
$notify_message = \sprintf(
/* translators: 1: Comment type, 2: Post title, 3: Parent comment author */
\html_entity_decode( esc_html__( 'New %1$s on your post “%2$s” in reply to %3$s’s comment.', 'activitypub' ) ),
\esc_html( $comment_type['singular'] ),
\esc_html( $post->post_title ),
\esc_html( $parent_comment->comment_author )
) . PHP_EOL . PHP_EOL;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we simply skip the else mail, because we do not show them yet?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're no longer shown in the frontend but they still get saved and are visible in the Comments list. They'll probably also require moderation (although I've not tested that). I'm not sure if it would be more or less confusing to notify about them, tbh. What do you think?

@obenland obenland merged commit 2e197e9 into trunk Jun 2, 2025
11 checks passed
@obenland obenland deleted the fix/1498 branch June 2, 2025 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reactions: Likes and Reposts of comments are stored for main post
3 participants