bridgy-fed icon indicating copy to clipboard operation
bridgy-fed copied to clipboard

Handle Hubzilla `Like`s better

Open snarfed opened this issue 1 year ago • 1 comments

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 avatar Apr 07 '24 16:04 snarfed

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"
          }],
    }
  ],
}

snarfed avatar Apr 07 '24 16:04 snarfed

It's probably best to go by the "type" : "Like" here instead of prioritising one interpretation by available properties.

Tamschi avatar Oct 31 '24 10:10 Tamschi

Good point!

snarfed avatar Oct 31 '24 16:10 snarfed

Oh yeah, I remember now. The difficulty here is that mf2 itself is basically untyped, at least for all of the types we care about here. They're all h-entry, and they have like-of, repost-of, in-reply-to, etc properties, which we preserve and translate from the source AS2 regardless of its type.

So the brute force way to fix this is, for each AS2 type, strip all properties that don't apply to it. Eg for a Like, we'd strip inReplyTo. Doable, but it'd be verbose, error-prone, and kind of painful. Sigh.

snarfed avatar Nov 01 '24 02:11 snarfed

I took the minimal approach here and just removed in-reply-to from just likes, shares, etc.

snarfed avatar Nov 01 '24 20:11 snarfed