Automattic / wordpress-activitypub

ActivityPub for WordPress
https://wordpress.org/plugins/activitypub/
MIT License
465 stars 67 forks source link

Remote Reply doesn't work #720

Open edent opened 3 months ago

edent commented 3 months ago

Quick summary

A recent update has added a "Reply on the Fediverse" button to comments which have been made on the Fediverse and syndicated to my blog.

Pressing the button launches a modal dialogue, but the actions it contains don't work.

Steps to reproduce

  1. View the comments at https://shkspr.mobi/blog/2024/04/fixing-broken-suspend-on-pop_os/#comments

  2. Clicking the reply button says "invalid"

    • Screenshot showing the error.
  3. View the comments on an older post at https://shkspr.mobi/blog/2023/09/why-is-it-so-hard-to-watch-foreign-tv-in-the-streaming-era/#div-comment-316308

  4. Clicking the reply button shows links which do not resolve to the comment.

What you expected to happen

Modal dialogue should have buttons that work and contain valid links.

What actually happened

Interacting with the modal did not allow me to reply on the fediverse.

Impact

One

Available workarounds?

No but the platform is still usable

Logs or notes

No response

edent commented 3 months ago

The first issue is caused by CSS. There is a text box there, but I couldn't see it because it uses invalid colours:

activitypub__dialog .activitypub-dialog__button-group input {
  background-color: var(--wp--preset--color--white);
  border: 1px solid var(--wp--preset--color--black);
  color: var(--wp--preset--color--black);
...
}

My theme doesn't have those --wp--preset variables.

Additionally, the modal doesn't respect the dark / light mode of the theme:

Pop up is light, background is dark.

I can raise a separate bug for that if necessary?

pfefferle commented 2 months ago

Is this an older comment? The code uses the source_id if there is one and only uses the internal ID otherwise... https://github.com/Automattic/wordpress-activitypub/blob/master/includes/rest/class-comment.php#L78

Screenshot 2024-04-08 at 10 38 01

I can raise a separate bug for that if necessary?

I would prefer a separate bug for that. That makes it easier to track the issue.

janboddez commented 2 months ago

I also saw some "curious" CSS being applied, turned out Gutenberg components have a lot of "hardcoded" (e.g., 13px, etc.) font sizes and so on. Also, the close button turns white on hover, rendering it nearly invisible against a light gray background. (Now wondering if a more minimal script, with minimal styling, might be the "better" choice, i.e., more respecting of theme styles.)

Guessing those variables aren't there (they do exist for me) because you're not using a block theme ...

Is this an older comment?

Looks like September '23. :-) Maybe "internal/non-pretty comment URLs" should only be used for "native" comments?

If no source_id can be determined, maybe not show a "Fediverse reply link"? (What happens if it isn't there? Does the plugin assume a "native" comment? Maybe it shouldn't ...)

edent commented 2 months ago

older comment

It is from 2023-09-19 20:36

If I do get_comment_link( $comment_id ) that shows the correct Fediverse link.

I'll open an issue for the CSS.

pfefferle commented 2 months ago

Ok, then it might be that. get_comment_link( $comment_id ) works, because it uses the source_url as a fallback (source_id might be introduced after the comment was posted)... I will add that also to the remote-reply feature...

pfefferle commented 2 months ago

Thanks for figuring that out @edent

edent commented 2 months ago

Here's what I've ended up with:

image

In class-comment.php

    public static function init() {
//      \add_filter( 'comment_reply_link', array( self::class, 'comment_reply_link' ), 10, 3 );
        \add_filter( 'comment_class', array( self::class, 'comment_class' ), 10, 3 );
        \add_filter( 'get_comment_link', array( self::class, 'remote_comment_link' ), 11, 3 );
//      \add_action( 'wp_enqueue_scripts', array( self::class, 'enqueue_scripts' ) );
    }

That stops all the weird stuff loading into my site.

Then, in my comments walker, I check to see if the comment URL is from my domain. If it isn't, I add a new reply link.

As I said, I appreciate what you're trying to do with this. But loading up a bunch of JS and CSS just isn't necessary for lots of sites and does degrade the user experience.

It would be really helpful if there was a simple toggle so that site owners could decide how they want to handle replies.