Skip to content
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

[Bug]: mentions should not show up as attached links from Mastodon #5452

Open
5 tasks done
wakest opened this issue Feb 23, 2025 · 2 comments
Open
5 tasks done

[Bug]: mentions should not show up as attached links from Mastodon #5452

wakest opened this issue Feb 23, 2025 · 2 comments
Labels
area: federation support federation via activitypub bug Something isn't working

Comments

@wakest
Copy link

wakest commented Feb 23, 2025

Requirements

  • Is this a bug report? For questions or discussions use https://lemmy.ml/c/lemmy_support
  • Did you check to see if this issue already exists?
  • Is this only a single bug? Do not put multiple bugs in one issue.
  • Do you agree to follow the rules in our Code of Conduct?
  • Is this a backend issue? Use the lemmy-ui repo for UI / frontend issues.

Summary

when mentioning a user in a reply, the mention shows up as an attached link from the Mastodon side

Image link to the comment shown in the screenshot

Steps to Reproduce

  1. mention a fediverse account in a lemmy reply
  2. load the post into a mastodon account

Technical Details

n/a

Version

BE: 0.19.9

Lemmy Instance URL

lemmy.ml

@wakest wakest added the bug Something isn't working label Feb 23, 2025
@Nutomic Nutomic added the area: federation support federation via activitypub label Feb 25, 2025
@Nutomic
Copy link
Member

Nutomic commented Feb 26, 2025

Dont know why this is happening, the Activitypub JSON looks just like the one sent from a Mastodon instance.

curl -H 'accept: application/activity+json' https://lemmy.ml/comment/16895096 | jq:

{
    "content":"<p>hat tip to <a href=\"https://aus.social/users/shlee\" rel=\"nofollow\">@[email protected]</a></p>\n",
    "tag":[
        {
            "href":"https://lemmy.ml/u/wakest",
            "name":"@[email protected]",
            "type":"Mention"
        },
        {
            "href":"https://aus.social/users/shlee",
            "name":"@[email protected]",
            "type":"Mention"
        }
    ],
    ...
}

curl -H 'accept: application/activity+json' https://mastodon.archive.org/@textfiles/113958335475068302 | jq:

{
    "content":"<p><span class=\"h-card\" translate=\"no\"><a href=\"https://mastodon.libre-entreprise.com/@lutindiscret\" class=\"u-url mention\">@<span>lutindiscret</span></a></span> <span class=\"h-card\" translate=\"no\"><a href=\"https://mastodon.social/@LemmyDev\" class=\"u-url mention\">@<span>LemmyDev</span></a></span> This is the absolute first time I&#39;ve ever heard of Lemmy, and the 16th year I&#39;ve heard of Reddit.</p>",
    "tag":[
        {
            "type":"Mention",
            "href":"https://mastodon.libre-entreprise.com/users/lutindiscret",
            "name":"@[email protected]"
        },
        {
            "type":"Mention",
            "href":"https://mastodon.social/users/LemmyDev",
            "name":"@[email protected]"
        }
    ],
    ...
}

So the only difference seems to be that Mastodon includes some additional HTML tags in content, but there is nothing wrong being sent by Lemmy. As this is a problem with the Mastodon UI you should report it to the Mastodon repo.

@flamingo-cant-draw
Copy link
Collaborator

The u-url class does seem to be what Mastodon uses to avoid link previews for mentions. It would also be pretty easy for us to add those tags, something like this in link_rule.rs:

let content = node.collect_text();
if MENTIONS_REGEX.is_match(&content) {
  attrs.push("class", "u-url".to_string());
  attrs.push("class", "mention".to_string()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: federation support federation via activitypub bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants