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

Rewrite Jetpack CDN image (URLs) since some instances don't load them

Open snarfed opened this issue 1 year ago • 15 comments

Posted a photo just now and it's not working. Forgot to include u-photo first, but then I tried attaching it to the img and then the surrounding a and updated both times. No luck, shows a black rectangle with "Not available."

https://indieweb.social/@[email protected]/109984562159038607, BF log: https://fed.brid.gy/log?start_time=1678231601&key=https://snarfed.org/2023-03-07_49461&module=

If I click on it, it links to the image on my site ok though. The a and img are fetting federated inside content, but Mastodon should be stripping the img, so I doubt that's a problem.

image

Also older post with photos aren't working either: https://indieweb.social/@[email protected]/109729051822644849 , https://indieweb.social/@[email protected]/109677037763348328

image image

snarfed avatar Mar 07 '23 23:03 snarfed

The plot thickens. Evidently u-featured works ok, this is just a u-photo issue? Examples from www.jvt.me:

snarfed avatar Mar 14 '23 19:03 snarfed

Another broken u-photo example, from gregorlove.com, 2/26:

snarfed avatar Mar 14 '23 22:03 snarfed

They're also broken on other instances, so it's not an indieweb.social thing. eg:

snarfed avatar Mar 14 '23 22:03 snarfed

Oddly gregorlove.com has two successful u-photo posts since then:

snarfed avatar Mar 14 '23 22:03 snarfed

Pruned down JSON AS2 objects from five of these examples. The second and third bad ones make sense, they have no image and their attachments aren't images. The first one though, my original example, looks identical to the two good ones except it's missing name. Guess I'll try adding that? Not holding my breath.

bad, my original example:

{
    "type": "Note",
    "id": "https://fed.brid.gy/r/https://snarfed.org/2023-03-07_49461",
    "image": {
      "type": "Image",
      "url": "https://i0.wp.com/snarfed.org/w/wp-content/uploads/2023/03/PXL_20230307_163518349-1.PANO_-scaled.jpg?ssl=1"
    },
    "attachment": [{
        "type": "Image",
        "url": "https://i0.wp.com/snarfed.org/w/wp-content/uploads/2023/03/PXL_20230307_163518349-1.PANO_-scaled.jpg?ssl=1"
    }],
}

bad:

{
    "type": "Note",
    "id": "https://fed.brid.gy/r/https://www.jvt.me/mf2/2023/03/lerm1/",
    "attachment": [{
        "type": "Note",
        "url": "https://twitter.com/juhuachai/status/1631458755480023041",
        "content": "\u201coptimal posting times\u201d \u201cstagger your posts\u201d if you see me you see me. it\u2019s in gods hands and i am not praying"
    }]
}

bad:

{
    "type": "Note",
    "id": "https://fed.brid.gy/r/https://gregorlove.com/2023/02/after-following-on-instagram/",
    "attachment": [{
        "type": "Note",
        "url": "https://manenough.com/podcast/",
        "name": "The Man Enough Podcast"
    }]
}

good:

{
    "type": "Note",
    "id": "https://fed.brid.gy/r/https://gregorlove.com/2023/03/i-usually-tend-to/",
    "image": {
      "type": "Image",
      "url": "https://gregorlove.com/site/assets/files/6398/pxl_20230304_234257890_portrait.2000x0-is.jpg",
      "name": "recent selfie"
    },
    "attachment": [{
        "type": "Image",
        "url": "https://gregorlove.com/site/assets/files/6398/pxl_20230304_234257890_portrait.2000x0-is.jpg",
        "name": "recent selfie"
    }]
}

good:

{
    "type": "Note",
    "id": "https://fed.brid.gy/r/https://gregorlove.com/2023/03/foggy-downtown/",
    "image": {
      "type": "Image",
      "url": "https://gregorlove.com/site/assets/files/6404/pxl_20230311_224353429.1500x0.jpg",
      "name": "Downtown San Diego with fog obscuring the tops of some buildings"
    },
    "attachment": [{
        "type": "Image",
        "url": "https://gregorlove.com/site/assets/files/6404/pxl_20230311_224353429.1500x0.jpg",
        "name": "Downtown San Diego with fog obscuring the tops of some buildings"
    }]
}

snarfed avatar Mar 14 '23 23:03 snarfed

Added name to the original post's image and attachment. No dice. 🤷 https://indieweb.social/@[email protected]/109984562159038607

snarfed avatar Mar 15 '23 00:03 snarfed

Oh man. I switched the image URLs from the Jetpack CDN to my site directly (snarfed.org), and that fixed it. Ugh, so that CDN is blocking Mastodon, or it's otherwise failing to fetch from it? Oh, sheesh, looks like it was just indieweb.social, the image wasn't broken on other instances, eg https://tech.lgbt/@[email protected]/109984559730340646.

I bet Reclaim Hosting is the culprit here. Ugh. https://github.com/snarfed/bridgy/issues/885

snarfed avatar Mar 15 '23 00:03 snarfed

Also, the two other bad example posts were probably unrelated, I suspect Mastodon expected their attachments were images and choked on them?

snarfed avatar Mar 15 '23 00:03 snarfed

Confirmed. I removed the attachment from one of them, and the broken image went away. https://indieweb.social/@[email protected]/109934332056357887

snarfed avatar Mar 15 '23 00:03 snarfed

Oh and re https://github.com/snarfed/bridgy-fed/issues/439#issuecomment-1469040563, looks like indieweb.social is hosted on https://masto.host/, not Reclaim.

snarfed avatar Mar 15 '23 00:03 snarfed

Looks like we started adding attachment for Mastodon, initially discovered in https://github.com/snarfed/bridgy-fed/issues/33#issuecomment-440965618. Evidently they still use it:

https://github.com/mastodon/mastodon/blob/65669d3c5719e72000bf26849d0ee1eaec1f9d1b/app/lib/activitypub/activity/create.rb#L255-L282

snarfed avatar Mar 15 '23 22:03 snarfed

One hacky fix here would be to auto detect WP Jetpack CDN URLs and rewrite them to the original URL. ~Unfortunate to need to do that only because Reclaim is blocking Jetpack's CDN though. (Along with what seems like half the internet.)~ (Reclaim is blocking half the internet, but evidently not the root cause here specifically.)

snarfed avatar Jun 05 '23 13:06 snarfed

https://mastodon.art/ has the same problem, and they're also on masto.host.

snarfed avatar Jun 11 '23 02:06 snarfed

Hrm, so does https://mastodon.social/ , and they're not on masto.host.

Haven't yet found anything relevant in https://github.com/mastodon/mastodon/issues

snarfed avatar Jun 11 '23 02:06 snarfed

Found an interesting workaround here: leave the img pointing to the CDN image, move the u-photo to an <a> wrapping it that points to the local (ie not CDN) image file.

snarfed avatar Jul 05 '23 18:07 snarfed