diff --git a/index.js b/index.js index 75312d3..8adf33b 100644 --- a/index.js +++ b/index.js @@ -180,7 +180,7 @@ export default class ActivityPubEndpoint { router.get("/admin/activities", activitiesController(mp)); router.get("/admin/migrate", migrateGetController(mp, this.options)); router.post("/admin/migrate", migratePostController(mp, this.options)); - router.post("/admin/migrate/import", express.json({ limit: "5mb" }), migrateImportController(mp, this.options)); + router.post("/admin/migrate/import", migrateImportController(mp, this.options)); return router; } diff --git a/lib/controllers/migrate.js b/lib/controllers/migrate.js index 3f36296..0d5bba3 100644 --- a/lib/controllers/migrate.js +++ b/lib/controllers/migrate.js @@ -7,8 +7,6 @@ */ import { - parseMastodonFollowingCsv, - parseMastodonFollowersList, bulkImportFollowing, bulkImportFollowers, } from "../migration.js"; @@ -56,19 +54,20 @@ export function migratePostController(mountPath, pluginOptions) { } /** - * JSON endpoint for CSV import — receives { csvContent, importTypes } - * via fetch() to bypass Express's app-level urlencoded body size limit. + * JSON endpoint for import — receives { handles, importTypes }. + * CSV is parsed client-side to extract handles only, keeping the + * JSON payload small enough for Express's default body parser limit. */ export function migrateImportController(mountPath, pluginOptions) { return async (request, response, next) => { try { const { application } = request.app.locals; - const { csvContent, importTypes } = request.body; + const { handles, importTypes } = request.body; - if (!csvContent?.trim()) { + if (!Array.isArray(handles) || handles.length === 0) { return response.status(400).json({ type: "error", - text: "No CSV content provided.", + text: "No handles provided.", }); } @@ -84,15 +83,13 @@ export function migrateImportController(mountPath, pluginOptions) { let followersResult = { imported: 0, failed: 0, errors: [] }; if (importFollowing && followingCollection) { - const handles = parseMastodonFollowingCsv(csvContent); - console.log(`[ActivityPub] Migration: parsed ${handles.length} following handles from CSV`); + console.log(`[ActivityPub] Migration: importing ${handles.length} following handles`); followingResult = await bulkImportFollowing(handles, followingCollection); } if (importFollowers && followersCollection) { - const entries = parseMastodonFollowersList(csvContent); - console.log(`[ActivityPub] Migration: parsed ${entries.length} follower entries from CSV`); - followersResult = await bulkImportFollowers(entries, followersCollection); + console.log(`[ActivityPub] Migration: importing ${handles.length} follower entries`); + followersResult = await bulkImportFollowers(handles, followersCollection); } const totalFailed = followingResult.failed + followersResult.failed; diff --git a/package.json b/package.json index 28247e4..94eae9b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rmdes/indiekit-endpoint-activitypub", - "version": "0.1.9", + "version": "0.1.10", "description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.", "keywords": [ "indiekit", diff --git a/views/activitypub-migrate.njk b/views/activitypub-migrate.njk index 39c1f23..08e8ee3 100644 --- a/views/activitypub-migrate.njk +++ b/views/activitypub-migrate.njk @@ -76,7 +76,7 @@ @change="readFile($event)">