UNPKG

immers

Version:

ActivityPub server for the metaverse

27 lines (23 loc) 767 B
module.exports = { parseHandle, debugOutput } function debugOutput (app) { const l = (activity) => { const obj = activity.object?.[0]?.id ?? activity.object?.[0] const target = activity.target?.[0]?.id ?? activity.target?.[0] return `${activity.type}: from ${activity.actor[0].id ?? activity.actor[0]} to ${activity.to} obj ${obj} target ${target}` } app.on('apex-inbox', msg => console.log('---inbox----------\n', l(msg.activity))) app.on('apex-outbox', msg => console.log('---outbox---------\n', l(msg.activity))) } const handleReg = /([^@[]+)[@[]([^\]]+)/ function parseHandle (handle) { const match = handleReg.exec(handle) if (match && match.length === 3) { return { username: match[1], immer: match[2] } } }