lib | ||
prisma | ||
scripts | ||
.env.example | ||
.gitignore | ||
deno.json | ||
deno.lock | ||
LICENSE | ||
README.md | ||
setup.sh |
mastodon-membership
Repository for tooling to manage Mastodon (or other Mastodon API-compatible fediverse servers) membership externally, namely on Steady (https://steadyhq.com) and Patreon (https://patreon.com).
License
The license is available at ./LICENSE
, but TL;DR: it's APGL! #FOSS
Documentation
Requirements
- NPM (just for the setup script, because Prisma's scripts only work with Node.js)
- Node.js (just for the setup script, because Prisma's scripts only work with Node.js)
- Deno
- A MySQL database running (wherever you want)
- A Steady creator account (if you want to use it)
- A Patreon creator account (if you want to use it)
- A Mastodon account with admin rights on its server
In the future, I want to support other fediverse flavors (with different client-server APIs). Also, support different DBs (shouldn't be hard).
Setup
Secrets/Envrionment variables
You can and example of this configuration at ./.env.example
. You need to duplicate this file, rename the duplicate .env
and complete it with the correct values.
You need to get all the necessary configuration values/API keys/etc. Currently, these are:
Environment variable name | Description |
---|---|
DATABASE_URL | Your MySQL database connection string |
PATREON_API_TOKEN | Your Patreon API token (that has all scopes), if you wanna use it - get it here |
STEADY_API_TOKEN | Your Steady API token (that has all scopes), if you wanna use it - get it in your profile page > Integrations > API |
MASTODON_API_TOKEN | Your Mastodon API token (admin token with, at least, the admin:read:accounts scope) - get it from YOUR_MASTODON_SERVER_URL/settings/applications |
DEFAULT_TRIAL_PERIOD_IN_DAYS | The number of days an account can be on the server in trial (without paying for a membership) |
DEFAULT_FREEZE_PERIOD_IN_DAYS | The number of days an account will be frozen on the server, before being deleted (if memberhsip status is not fixed) |
DEFAULT_TRIAL_GRACE_PERIOD_IN_DAYS | A grace period, in days, for the trial period (to be forgiving). Usually, you'd want to publicly announce the period itself and tell people you have a grace period without specifying the duration |
DEFAULT_FREEZE_GRACE_PERIOD_IN_DAYS | A grace period, in days, for the freeze period (to be forgiving). Usually, you'd want to publicly announce the period itself and tell people you have a grace period without specifying the duration |
FEDIVERSE_SERVER_DOMAIN | Your fediverse server domain (just the domain itself, no "https" and such) |
I will try to work to reduce the scopes needed from the API tokens, and eventually try to make an OAuth app so that you don't need to input any secrets at all.
The setup script
There is a ./setup.sh
script. You need NPM, and therefore Node.js, to run it. You don't need Node anymore after this.
You just have to run it and let it setup your database with the right tables and such.
Test your setup
Run deno run scripts/test.ts
to test your setup. This should run with no errors, and outup some stuff that lets you know everything is ok. It is dry (doesn't change anything in the databases and such).
As of 22/04/2023, it only tests that your Deno installation is good.
Doing stuff
You're now ready to start populating the database with accounts and subscriptions!
Run any of the following scripts to do what their name implies (eheh), using deno run scripts/${scriptName}.ts
linkAccountToMembership
(this is a manual linkage)seedMastodonAccounts
(populates the DB with all Mastodon accounts on your server)seedPatreonMemberships
(populates the DB with all Patreon memberships)seedSteadyMemberships
(populates the DB with all Steady memberships)
That's it!
That should be it! Let me know if anything goes wrong. Feel free to open PRs or issues at will 😊