diff --git a/lib/controllers/migrate.js b/lib/controllers/migrate.js index f4fb2c9..6b02b48 100644 --- a/lib/controllers/migrate.js +++ b/lib/controllers/migrate.js @@ -55,10 +55,13 @@ export function migratePostController(mountPath, pluginOptions) { const importFollowing = request.body.importTypes?.includes("following"); const importFollowers = request.body.importTypes?.includes("followers"); - // Read uploaded file — express-fileupload or raw body - const fileContent = extractFileContent(request); + // Read file content (submitted as text via client-side FileReader) + const fileContent = request.body.csvContent?.trim(); if (!fileContent) { - result = { type: "error", text: "No file uploaded" }; + result = { + type: "error", + text: response.locals.__("activitypub.migrate.errorNoFile"), + }; } else { let followingResult = { imported: 0, failed: 0 }; let followersResult = { imported: 0, failed: 0 }; @@ -104,20 +107,3 @@ export function migratePostController(mountPath, pluginOptions) { }; } -/** - * Extract file content from the request. - * Supports express-fileupload (request.files) and raw text body. - */ -function extractFileContent(request) { - // express-fileupload attaches to request.files - if (request.files?.csvFile) { - return request.files.csvFile.data.toString("utf-8"); - } - - // Fallback: file content submitted as text in a textarea - if (request.body.csvContent) { - return request.body.csvContent; - } - - return null; -} diff --git a/locales/en.json b/locales/en.json index fdd3396..ef3cb70 100644 --- a/locales/en.json +++ b/locales/en.json @@ -41,6 +41,7 @@ "importFollowersHint": "Your current followers — they will be recorded as pending until they re-follow you after the Move in step 3", "step3Title": "Step 3 — Move your account", "step3Desc": "Once you have saved your alias and imported your data, go to your Mastodon instance → Preferences → Account → Move to a different account. Enter your new fediverse handle and confirm. Mastodon will notify all your followers, and those whose servers support it will automatically re-follow you here. This step is irreversible — your old account will become a redirect.", + "errorNoFile": "Please select a CSV file before importing.", "success": "Imported %d following, %d followers (%d failed).", "aliasSuccess": "Alias saved — your actor document now includes this account as alsoKnownAs." } diff --git a/package.json b/package.json index 819698e..090e464 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rmdes/indiekit-endpoint-activitypub", - "version": "0.1.6", + "version": "0.1.7", "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 ce8f59a..c103e1d 100644 --- a/views/activitypub-migrate.njk +++ b/views/activitypub-migrate.njk @@ -4,10 +4,8 @@ {% from "input/macro.njk" import input with context %} {% from "button/macro.njk" import button with context %} {% from "checkboxes/macro.njk" import checkboxes with context %} -{% from "file-input/macro.njk" import fileInput with context %} {% from "notification-banner/macro.njk" import notificationBanner with context %} {% from "prose/macro.njk" import prose with context %} -{% from "badge/macro.njk" import badge with context %} {% block content %} {{ heading({ text: title, level: 1, parent: { text: __("activitypub.title"), href: mountPath } }) }} @@ -49,8 +47,9 @@ {{ heading({ text: __("activitypub.migrate.step2Title"), level: 2 }) }} {{ prose({ text: __("activitypub.migrate.step2Desc") }) }} -
@@ -87,4 +94,44 @@ {# Step 3 — Instructions #} {{ heading({ text: __("activitypub.migrate.step3Title"), level: 2 }) }} {{ prose({ text: __("activitypub.migrate.step3Desc") }) }} + + {% endblock %}