Automattic / wordpress-activitypub

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

Links of Hashtags in Apps aren't working correctly #399

Closed ichderfisch closed 1 year ago

ichderfisch commented 1 year ago

I recently noticed, if you click on a hashtag from an WP-ActivityPub post from within a Mastodon app, that these Link won't open the local feed of that hashtag, but instead interpret the hashtag as normal link to your Website: It opens the browser and opens the respective tag page.

Tested with the latest versions of Ivory and Icecubes on iOS Tested with the Mostodon App on Android. (Tusky works fine) Also, same behavior within Pixelfed webclient

This behavior is different from the Mastodon webclient, which opens the hashtag in local the /tags/ page.

I was currious what might trigger this behavior and found a clue in the mastodon documentation under microformats.

Under Additional classes it says:

These elements are attached by Mastodon for parsing metadata, but are not technically part of the Microformats vocabulary. mention Indicates that the link should be opened in-app with the associated mention data from the API.

hashtag Indicates that the link should be opened in-app with the associated hashtag data from the API.

The current implementaion of the plugin is using u-tag u-category, which are propably Microformats, but I couldn't find any information on them. Instead Microformats2 only lists p-category which might be related to the issue.

I currently don't have a Dev-Enviornment on my machine for testing, but looking at class-hashtag.php or class-shortcodes.php this might be a quick fix.

For comparison: Posting from Wordpress ActivityPub (JSON) Posting from Mastodon (JSON)

camielschoonens commented 1 year ago

I’ve noticed the same behavior and I also think the current hashtag implementation isn’t working with the Mastodon search or ‘follow hashtag’ usecase. E.g. Mastodon recognizes these hashtags differently from the ones created within a Mastodon client or webinterface.

pfefferle commented 1 year ago

It works fine when using the Mastodon-Webinterface, so it might be Client specific. I have no idea how they handle/treat hashtags differently, so if you have some links to any kind of documentation, I could try to work on that.

ichderfisch commented 1 year ago

I tested adding hashtag as an additional class next to u-tag u-category as mentioned above and in the mastodon documentation.

Just by adding it, it normalizes the behavior with Ivory (iOS), Mastodon App (Android), Magalodon (Android) and Pixelfed (of course on new postings only). Normalizes, means: They acted like the Mastodon-Webclient.

Sadly it doesn't change anything within Ice Cubes (iOS) as this is my main Client. But at this point I consider this a bug on their side, as everything else with hashtags looks fine for me. Checking the Ice Cubes repository didn't really help me, as I'm not familiar with Swift.

I also tried removing u-tag u-category, but the result was the same on all tested clients.

As this plugin is not a Mastodon Plugin, but an ActivityPub plugin I consider adding the hashtag-class as a feature request.

pfefferle commented 1 year ago

Good catch! Do you want to work on a Pull-Request @ichderfisch ?

ichderfisch commented 1 year ago

I would but as mentioned above I have no working dev machine at the moment. Also I'm not really sure what's the difference between class-hashtag.php or class-shortcodes.php implementation (one might be the Beta implementation you can choose in the settings, right?). If it's ok, I leave it to you.

ichderfisch commented 1 year ago

Sorry for reopening. I missed one change, so it's not working as intended for hashtags in posts.

https://github.com/Automattic/wordpress-activitypub/blob/fe07d5eb32fe00248d594f019bc70ab1ca63484c/includes/class-shortcodes.php#L49

hashtaghas also to be added at this place. I write a new pull request later.

pfefferle commented 1 year ago

no problem, thanks for reporting and providing a PR.