@volpeon@mk.vulpes.one :akko_woozy: this seems more like a tiny little AP server than a bot, but ok
Conversation
Notices
-
Embed this notice
Puniko ? (puniko@mk.absturztau.be)'s status on Monday, 05-Dec-2022 21:25:12 JST Puniko ?
-
Embed this notice
Volpeon :drgn_fire::drgn_scream: (volpeon@mk.vulpes.one)'s status on Monday, 05-Dec-2022 21:25:13 JST Volpeon :drgn_fire::drgn_scream:
It does seem to know about ActivityPub :drgn_think_cool:
const express = require('express'); const bodyParser = require('body-parser'); const { fromObject, toObject, Actor, Collection, Link, OrderedCollection, OrderedCollectionPage, getId, getType } = require('activitypub'); const app = express(); app.use(bodyParser.json()); const actor = new Actor({ id: 'http://localhost:3000/actor', type: 'Person', name: 'Bot', inbox: 'http://localhost:3000/inbox', outbox: 'http://localhost:3000/outbox' }); app.post('/inbox', (req, res) => { const { body } = req; const object = fromObject(body); const objectType = getType(object); if (objectType === 'Create') { // handle creation of an object } else if (objectType === 'Follow') { // handle follow request } else if (objectType === 'Like') { // handle like request } res.send('OK'); }); app.get('/outbox', (req, res) => { const collection = new OrderedCollection({ id: 'http://localhost:3000/outbox', totalItems: 10, first: new OrderedCollectionPage({ id: 'http://localhost:3000/outbox?page=1', type: 'OrderedCollectionPage', partOf: 'http://localhost:3000/outbox', items: [ // array of objects that have been created by the bot ] }) }); res.json(toObject(collection)); }); app.listen(3000);
-
Embed this notice