mirror of
https://github.com/svemagie/indiekit-endpoint-activitypub.git
synced 2026-04-02 15:44:58 +02:00
- Persist Ed25519 key pair to ap_keys collection via exportJwk/importJwk instead of regenerating on every request (fixes OIP verification failures) - Use assertionMethods (plural array) per Fedify spec - Add @fedify/redis + ioredis for persistent message queue that survives process restarts (falls back to InProcessMessageQueue when no Redis) - Add Reject inbox listener to mark rejected Follow requests - Add performance indexes on ap_followers, ap_following, ap_activities - Wire storeRawActivities flag through to activity logging - Bump version to 1.0.21
36 lines
1.2 KiB
JavaScript
36 lines
1.2 KiB
JavaScript
/**
|
|
* Shared activity logging utility.
|
|
*
|
|
* Logs inbound and outbound ActivityPub activities to the ap_activities
|
|
* collection so they appear in the Activity Log admin UI.
|
|
*/
|
|
|
|
/**
|
|
* Log an activity to the ap_activities collection.
|
|
*
|
|
* @param {object} collection - The ap_activities MongoDB collection
|
|
* @param {object} record - Activity record
|
|
* @param {string} record.direction - "inbound" or "outbound"
|
|
* @param {string} record.type - Activity type (e.g. "Create", "Follow", "Undo(Follow)")
|
|
* @param {string} [record.actorUrl] - Actor URL
|
|
* @param {string} [record.actorName] - Actor display name
|
|
* @param {string} [record.objectUrl] - Object URL
|
|
* @param {string} [record.targetUrl] - Target URL (e.g. reply target)
|
|
* @param {string} [record.content] - Content excerpt
|
|
* @param {string} record.summary - Human-readable summary
|
|
*/
|
|
export async function logActivity(collection, record, options = {}) {
|
|
try {
|
|
const doc = {
|
|
...record,
|
|
receivedAt: new Date().toISOString(),
|
|
};
|
|
if (options.rawJson) {
|
|
doc.rawJson = options.rawJson;
|
|
}
|
|
await collection.insertOne(doc);
|
|
} catch (error) {
|
|
console.warn("[ActivityPub] Failed to log activity:", error.message);
|
|
}
|
|
}
|