diff --git a/api/src/activity/federation.js b/api/src/activity/federation.js new file mode 100644 index 0000000..e69223a --- /dev/null +++ b/api/src/activity/federation.js @@ -0,0 +1,10 @@ +module.exports = { + inbox: (msg) => { + console.log('INBOX') + console.log(msg) + }, + outbox: (msg) => { + console.log('OUTBOX') + console.log(msg) + }, +}; diff --git a/api/src/activity/index.js b/api/src/activity/index.js index a9be412..5addef4 100644 --- a/api/src/activity/index.js +++ b/api/src/activity/index.js @@ -5,6 +5,7 @@ global.replaceImpl = (funcs, name, withFunc) => { } module.exports = { + federation: require('./federation.js'), rewriteImplementations: () => { require('./well-known.js').init() require('./actor.js').init() diff --git a/api/src/server.js b/api/src/server.js index 2c5dcce..a8bad16 100644 --- a/api/src/server.js +++ b/api/src/server.js @@ -62,18 +62,8 @@ app.get(routes.likes, apex.net.likes.get) app.get('/.well-known/webfinger', apex.net.webfinger.get) app.get('/.well-known/nodeinfo', apex.net.nodeInfoLocation.get) app.get('/nodeinfo/:version', apex.net.nodeInfo.get) - -// custom side-effects for your app -app.on('apex-outbox', msg => { - if (msg.activity.type === 'Create') { - console.log(`New ${msg.object.type} from ${msg.actor}`) - } -}) -app.on('apex-inbox', msg => { - if (msg.activity.type === 'Create') { - console.log(`New ${msg.object.type} from ${msg.actor} to ${msg.recipient}`) - } -}) +app.on('apex-outbox', activity.federation.outbox) +app.on('apex-inbox', activity.federation.inbox) // API defines app.route(api.url('/accounts/register')).post(api.accounts.register.post)