Skip to content

castaneai/apubhook

Repository files navigation

APubHook

Incoming WebHook-like server for ActivityPub.

You can post messages to Fediverse like Incoming WebHook in Slack with the command curl -X POST -d '{"text": "hello"}' ...

Configuration

APubHook works on Cloudflare Workers; use Wrangler to configure and deploy.

cp wrangler.sample.toml wrangler.toml
pnpm install

Pick up the value of PRIVATE_KEY from the files generated by ssh-keygen:

ssh-keygen -b 4096 -m PKCS8 -t rsa -N '' -f id_rsa

You can also use the value as "Secret variables" in Cloudflare Workers.

Setup Database

pnpm wrangler d1 create apubhook
pnpm wrangler d1 execute apubhook --file db.sql

Deploy

pnpm run deploy

Usage

APubHook can host multiple accounts on a single server. Accounts are managed in the accounts table on the D1 Database. For example, the following command creates a BOT account named 'testbot'. secretHookPath is a secret string used in the WebHook URL.

pnpm wrangler d1 execute apubhook --command "insert or replace into accounts(username, displayName, secretHookPath, iconUrl, iconMime) VALUES('testbot', 'Test BOT', 'secret-path-example', '/static/icon.png', 'image/png')"

Then you can follow a account: @testbot@apubhook.<USERNAME>.workers.dev on Fediverse (Alternatively, you could use a custom domain for Workers).

And you can post messages with HTTP POST request with JSON payload to /hooks/secret-path-example.

# Sending 'hello' to Fediverse!
curl -X POST -d '{"text": "hello"}' "https://apubhook.<USERNAME>.workers.dev/hooks/secret-path-example"

You can see the post on Fediverse!

License

MIT

And using a lot of code in Matchbox and inspired by Minidon and Express ActivityPub Server.

Minidon https://github.com/yusukebe/minidon Copyright (c) 2023 Yusuke Wada. Licensed under the MIT license.

Matchbox https://gitlab.com/acefed/matchbox Copyright (c) 2022 Acefed MIT License

Express ActivityPub Server https://github.com/dariusk/express-activitypub Copyright (c) 2018 Darius Kazemi. Licensed under the MIT license.

About

Incoming Webhook-like server for ActivityPub.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published