snarfed / bridgy-fed

🌉 A bridge between decentralized social network protocols
https://fed.brid.gy
Creative Commons Zero v1.0 Universal
566 stars 30 forks source link

Handle Hubzilla `Like`s better #941

Open snarfed opened 6 months ago

snarfed commented 6 months ago

We don't currently translate Hubzilla Like activities to mf2 HTML very well. They have both object and inReplyTo, which arguably they shouldn't, but probably isn't technically wrong. We convert them to a combined reply and like as mf2, which webmention receivers like the WordPress plugin (cc @dshanske) interpret as a reply over a like. (Which is probably right!)

For AS2 Likes, we should prioritize the like and remove the reply when converting to AS1 and/or mf2.

Example: https://authorship.studio/activity/143b8b1d-0bf8-46ab-b0bf-065e689120cd . Pruned AS2:

{
   "type" : "Like"
   "id" : "https://authorship.studio/activity/143b8b1d-0bf8-46ab-b0bf-065e689120cd",
   "actor" : "https://authorship.studio/channel/scott",
   "inReplyTo" : "https://fed.brid.gy/r/https://snarfed.org/2024-04-07_52743",
   "cc" : ["https://authorship.studio/followers/scott"],
   "object" : {
      "type" : "Note",
      "id" : "https://fed.brid.gy/r/https://snarfed.org/2024-04-07_52743",
      "actor" : "https://fed.brid.gy/snarfed.org",
      "url" : "https://fed.brid.gy/r/https://snarfed.org/2024-04-07_52743"
      "attributedTo" : "https://fed.brid.gy/snarfed.org",
      "content" : "One of our cats purrs so loudly that it’s a running joke in our family. It makes her fur vibrate. We have to turn the TV volume up when she sits with us. Once, she was in another room, and I heard her purr through the wall. No joke.",
      "published" : "2024-04-07T16:07:49Z",
      "to" : ["https://www.w3.org/ns/activitystreams#Public"],
   },
   "published" : "2024-04-07T16:31:35Z",
   "to" : ["https://www.w3.org/ns/activitystreams#Public"],
}
snarfed commented 6 months ago

HTML from https://ap.brid.gy/convert/web/https://authorship.studio/activity/143b8b1d-0bf8-46ab-b0bf-065e689120cd :

<article class="h-entry">
  <span class="p-uid">https://ap.brid.gy/convert/web/https://authorship.studio/activity/143b8b1d-0bf8-46ab-b0bf-065e689120cd</span>
  <time class="dt-published" datetime="2024-04-07T16:31:35+00:00">2024-04-07T16:31:35+00:00</time>
  <span class="p-author h-card">
    <data class="p-uid" value="https://authorship.studio/channel/scott"></data>
    <a class="p-name u-url" href="https://authorship.studio/channel/scott">Scott M. Stolz</a>
    <span class="p-nickname">scott</span>
    <img class="u-photo" src="https://authorship.studio/photo/profile/l/4?rev=1701617226" alt="" />
<img class="u-photo" src="https://authorship.studio/photo/72d44b5e-3c8e-414f-965b-70f2c0da81ec-7" alt="" />
  </span>

  <div class="e-content p-name">
  Likes <a href="https://snarfed.org/2024-04-07_52743">a post</a> by   <span class="h-card">
    <data class="p-uid" value="https://snarfed.org/"></data>
    <a class="u-url" href="https://snarfed.org/">snarfed.org</a>
      </span>
One of our cats purrs so loudly that it’s a running joke in our family. It makes her fur vibrate. We have to turn the TV volume up when she sits with us. Once, she was in another room, and I heard her purr through the wall. No joke.
  </div>

  <a class="u-in-reply-to" href="https://snarfed.org/2024-04-07_52743"></a>
<article class="u-like-of h-cite">
  <span class="p-uid">https://snarfed.org/2024-04-07_52743</span>
  <time class="dt-published" datetime="2024-04-07T16:07:49+00:00">2024-04-07T16:07:49+00:00</time>

  <a title="snarfed.org/2024-04-07_52743" class="u-url" href="https://snarfed.org/2024-04-07_52743">snarfed.org/2024-04-07_527...</a>
  <div class="e-content p-name">
  One of our cats purrs so loudly that it’s a running joke in our family. It makes her fur vibrate. We have to turn the TV volume up when she sits with us. Once, she was in another room, and I heard her purr through the wall. No joke.
  </div>
</article>

Parsed mf2 (pruned), https://pin13.net/mf2/?url=https://ap.brid.gy/convert/web/https://authorship.studio/activity/143b8b1d-0bf8-46ab-b0bf-065e689120cd :

{
  "items": [
    {
      "type": ["h-entry"],
      "properties": {
        "uid": ["https://ap.brid.gy/convert/web/https://authorship.studio/activity/143b8b1d-0bf8-46ab-b0bf-065e689120cd"],
        "name": ["Likes a post by snarfed.org One of our cats purrs so loudly that it\u2019s a running joke in our family. It makes her fur vibrate. We have to turn the TV volume up when she sits with us. Once, she was in another room, and I heard her purr through the wall. No joke."],
        "in-reply-to": ["https://snarfed.org/2024-04-07_52743"],
        "published": ["2024-04-07T16:31:35+00:00"],
        "content": [{
            "html": "Likes <a href=\"https://snarfed.org/2024-04-07_52743\">a post</a> by   <span class=\"h-card\">\n  <data class=\"p-uid\" value=\"https://snarfed.org/\"></data>\n  <a class=\"u-url\" href=\"https://snarfed.org/\">snarfed.org</a>\n  \n  \n  </span>\nOne of our cats purrs so loudly that it&#x2019;s a running joke in our family. It makes her fur vibrate. We have to turn the TV volume up when she sits with us. Once, she was in another room, and I heard her purr through the wall. No joke.",
            "value": "Likes a post by snarfed.org One of our cats purrs so loudly that it\u2019s a running joke in our family. It makes her fur vibrate. We have to turn the TV volume up when she sits with us. Once, she was in another room, and I heard her purr through the wall. No joke."
          }
        ],
        "like-of": [{
            "type": ["h-cite"],
            "properties": {
              "uid": ["https://snarfed.org/2024-04-07_52743"],
              "name": ["One of our cats purrs so loudly that it\u2019s a running joke in our family. It makes her fur vibrate. We have to turn the TV volume up when she sits with us. Once, she was in another room, and I heard her purr through the wall. No joke."],
              "url": ["https://snarfed.org/2024-04-07_52743"],
              "published": ["2024-04-07T16:07:49+00:00"],
              "content": [{
                  "html": "One of our cats purrs so loudly that it&#x2019;s a running joke in our family. It makes her fur vibrate. We have to turn the TV volume up when she sits with us. Once, she was in another room, and I heard her purr through the wall. No joke.",
                  "value": "One of our cats purrs so loudly that it\u2019s a running joke in our family. It makes her fur vibrate. We have to turn the TV volume up when she sits with us. Once, she was in another room, and I heard her purr through the wall. No joke."
                }]
            },
            "value": "https://snarfed.org/2024-04-07_52743"
          }
        ]
      },
        "author": [{
            "type": ["h-card"],
            "properties": {
              "uid": ["https://authorship.studio/channel/scott"],
              "name": ["Scott M. Stolz"],
              "nickname": ["scott"],
              "url": ["https://authorship.studio/channel/scott"],
              "photo": [{
                  "value": "https://authorship.studio/photo/profile/l/4?rev=1701617226",
                }]
            },
            "value": "Scott M. Stolz"
          }],
    }
  ],
}