Skip to content

Add dedicated Pixelfed integration (and wire up Mastodon media polling) - #2

Merged
fishcharlie merged 3 commits into
mainfrom
fishcharlie/add-pixelfed-support
Apr 18, 2026
Merged

fishcharlie merged 3 commits into
mainfrom
fishcharlie/add-pixelfed-support

Conversation

@fishcharlie

Copy link
Copy Markdown
Member

Why

Pixelfed is a popular ActivityPub photo-sharing platform that, while Mastodon-API-compatible at the wire level, has its own publishing semantics (image is required, media uploads are processed asynchronously server-side). Treating it as "just another Mastodon instance" works on paper but trips over those differences in practice. This PR gives Pixelfed a first-class network type with the right defaults and behavior.

What changed

New pixelfed social network type

  • SocialNetworkType.pixelfed enum value and PixelfedSocialNetwork config interface (endpoint + OAuth bearer token).
  • Poster.post / Poster.reply: upload image via /api/v1/media, poll /api/v1/media/:id until processing finishes, then create the status. Throws a clear error if no image is supplied (Pixelfed posts always require one).
  • Poster.repost: reblogs by status id.
  • defaultIncludeHashtags(pixelfed) returns true.

Shared MediaProcessingSettings

  • Pulled the polling knobs (pollAttempts, pollIntervalMs) into a shared MediaProcessingSettings interface, exposed as settings.mediaProcessing on both Mastodon and Pixelfed configs (and exported from the package entrypoint).
  • Three new private helpers on Poster keep the two Mastodon-API-compatible code paths fully DRY: #mastodonCompatibleClient, #waitForMastodonCompatibleMedia, and #uploadMastodonCompatibleImage (upload + poll in one call).

Mastodon side benefits

  • Poster.post and Poster.reply for Mastodon now also poll uploaded media until processing completes, fixing a latent bug where a status could reference a not-yet-ready media id on slower instances or with larger images.
  • Poster.reply for Mastodon now actually attaches images, which it was previously dropping on the floor.

Tests

  • Added src/Pixelfed.test.ts covering the "image required" errors for post and reply.
  • Updated src/index.test.ts to assert the new enum value and defaultIncludeHashtags coverage.
  • 21/21 tests pass; tsc build is clean.

Notes for reviewers

  • No new runtime dependencies. Pixelfed reuses the existing masto client.
  • The two pre-existing lint errors in Poster.ts / types/Config.ts are untouched and not introduced by this change.
  • Default polling settings (10 attempts × 1000ms = up to 10s) are intentionally conservative; both can be overridden per-network via settings.mediaProcessing.

fishcharlie and others added 3 commits April 17, 2026 19:03
Pixelfed implements the Mastodon-compatible REST API, so this reuses
the masto client but adds a first-class `pixelfed` social network type
with Pixelfed-specific behavior:

- New SocialNetworkType.pixelfed enum value
- New PixelfedSocialNetwork config interface (endpoint + bearer token)
- Poster.post / Poster.reply use /api/v1/media + /api/v1/statuses
- Image is required for posts and replies (Pixelfed is photo-first);
  throws a clear error otherwise
- Polls /api/v1/media/:id while the server processes the upload
  (configurable via mediaProcessingPollAttempts /
  mediaProcessingPollIntervalMs)
- Poster.repost reblogs an existing status by id
- defaultIncludeHashtags returns true for pixelfed

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…n polling

- New shared MediaProcessingSettings type (pollAttempts, pollIntervalMs)
  on src/types/Config.ts; both Mastodon and Pixelfed configs now expose
  it as settings.mediaProcessing.
- Replace the Pixelfed-specific #waitForPixelfedMedia helper with a
  generic #waitForMastodonCompatibleMedia that works for any
  Mastodon-API-compatible network.
- New #mastodonCompatibleClient helper centralizes masto client
  construction (used by post / repost / reply for both platforms).
- New #uploadMastodonCompatibleImage helper combines media upload +
  polling so Mastodon and Pixelfed share the exact same flow.
- Mastodon post / reply now poll uploaded media for processing
  completion (fixes a latent bug where large images or slow instances
  could be referenced before processing finished). Mastodon reply also
  now actually attaches images, which it previously dropped.
- Export MediaProcessingSettings from the package entrypoint.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The repo's lint job was already failing on main with two pre-existing
errors. Fixing them here so CI passes for this PR:

- src/Poster.ts: nostrContent is never reassigned, change `let` to
  `const`.
- src/types/Config.ts: NostrSocialNetwork.eventHandler return type
  was `Promise<any>`. Replace with the explicit PostResult shape
  inlined (avoids a circular import with Poster.ts) so it satisfies
  @typescript-eslint/no-explicit-any without losing the structural
  contract that Poster.post relies on.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@fishcharlie
fishcharlie merged commit 23547fb into main Apr 18, 2026
4 checks passed
@fishcharlie
fishcharlie deleted the fishcharlie/add-pixelfed-support branch April 18, 2026 20:11
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

Successfully merging this pull request may close these issues.

1 participant