Parse Mastodon under profile links

Created on 21 November 2022, about 2 years ago
Updated 10 November 2023, about 1 year ago

Problem/Motivation

Currently, with the issues on Twitter and many members have moved off to different platforms. One such platform is Mastodon.

As the profiles section exits today, it cannot derive what those Mastodon URLs look like as social links, so it outputs the URL as a raw URL.

User Story:

"As a Drupal.org member, I would like to be able to link my Mastodon profile on my Drupal profile, have that link correctly attribute as me, and appear with the name of the community as the link title."

An example of a current community managed Drupal Mastodon Instance is Drupal.community: https://drupal.community

Steps to reproduce

As a Mastodon user, add your profile link as a Social links item.

Proposed resolution

Update the parsing regex pattern to support mastodon URL's.

Suggested support:

  • mastodon.social
  • drupal.community

Remaining tasks

  • Investigate next steps/viability
  • Develop solution
  • Test
  • Deploy
โœจ Feature request
Status

Needs work

Version

3.0

Component

User interface

Created by

๐Ÿ‡จ๐Ÿ‡ฆCanada mikeohara Moncton, NB

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States markdorison

    A GitHub team member shared a bit on Mastodon about how they are validating hosts. Sharing that here just in case it is helpful:

    We make a NodeInfo request to non-obvious hosts to check server metadata.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States markdorison

    I was trying to determine if any processing is already done on field_social_links. It seems like there must be as if you enter a URL for a known site like Twitter, GitHub, or LinkedIn URL, it renders with the site name as the link text as opposed to just a raw URL:

    <a href="http://www.linkedin.com/in/username" rel="nofollow">LinkedIn</a>

    I was searching for that logic here and in bluecheese, but I came up short.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States markdorison

    Secondarily, allow the user to request the rel="me" attribute be included with the link.

    Instead of a follow-on, maybe this could be an incremental step for Mastodon links. Could we safely add rel=me to all social links?

  • ๐Ÿ‡ธ๐Ÿ‡ฎSlovenia useernamee Ljubljana

    This is a feature I'm looking forward to. I tried just adding a link to my bio, but rel=me tag just gets filtered out.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States markdorison

    @useernamee A version of this went live in โœจ Add XFN rel-me to external links on profile page Fixed , but it only works on links added to the "Social Links" field. Check out my user account for an example.

  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium BramDriesen Belgium ๐Ÿ‡ง๐Ÿ‡ช

    There is a list of regex patterns used to parse the links on your user profile (drupal.org/static-files/sites/default/settings.php).

    See โœจ Parse Flickr under social links Fixed for an example where a regex pattern was added.

    Here is the (untested) regex pattern for Mastodon. @drumm could add this (not sure who else has access to the bitbucket).

    '%^https?://mastodon\.social/@[^/]+/?%' => 'Mastodon',
    '%^https?://drupal\.community/@[^/]+/?%' => 'Mastodon (Drupal)',
    

    This should match users and posts:
    https://MASTODON_URL/@USER
    https://MASTODON_URL/@USER/POSTID

    Given the decentralised nature, I think it only makes sense to support those two.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium BramDriesen Belgium ๐Ÿ‡ง๐Ÿ‡ช

    Fixing a typo in the title and renaming it. Updating IS as well to reflect what this ticket is about.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium BramDriesen Belgium ๐Ÿ‡ง๐Ÿ‡ช
  • Status changed to Fixed about 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States drumm NY, US

    Thanks, I made one small change - Mastodon (drupal.community) to match the siteโ€™s branding.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States neclimdul Houston, TX

    I'm not sure I understand what got fixed. My Mastodon link looks the same.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium BramDriesen Belgium ๐Ÿ‡ง๐Ÿ‡ช

    It's parsing fine for me :) I guess it wasn't deployed or your profile was cached.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium BramDriesen Belgium ๐Ÿ‡ง๐Ÿ‡ช

    @neclimdul I checked your profile, you have a mastodon URL from https://hachyderm.io which is not added as a pattern.

    If you add "https://drupal.community/@neclimdul" it will go to your community profile there and show a link to your main profile. Or this one https://mastodon.social/@neclimdul@hachyderm.io which will redirect to hachyderm.io

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada mikeohara Moncton, NB

    Mine is also not updated - but it is a drupal.community url

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium BramDriesen Belgium ๐Ÿ‡ง๐Ÿ‡ช

    I checked your profile and the URL should match the regex. Can you maybe check in your profile if there is no extra space or something in the URL field, and maybe save your profile to see if that busts the cache (if it's a cache issue)

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands ekes

    > maybe save your profile to see if that busts the cache (if it's a cache issue)

    I found resaving my profile updated it.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States neclimdul Houston, TX

    Doesn't sound like we really addressed this in the decentralized way mastadon actually works.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium BramDriesen Belgium ๐Ÿ‡ง๐Ÿ‡ช

    @neclimdul Like discussed in #8 we only added the main Mastodon and Drupal URL to the regex pattern.

    Given the decentralised way, it's next to impossible to build a regex for that without a form of API integration to verify what server a URL might belong to (not even sure there is an API for listing all servers). Not to forget there also is the self-hosted option which probably isn't listed on the servers listing either.

    Stackexchange poses the same issue, there we also only support StackOverflow and Drupal Answers, and none of the many other subsites.

    I think for the scope of this issue we've addressed it. And there also is a workaround that redirects you to your main profile as shown in #15. The only real way of fixing this without adding a few hundred regex patterns would be to make the URL field also have a "Title/Label" field that you can fill in your own, but then you end up with a bunch of different writings for the same thing, which in the end might also be misleading.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States drumm NY, US

    I did not bulk update existing accounts with matching URLs, so the label will update as people save their user account.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States neclimdul Houston, TX

    The new scope you defined was but I don't feel like the original intent was. There are lots of inclusivity reasons and just general choice reasons someone would choose a server outside the to provided options.

    I actually appreciate the effort a lot and the motion on this, just think we can do better.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada mikeohara Moncton, NB

    I appreciate the effort, but I am also inclined to agree with the others.

    Mastodon provides methods to identify the community and properly attribute, I think it would make more sense to build that detection scheme.

    I think the best way to approach it would be two-fold:

    Do a regex pattern to see if the entered URL contains the @ symbol as part of the last URL segment. If so, do a query against the URL to get information on the Mastodon instance to validate it. See #4

    I think for the most part, it makes more sense to just render the link with a Generic โ€œMastodonโ€ link title. This avoids issues with how to visualize the disparate instances names and configurations.

    We can, still, choose to specially treat the Drupal Community Mastodon instance the same way with the link text as โ€œMastodon (drupal.community)โ€ to call it out specifically. This would also be useful if a user were to have more than one Mastodon link in their profile.

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada mikeohara Moncton, NB
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States drumm NY, US

    https://git.drupalcode.org/project/drupalorg/-/blob/7.x-3.x/drupalorg/dr... is where the titles of links are set. We would need:

    • A way to detect what is a link to a Mastodon site.
    • That will almost certainly require making an HTTP request, and HTTP requests are slow. The result needs to be cached for each site.
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States drumm NY, US

    Permalink for the above code, since its location will change https://git.drupalcode.org/project/drupalorg/-/blob/aafab131276211ba4f0b...

    Its the field_social_links processing within drupalorg_entity_presave()

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia dpi Perth, Australia

    Ideally we wouldnt stick to the behaviour of Mastodon, and live by the rules of the protocol that it lives by: ActivityPub.

    We should be able to accept handles instead of profile links. ie dpi@mastodon.social. (Note @ prefix is a Mastodon convention and must be stripped).

    Links would bind detection to the Mastodon platform.

    If you want to verify a profile exists without making tings too complicated, while following the rules of federation:

Production build 0.71.5 2024