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

Add support for publishing mentions #493

Closed
gRegorLove opened this issue Apr 25, 2023 · 15 comments
Closed

Add support for publishing mentions #493

gRegorLove opened this issue Apr 25, 2023 · 15 comments

Comments

@gRegorLove
Copy link

I'd like to be able to publish a note to start a conversation with someone (vs replying to a post in a thread). Also handy for tagging someone in a post in an existing thread.

I tried a couple ways a while back but they didn't show up as notifications for the person I mentioned:

https://gregorlove.com/2022/11/hello-from-my-website/ - linked the @-@
https://gregorlove.com/2022/11/hello-again-from-my-website/ - no @-@ link

@snarfed
Copy link
Owner

snarfed commented Apr 25, 2023

Yes! Great point, and BF already does the other direction, AP => wm (background in eg #270), so it should absolutely do this too.

@snarfed
Copy link
Owner

snarfed commented May 5, 2023

More motivation for this: the emerging standard way to do groups on the fediverse is evidently accounts that automatically repost you when you mention them, eg https://venera.social/profile/activitypubblueskybridge

@snarfed
Copy link
Owner

snarfed commented May 5, 2023

I've been trying to get this to work with a Friendica group, which works by reposting your posts that mention it, but no luck so far. Here are all the different AS2 Mention tags I've tried:

    "tag": [{
      "type": "Mention",
      "id": "https://venera.social/profile/activitypubblueskybridge",
      "name": "AP-AT-Bridge Group"
    }]
    "tag": [{
      "type": "Mention",
      "id": "https://venera.social/profile/activitypubblueskybridge",
      "url": "https://venera.social/profile/activitypubblueskybridge",
      "name": "@activitypubblueskybridge@venera.social"
    }]
    "tag": [{
      "type": "Mention",
      "id": "https://venera.social/profile/activitypubblueskybridge",
      "url": "https://venera.social/profile/activitypubblueskybridge",
      "href": "https://venera.social/profile/activitypubblueskybridge",
      "name": "@activitypubblueskybridge@venera.social"
    }]

...all with cc <a href=\"https://venera.social/profile/activitypubblueskybridge\">@activitypubblueskybridge@venera.social</a> in content and with this audience targeting:

  "to": [
    "https://www.w3.org/ns/activitystreams#Public",
    "https://venera.social/profile/activitypubblueskybridge"
  ]

🤷 🤷 🤷

@snarfed
Copy link
Owner

snarfed commented Jun 1, 2023

Mastodon docs for mentions: https://docs.joinmastodon.org/spec/activitypub/#Mention

I guess I could try some of the above ^ examples with cc instead of to.

@snarfed
Copy link
Owner

snarfed commented Oct 13, 2023

Tried again with cc, delivered this to https://indieweb.social/users/snarfed/inbox just now, it mentions and cc's https://indieweb.social/users/snarfed , but still no luck, that account didn't get a notification.

Next step is to hope @manton can help, he evidently has outgoing fediverse mentions working in micro.blog!

{
  "id": "https://fed.brid.gy/r/https://snarfed.org/2023-10-12_snarfed-foo-bar-mas-to#bridgy-fed-update-2023-10-12T23:44:49.320885+00:00",
  "actor": "https://fed.brid.gy/snarfed.org",
  "@context": "https://www.w3.org/ns/activitystreams",
  "type": "Update",
  "object": {
    "updated": "2023-10-12T23:44:49.320885+00:00",
    "published": "2023-10-12T16:35:43-07:00",
    "content": "hi again to <a href=\"https://indieweb.social/users/snarfed\">@snarfed@indieweb.social</a> <a class=\"u-in-reply-to\" href=\"https://mas.to/@snarfed/109668310494520038\"> </a>",
    "url": "https://fed.brid.gy/r/https://snarfed.org/2023-10-12_snarfed-foo-bar-mas-to",
    "id": "https://fed.brid.gy/r/https://snarfed.org/2023-10-12_snarfed-foo-bar-mas-to",
    "type": "Note",
    "attributedTo": "https://fed.brid.gy/snarfed.org",
    "inReplyTo": "https://mas.to/users/snarfed/statuses/109668310494520038",
    "tag": [
      {
        "type": "Mention",
        "href": "https://indieweb.social/users/snarfed",
        "name": "@snarfed@indieweb.social"
      },
      {
        "type": "Mention",
        "href": "https://mas.to/users/snarfed"
      }
    ],
    "cc": [
      "https://indieweb.social/users/snarfed",
      "https://mas.to/users/snarfed",
      "https://www.w3.org/ns/activitystreams#Public",
      "https://mas.to/users/snarfed/followers"
    ],
    "to": [
      "https://www.w3.org/ns/activitystreams#Public"
    ]
  },
  "to": [
    "https://www.w3.org/ns/activitystreams#Public"
  ],
  "cc": [
    "https://indieweb.social/users/snarfed",
    "https://mas.to/users/snarfed",
    "https://www.w3.org/ns/activitystreams#Public",
    "https://mas.to/users/snarfed/followers"
  ],
}

@manton
Copy link

manton commented Oct 13, 2023

I just tested this in Micro.blog and it's working. One thing I noticed in your example above, the type = "Update". Why not "Create"? Maybe Mastodon is confused by that.

Here's the JSON for sending an @-mention from the test account @mantondroid@micro.blog to @manton@indieweb.social:

{
  "@context": "https://www.w3.org/ns/activitystreams",
  "type": "Create",
  "id": "https://micro.blog/activitypub/ids/19f285fd5759d3170732",
  "actor": "https://micro.blog/activitypub/mantondroid",
  "object": {
    "id": "https://micro.blog/activitypub/posts/24869106",
    "type": "Note",
    "url": "https://mantondroid.micro.blog/2023/10/13/testing-a-mention.html",
    "published": "2023-10-13T13:49:49+00:00",
    "attributedTo": "https://micro.blog/activitypub/mantondroid",
    "tag": [
      {
        "type": "Mention",
        "href": "https://indieweb.social/users/manton",
        "name": "@manton@indieweb.social"
      }
    ],
    "content": "<p>Testing a mention to Mastodon. Hi <a href=\"https://indieweb.social/users/manton\">@manton@indieweb.social</a>. \ud83d\udc4b</p>",
    "attachment": [],
    "to": [
      "https://www.w3.org/ns/activitystreams#Public"
    ],
    "cc": [
      "https://micro.blog/activitypub/mantondroid/followers",
      "https://indieweb.social/users/manton"
    ]
  }
}

@manton
Copy link

manton commented Oct 13, 2023

This is also a new post, not a reply to anything specific, so I don't include inReplyTo. Pretty similar for replies to a post, though. I think only inReplyTo is different.

@manton
Copy link

manton commented Oct 13, 2023

Not sure if this matters, but why have the empty link username for the second Mastodon user that is mentioned?

snarfed added a commit that referenced this issue Oct 13, 2023
@snarfed
Copy link
Owner

snarfed commented Oct 13, 2023

Woo, this is working! I honestly don't know what fixed it, but I won't argue. Docs are deploying now. Thank you @manton!

(Re your q's, I'd tried with Create too, and the empty second link was just a quirk of my site, unrelated to BF.)

@snarfed snarfed closed this as completed Oct 13, 2023
@snarfed
Copy link
Owner

snarfed commented Oct 13, 2023

One silver lining of Mastodon's support here is that the AS2 Mention tag href isn't absolutely required to be the AP actor id, eg https://indieweb.social/users/snarfed. Mastodon also accepts the frontend URL that users see, eg https://indieweb.social/@snarfed.

@snarfed
Copy link
Owner

snarfed commented Oct 20, 2023

Reopening, this isn't working with Friendica groups, eg https://venera.social/profile/activitypubblueskybridge , which repost (Announce) your posts when you mention them. Sent this (trimmed here) to https://venera.social/inbox/activitypubblueskybridge a bit ago but it didn't work.

{
  "@context": "https://www.w3.org/ns/activitystreams",
  "type": "Create",
  "id": "https://fed.brid.gy/r/https://snarfed.org/2023-10-20_51173#bridgy-fed-create",
  "actor": "https://fed.brid.gy/snarfed.org",
  "published": "2023-10-20T19:27:57.093008+00:00",
  "object": {
    "type": "Note",
    "id": "https://fed.brid.gy/r/https://snarfed.org/2023-10-20_51173",
    "url": "https://fed.brid.gy/r/https://snarfed.org/2023-10-20_51173",
    "published": "2023-10-20T12:01:27-07:00",
    "content": "... cc <a href=\"https://venera.social/profile/activitypubblueskybridge\">@activitypubblueskybridge@venera.social</a>.</p>",
    "attributedTo": "https://fed.brid.gy/snarfed.org",
    "tag": [
      {
        "type": "Mention",
        "name": "@activitypubblueskybridge@venera.social",
        "href": "https://venera.social/profile/activitypubblueskybridge"
      }
    ],
    "cc": ["https://venera.social/profile/activitypubblueskybridge"],
    "to": ["https://www.w3.org/ns/activitystreams#Public"]
    "...",
  },
  "to": ["https://www.w3.org/ns/activitystreams#Public"]
}

@snarfed snarfed reopened this Oct 20, 2023
@snarfed
Copy link
Owner

snarfed commented Oct 20, 2023

Here's the most recent post to that group, also trimmed a bit. I don't see an obvious difference yet: the Mention tags are identical, and the HTML mention links in content are a bit different, but their hrefs are also identical.

You evidently have to follow the group before you can post to it, which I did a while back, but maybe that follow didn't take?

{
  "id": "https://indieweb.social/users/tchambers/statuses/111048163021099999",
  "type": "Note",
  "summary": null,
  "published": "2023-09-11T19:28:15Z",
  "url": "https://indieweb.social/@tchambers/111048163021099999",
  "attributedTo": "https://indieweb.social/users/tchambers",
  "to": ["https://www.w3.org/ns/activitystreams#Public"],
  "cc": [
    "https://indieweb.social/users/tchambers/followers",
    "https://venera.social/profile/activitypubblueskybridge",
    "https://venera.social/followers/activitypubblueskybridge",
    "https://fed.brid.gy/snarfed.org"
  ],
  "conversation": "tag:indieweb.social,2023-09-11:objectId=76434671:objectType=Conversation",
  "content": "<p>important work from <span class=\"h-card\" translate=\"no\"><a href=\"https://fed.brid.gy/r/https://snarfed.org/\" class=\"u-url mention\">@<span>snarfed.org</span></a></span> as part of his AP to BlueSky/AT bridge... comparing Nostr, AP, and AT Protocols.... Chime in if anything here needs tweaking or fixing...  cc: <span class=\"h-card\" translate=\"no\"><a href=\"https://venera.social/profile/activitypubblueskybridge\" class=\"u-url mention\">@<span>activitypubblueskybridge</span></a></span></p>",
  "tag": [
    {
      "type": "Mention",
      "href": "https://fed.brid.gy/snarfed.org",
      "name": "@snarfed.org@snarfed.org"
    },
    {
      "type": "Mention",
      "href": "https://venera.social/profile/activitypubblueskybridge",
      "name": "@activitypubblueskybridge@venera.social"
    }
  ],
  "..."
}

@snarfed
Copy link
Owner

snarfed commented Oct 20, 2023

@snarfed
Copy link
Owner

snarfed commented Oct 24, 2023

Hmm, that group actually did end up reposting my mention post after all, just a while later, at 21:36:12 UTC, or at least I'm guessing based on this HTML in the repost:

<span class="commented" style="display: none;">2023-10-22 02:16:53</span>
<span class="received" style="display: none;">2023-10-20 21:36:12</span>
<span class="created" style="display: none;">2023-10-20 19:01:27</span>

Not sure why the delay. But maybe this is working and I can close again after all.

@snarfed
Copy link
Owner

snarfed commented Jan 18, 2024

Following up here. Did some tests, turns out Mastodon's incoming mention handling is pretty relaxed.

So I'm relaxing BF's mention detection in #760.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants