Repository navigation
Add dedicated Pixelfed integration (and wire up Mastodon media polling) - #2
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
pixelfedsocial network typeSocialNetworkType.pixelfedenum value andPixelfedSocialNetworkconfig interface (endpoint + OAuth bearer token).Poster.post/Poster.reply: upload image via/api/v1/media, poll/api/v1/media/:iduntil 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)returnstrue.Shared
MediaProcessingSettingspollAttempts,pollIntervalMs) into a sharedMediaProcessingSettingsinterface, exposed assettings.mediaProcessingon both Mastodon and Pixelfed configs (and exported from the package entrypoint).Posterkeep the two Mastodon-API-compatible code paths fully DRY:#mastodonCompatibleClient,#waitForMastodonCompatibleMedia, and#uploadMastodonCompatibleImage(upload + poll in one call).Mastodon side benefits
Poster.postandPoster.replyfor 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.replyfor Mastodon now actually attaches images, which it was previously dropping on the floor.Tests
src/Pixelfed.test.tscovering the "image required" errors forpostandreply.src/index.test.tsto assert the new enum value anddefaultIncludeHashtagscoverage.tscbuild is clean.Notes for reviewers
mastoclient.Poster.ts/types/Config.tsare untouched and not introduced by this change.settings.mediaProcessing.