Files
indiekit-endpoint-activitypub/lib/controllers/dashboard.js
Ricardo da625592fd feat: ActivityPub federation endpoint for Indiekit
Implements full ActivityPub federation as an Indiekit plugin:
- Actor document (Person) with RSA key pair for HTTP Signatures
- WebFinger discovery (acct:rick@rmendes.net)
- Inbox: handles Follow, Undo, Like, Announce, Create, Delete, Move
- Outbox: serves published posts as ActivityStreams 2.0
- Content negotiation: AS2 JSON for AP clients, passthrough for browsers
- JF2-to-AS2 converter for all Indiekit post types
- Syndicator integration (pre-ticked checkbox for delivery to followers)
- Mastodon migration: alias config, CSV import for followers/following
- Admin UI: dashboard, followers, following, activity log, migration page
- Data retention: configurable TTL on activities, optional raw JSON storage

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 22:13:51 +01:00

40 lines
1.2 KiB
JavaScript

/**
* Dashboard controller — shows follower/following counts and recent activity.
*/
export function dashboardController(mountPath) {
return async (request, response, next) => {
try {
const { application } = request.app.locals;
const followersCollection = application?.collections?.get("ap_followers");
const followingCollection = application?.collections?.get("ap_following");
const activitiesCollection =
application?.collections?.get("ap_activities");
const followerCount = followersCollection
? await followersCollection.countDocuments()
: 0;
const followingCount = followingCollection
? await followingCollection.countDocuments()
: 0;
const recentActivities = activitiesCollection
? await activitiesCollection
.find()
.sort({ receivedAt: -1 })
.limit(10)
.toArray()
: [];
response.render("dashboard", {
title: response.locals.__("activitypub.title"),
followerCount,
followingCount,
recentActivities,
mountPath,
});
} catch (error) {
next(error);
}
};
}