fix(activitypub): Improved robustness of the logic that handles the protocol
This commit improves protocol handling and error resilience for incoming
and outgoing ActivityPub payloads.
- Refactored inbox handling to robustly parse and log incoming activity payloads, including raw body capture and detailed debug logging.
- Ensured all response paths send a valid empty JSON response instead of propagating errors or triggering crashes, especially for unhandled activities.
- Improved callback logic to reliably mark responses as handled (responseWritten) and prevent duplicate responses.
- Added outgoing activity logging (logOutgoingActivity) for better visibility into federated payload structure.
- Ensured proper error handling and logging for outgoing POST requests, including checks for empty target URLs.
- Avoid 500 errors due to empty response objects.
- Improved protocol stability for federating posts, including accurate labeling and debug output for both Create and Update activities.
- Added deduplication and normalization logic for attachments and outgoing object structure to maximize compatibility with other implementations.
- Enhanced maintainability by consolidating debug and error logs for easier troubleshooting.
These changes aim to ensure:
- Maximum compatibility with remote ActivityPub implementations (Akkoma/Pleroma, Mastodon, etc.).
- Improved diagnostics and easier protocol debugging.
- Reduced risk of protocol-induced crashes or silent failures on either side.
Fixes: #1436, #1415