Move custom side-effects events to activity/federation.js

This commit is contained in:
Niko 2022-02-12 03:03:16 +01:00
parent beab38eeed
commit 35898576fa
3 changed files with 13 additions and 12 deletions

View File

@ -0,0 +1,10 @@
module.exports = {
inbox: (msg) => {
console.log('INBOX')
console.log(msg)
},
outbox: (msg) => {
console.log('OUTBOX')
console.log(msg)
},
};

View File

@ -5,6 +5,7 @@ global.replaceImpl = (funcs, name, withFunc) => {
} }
module.exports = { module.exports = {
federation: require('./federation.js'),
rewriteImplementations: () => { rewriteImplementations: () => {
require('./well-known.js').init() require('./well-known.js').init()
require('./actor.js').init() require('./actor.js').init()

View File

@ -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/webfinger', apex.net.webfinger.get)
app.get('/.well-known/nodeinfo', apex.net.nodeInfoLocation.get) app.get('/.well-known/nodeinfo', apex.net.nodeInfoLocation.get)
app.get('/nodeinfo/:version', apex.net.nodeInfo.get) app.get('/nodeinfo/:version', apex.net.nodeInfo.get)
app.on('apex-outbox', activity.federation.outbox)
// custom side-effects for your app app.on('apex-inbox', activity.federation.inbox)
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}`)
}
})
// API defines // API defines
app.route(api.url('/accounts/register')).post(api.accounts.register.post) app.route(api.url('/accounts/register')).post(api.accounts.register.post)