ckolderup / postmarks

a single-user bookmarking website designed to live on the Fediverse

Home Page:https://postmarks.glitch.me

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ActivityPub hash tag collection needs to be added to end of the content node as well

jeffsikes opened this issue · comments

Ran into an interesting scenario while testing other changes.

While Postmarks is sending over the tag collection in the ActivityPub outbox message correctly, because it isn't included in the content node of the message, the tags are indexable and searchable, but the end user can't see them identified anywhere.

https://elk.zone/mastodon.social/@ladyteruki/111200798408906624

This user was confused as to why my posts were visible to her. Turns out she was following the tvshows hashtag, so that's why - but to her, there was no indication why they were showing up!

Who knew this was a thing? You basically have duplicate the hashtags into the content section manually prior to placing in the outbox. This is because most clients aren't pulling the list of hashtags from the tag collection - they are expecting them to be listed in the content!

In addition to being included in the content section, they also need to be linked and given some specific properties to be handled within Mastodon and other platforms that expect it. (nofollow, noreferrer, noopener, _blank)

Here's the required logic to really get a handle on it:

On create new or update existing AP message

  • Extract all hashtags found inline in the description into an array
  • Compare to the tag collection array
  • Merge the two into one unique array (compare lowercase, but include however the first version appears which might be camelcase)
  • So, it could be that some hashtags appeared in the description that didn't appear in the tag collection or vice versa.
  • Display only the tags that aren't in the description at the bottom of the note in a new paragraph (important).
  • Add any new tags to the tag collection.
  • Linkify all hashtags found in the note.

You'd really need to do the same for any comments as well...but let's start here!

I'd like to give this one a go. It might be next weekend before I could complete it.

(facepalm) funny story here-- I used to do this, then Eugen mentioned that the Mastodon web interface as of 4.2.0 would include these hashtags at the bottom of the post and I got excited about the opportunity to delete code and totally forgot that all the native apps would have their own treatments. Despite the fact that 90% of my Mastodon usage is on Mona these days.

Making progress, letting you know I didn't ghost this request 👻

Code is still pretty gross, but it's taking shape. I have some family stuff this weekend so probably won't be able to work on these changes until late Sunday evening.

I did see the original code mentioned, and wanted to add some additional "humans never follow the rules" logic. Will definitely adhere the patterns I'm seeing in the mentioned code before adding any of this to a pull request.

https://codepen.io/box464/full/MWZLYZZ

@ckolderup In this scenario, what's your expected behavior in regards to both the Postmarks entry and the ActivityPub message.

Url: https://thedogapi.com/
Title: The Dog API
Description
This free #API allows you to pull images and data about various breeds of dogs. #DogsOfMastodon

Categories
#FreeAPI #Pets

Would Postmarks add "#API" and "#DogsOfMastodon" as additional tag categories inside Postmarks?
Or would it ignore them since the user didn't explicitly add them to the categories.

Right now, i'm ignoring them, because surely the user had a reason for doing this on purpose! Perhaps they don't want a #DogsOfMastodon category but want to reach a broader audience when it's posted on the fediverse.

I think this is what Friendica is trying to get at with it's Categories and Tags separation as well. Categories are for the user's own classification of content, Tags are for helping other users find your content. Friendica doesn't include Categories in the outgoing message, but to me that would be unexpected and a bit confusing to a general fediverse user of Postmarks.

If the message is being broadcast, then I merge all hashtags, add them to the description, and also include them in the ActivityPub outbox tag collection. This ensures visibility of all tags, plus that they are all indexed as well by adding them to the tag collection.

So, the Outbox message would have this:

The Dog API
This free #API allows you to pull images and data about various breeds of dogs. #DogsOfMastodon

#FreeAPI #Pets

And the Outbox tags would be:

API, DogsOfMastodon, FreeAPI, Pets

Postmarks would store the data as entered, however, and not add new categories from the tags in the description:

This free #API allows you to pull images and data about various breeds of dogs. #DogsOfMastodon

With categories of:

FreeAPI, Pets

Thanks!

Hmm, interesting! My gut feeling is that we shouldn't do anything with detecting the contents of the description when sending tags. In my usage the description field is frequently populated with whatever the opengraph data held-- I wouldn't want my tagging structure to potentially get polluted without any way to control it.

What I could see, and this would probably be a separate issue/PR, would be to detect hashtags in the description field and offer them as one-click "suggestions" in the tag area below; that would be a client-side thing and fairly compact/straightforward to implement (though I also have some dream of a server-side tag suggestions endpoint that we'd also hit after getting the URL, based on noticing things like "every other bookmark with this domain name has the same three tags")

does that make sense? I think it makes sense in Mastodon to be a bit more clever/opinionated about things like that, since people expect a microblogging tool to have just one entry field, but social bookmarking is a platform that is kinda built around structured data/strict form inputs, and people feel strongly about their workflows in those.

Ah, understood. So in that case, note that an AP message being delivered would have a mix of some things being tagged and others not for the moment, like this, until the suggestion UI is implemented.

Always a new line, categories appended at the end of the content and linkified, and ONLY the appended categories are added to the AP tag collection. Which is...exactly what you had before and I completely over-thought it. 🤦🏼

Fine with that, just wanted to make sure I'm going down the right path!

The Dog API
This free #API allows you to pull images and data about various breeds of dogs. #DogsOfMastodon

#FreeAPI #Pets

yep, no worries! It's good to think through this stuff, and maybe we should change that eventually, if people really are getting usage out of putting hashtags in the description and we get a bunch of issues filed. But that's just my gut feeling for now in terms of making this a platform that feels like a bookmarking site rather than another microblog.