newsmast-mastodon
A Rails engine that extends a Mastodon server with the features behind the Newsmast Apps for Change mobile apps and the Newsmast Dashboard: content channels, content filters, drafts, push notifications, account management and more.
Install it into an existing Mastodon server and it adds these features at runtime, so you don't need to maintain a fork.
Features
- Timelines: per-account custom feeds, a "For You" timeline, and an instances timeline that combines home with selected relay domains.
- Posting: drafted statuses (create, edit, publish later), local-only posts, long posts, and link previews.
- Moderation and content filters: banned statuses, tags and accounts, domain and username block lists, and content filter keywords.
- Notifications: Firebase (FCM) push with per-device tokens and mute settings, cross-instance push from a trusted partner server, and branded email templates.
- Accounts: OTP-based email verification and password reset, email change, account deletion, alt-text and email notification settings, and automatically following default accounts.
- Community features: status reactions, conversation helpers, a boost bot and channel reblogging, and custom relays.
-
Mobile deep links:
apple-app-site-associationandassetlinks.jsonserved from/.well-known.
See docs/newsmast-api-list.md for the full API
list, or import the
Postman collection.
Compatibility
The gem uses compatibility-first versioning: X.Y.Z.N, where X.Y.Z is
the Mastodon version it targets and N is the gem patch level for that
Mastodon line. Install the version that matches your Mastodon server.
| Gem version | Mastodon | Ruby | Rails |
|---|---|---|---|
4.6.5.x |
4.6.5 | >= 3.3, < 4.1 | ~> 8.1 |
4.6.3.x |
4.6.3 | >= 3.3, < 4.1 | ~> 8.1 |
4.5.11 |
4.5.11 | see CHANGELOG | see CHANGELOG |
Release notes for each version are in CHANGELOG.md.
Installation
Run these steps from the root of your Mastodon application.
-
Add the gem to Mastodon's
Gemfile, pinned to the version that matches your Mastodon release:gem "newsmast_mastodon", "4.6.5.1"
-
Install it and copy the gem's Chewy indexes and frontend overrides into the host app:
bundle install bin/rails newsmast_mastodon:install
-
Run the migrations and rebuild the frontend:
bin/rails db:migrate yarn build:production
-
Set the environment variables for the features you use (see Configuration), then restart the web, Sidekiq and streaming processes.
New servers can also create the database from Mastodon's schema
(bin/rails db:setup, db:prepare or mastodon:setup). The gem runs its own
migrations right after the schema is loaded, so its tables and columns are
created either way.
The engine mounts its routes automatically, so you don't need to edit
config/routes.rb. For a full deployment guide, see the
installation docs.
Upgrading
To move to a new Mastodon version, bump Mastodon and the gem together:
- Change the version pin in the
Gemfile, then runbundle update newsmast_mastodon. - Run
bin/rails newsmast_mastodon:installagain, because the frontend overrides change between releases. - Run
bin/rails db:migrate, rebuild assets, and restart.
Check the CHANGELOG.md entry for each version you skip, and
the release process for upgrade notes.
Configuration
Every feature is configured with environment variables, and most are off
until you set them. See
docs/configuration/environment-variables.md
for the full reference, and the hosted
configuration guide.
How the gem overrides Mastodon
The gem is a standard Rails engine. It changes Mastodon's behavior at runtime by:
- prepending modules into Mastodon services, serializers, validators and
controllers (see
config/initializers/prepend_concerns.rb); - including model concerns into
Account,Status,Userand other host models; - shipping its own migrations, frontend components and API controllers, which mount onto the host.
This gives every Mastodon host the same behavior that used to be maintained as
inline patches in a fork. bin/check-override-drift checks that the vendored
frontend overrides still match a given Mastodon checkout.
Documentation
| Topic | Where |
|---|---|
| Environment variables | docs/configuration/environment-variables.md |
| API list and Postman collection | docs/newsmast-api-list.md |
| Local development and testing | docs/development/testing-and-local-services.md |
| API validation and system tests | docs/testing/api-validation-and-system-testing.md |
| CI jobs | docs/ci/jobs.md |
| Troubleshooting | docs/troubleshooting/common-issues.md |
| Mastodon upgrade guide (maintainers) | docs/internal/mastodon-upgrade/GUIDE.md |
Development
bin/setup --skip-server # install dependencies and prepare the dummy app
bundle exec rspec # run the test suite
bundle exec rubocop # lint
bundle exec rake api:verify # check routes, controllers and Postman docs are in syncSee CONTRIBUTING.md for the full workflow.
Contributing and community
- Contributing guide
- Governance and maintainers
- Getting support
- Code of Conduct
-
Security issues: please report privately as described in
SECURITY.md. Don't open a public issue.
License
Copyright © Patchwork Hub and contributors. Licensed under the
GNU Affero General Public License v3.0 only. This gem extends
and includes code derived from Mastodon; see NOTICE for
attribution.