ActivityPub Federation#
Misskey implements the ActivityPub protocol to federate with Mastodon, Pleroma, Akkoma, Fedibird, and other Fediverse servers. All AP logic lives under packages/backend/src/core/activitypub/ .
The five primary services are:
| Service | Responsibility |
|---|---|
ApRendererService | Serializes Misskey objects β AP JSON |
ApInboxService | Processes inbound AP activities |
ApDeliverManagerService | Queues outbound deliveries |
ApResolverService | Fetches remote AP objects via signed HTTP GET |
ApRequestService | HTTP Signature primitives |
A models/ subdirectory contains ApNoteService and ApPersonService, which materialize remote AP objects into the local database.
Outbound: ApRendererService#
ApRendererService converts internal Misskey entities into AP-compliant JSON-LD objects . Rendered types include:
- Objects:
Note,Person,Document,Image,Emoji - Activities:
Create,Announce,Follow,Like,Block,Delete,Update,Undo,Accept,Reject
Outgoing notes include a _misskey_content field carrying the original MFM source text; ApNoteService uses a typeof === 'string' guard on this field to avoid shadowing the standard content field when _misskey_content is null .
Emoji reactions are federated as Like activities with a content property. Custom emoji reactions additionally include an Emoji object in the tag array .
Activities are signed via attachLdSignature() using RSA-SHA256 (RsaSignature2017). Ed25519 key support is in progress under PR #16250; it adds additionalPublicKeys to the AP Person object (following the Mastodon publicKey spec) and selects the signing algorithm per remote instance based on their nodeinfo httpMessageSignaturesImplementationLevel .
Inbound: ApInboxService#
ApInboxService handles the full range of AP activity types: Create, Delete, Update, Follow, Accept, Reject, Add, Remove, Announce, Like, Undo, Block, Flag, Move .
Actor validation flow:
- Actor suspension status is checked before any processing.
- All uses of
activity.actorare wrapped withgetApId()to handle both embedded actor objects and plain URI strings β improving compatibility with non-Mastodon AP implementations . isFederationAllowedUrienforces domain-level allow/block lists.- A distributed lock (
acquireApObjectLock) prevents race conditions on the same AP object.
Security hardening applied:
Reject{Follow}validates the rejecting actor's URI matches the Follow's target; mismatches are skipped to block forced-unfollow attacks .- Remote actor
namefields are HTML-stripped before storage to prevent stored XSS . - Activities missing an
actorfield return HTTP 400 rather than crashing the worker queue . Deleteactivities for actors that don't exist locally are silently skipped .
Relay handling:
RelayService.isRelayActor() identifies relay actors by matching their inbox/sharedInbox against accepted relay entries. Relay-delivered Announce activities publish the inner note directly to the stream instead of creating a renote β a distinction corrected in PR #17308 .
Delivery: ApDeliverManagerService#
ApDeliverManagerService builds a delivery list from followers and direct recipients, deduplicates by preferring shared inboxes, then enqueues jobs via QueueService . Retry logic and concurrency are managed at the queue layer.
Default queue concurrency values (updated in PR #16250 to reduce server load when Ed25519 becomes widespread):
| Queue | Old | New |
|---|---|---|
deliverJobConcurrency | 128 | 16 |
deliverJobPerSec | 128 | 1024 |
inboxJobConcurrency | 16 | 4 |
inboxJobPerSec | 32 | 64 |
Clock skew tolerance is Β±300s in both directions (previously only 2000ms forward); HTTP 401 responses from remote inboxes are retried to accommodate clock-skew scenarios .
Image Format Compatibility#
Federation constrains which image formats Misskey can serve and publish. Two constants and one service govern this:
FILE_TYPE_BROWSERSAFE (const.ts) is the whitelist of MIME types served with their real Content-Type. Everything else is returned as application/octet-stream. SVG is explicitly excluded to prevent XSS .
DriveService.generateAlts() creates two derivatives for every locally-uploaded image :
- webpublic β a web-optimized version referenced in AP
Documentattachments. Rules for when it is generated:- Not generated for animated images (compatibility).
- Not generated for remote-origin files (federation direction).
- AVIF originals are converted to WebP, because AVIF is
"not supported by Mastodon and MS Edge". - Images with EXIF/IPTC/XMP metadata embedded are always re-encoded (strips private metadata).
- Images exceeding 2048Γ2048 are downscaled.
- PNG/BMP/SVG originals produce a PNG webpublic; JPEG/WebP/AVIF produce a WebP webpublic.
- thumbnail β always WebP, always generated (498Γ422 for stills, 374Γ317 for animated).
WebP encoding defaults: quality 77, alphaQuality 95, smartSubsample: true, mixed: true, effort 2 .
AVIF history: AVIF support was added in 2022 then immediately rolled back due to incompatibility with Mastodon and Microsoft Edge . AVIF remains in FILE_TYPE_BROWSERSAFE for direct display of AVIF originals, but is never used as the output format for webpublic derivatives.
HEIF/HEIC: Not in FILE_TYPE_BROWSERSAFE and not auto-converted. Server-side conversion to JPEG/WebP on upload is the recommended implementation path to avoid federation compatibility problems .
Cross-Platform Compatibility Notes#
-
Emoji reactions: Misskey federates emoji reactions as
Likewithcontent(and anEmojitag for custom emoji). FEP-c0e0 is largely implemented; the remaining gap is exposing anemojiReactionscollection endpoint. Fedibird uses a per-reaction array format, while Misskey stores aggregated JSON counts in its DB β requiring mapping on each side . -
Image attachments: PR #17563 adds
widthandheightmetadata to APDocumentobjects, enabling remote clients to pre-allocate layout space before fetching media . -
Actor embedding: Some AP implementations embed full actor objects inside activities rather than providing a URI.
getApId()normalizes both forms throughoutApInboxService, preventing silent activity rejection . -
Relay LD signatures: As of Misskey 2026.6.0, LD Signature verification fails for posts relayed through some relay servers (Fedibird's relay, activitypub-relay) . This is an active bug.
-
Secure Mode / Private Mode: Administrators can require HTTP Signatures for all remote requests (Secure Mode) or restrict federation to an explicit allowlist (Private Mode) via instance settings .