Apoorva - feat: Add Mastodon API integration backend#1953
Merged
one-community merged 4 commits intodevelopmentfrom Jan 24, 2026
Merged
Apoorva - feat: Add Mastodon API integration backend#1953one-community merged 4 commits intodevelopmentfrom
one-community merged 4 commits intodevelopmentfrom
Conversation
- Implement mastodonPostController with image upload and alt text - Add cron job for scheduled post processing - Create mastodonRouter with RESTful endpoints - Add form-data dependency for media uploads - Integrate with Mastodon API v1
Anusha-Gali
approved these changes
Jan 7, 2026
Member
|
Thank you all, merging! |
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.





Description
Backend implementation for Mastodon auto-poster feature, providing API endpoints for posting, scheduling, and managing social media content.
Related PRS (if any):
To test this backend PR you need to checkout the #4558 frontend PR.
…
Features Implemented
Main Changes
New Files:
src/controllers/mastodonPostController.js- Main API controller with image upload logicsrc/cronjobs/mastodonScheduleJob.js- Cron job for processing scheduled postssrc/routes/mastodonRouter.js- RESTful API routessrc/models/mastodonSchedule.js- MongoDB schema for scheduled postsModified Files:
src/server.js- Added mastodon routes and cron job initializationpackage.json- Addedform-datadependencypackage-lock.json- Updated lock fileAPI Endpoints
POST
/api/mastodon/createPinPost immediately to Mastodon
POST
/api/mastodon/scheduleSchedule a post for later
GET
/api/mastodon/scheduleFetch all scheduled posts
DELETE
/api/mastodon/schedule/:idDelete a scheduled post by ID
GET
/api/mastodon/history?limit=20Fetch post history from Mastodon API
Technical Implementation
Image Upload Process (Two-Step)
/api/v1/media→ get media IDPUT /api/v1/media/:idWhy two steps? Mastodon API requires alt text to be set separately after upload.
Cron Job Flow
* * * * *)scheduledTime <= nowError Handling
Environment Variables Required
Add to
.env:To get access token:
read writeHow to Test
Setup:
apoorva-mastodon-autoposterapoorva-mastodon-autoposter.envnpm installnpm run buildnpm startTest Endpoints:
1. POST Immediately (with image + alt text)
✅ Verify post appears on Mastodon
✅ Verify image has alt text (inspect HTML)
2. Schedule Post
✅ Verify saves to MongoDB
✅ Wait 2 minutes
✅ Verify cron job posts it
✅ Verify removes from MongoDB
3. Fetch Scheduled Posts
✅ Verify returns array of scheduled posts
4. Delete Scheduled Post
✅ Verify removes from MongoDB
5. Fetch Post History
curl http://localhost:4500/api/mastodon/history?limit=20✅ Verify returns last 20 posts from Mastodon
✅ Verify includes engagement metrics (likes, reblogs)
Integration Test with Frontend:
Code Quality
Dependencies Added
form-data@^4.0.0- For multipart/form-data image uploads to Mastodon APIDatabase Schema
mastodonschedules collection:
Security Considerations
Performance
Known Issues
None at this time
Future Enhancements