2021-04-09 00:22:17 +00:00
# Mitra
2022-08-21 17:56:28 +00:00
Federated social network with blockchain integration.
2021-04-09 00:22:17 +00:00
2022-07-11 00:48:33 +00:00
Built on [ActivityPub ](https://www.w3.org/TR/activitypub/ ) protocol, self-hosted, lightweight. Part of the [Fediverse ](https://en.wikipedia.org/wiki/Fediverse ).
2022-02-08 01:36:40 +00:00
2022-08-21 17:56:28 +00:00
Unique features:
2022-02-08 01:36:40 +00:00
2022-09-01 12:47:00 +00:00
- [Sign-in with a wallet ](https://eips.ethereum.org/EIPS/eip-4361 ).
2022-07-11 00:48:33 +00:00
- Recurring payments. Subscribers-only posts.
2022-09-01 12:47:00 +00:00
- Donations.
2022-07-11 00:48:33 +00:00
- Token-gated registration (can be used to verify membership in some group or to stop bots).
2021-04-09 00:22:17 +00:00
- Converting posts into NFTs.
2022-08-21 17:56:28 +00:00
Supported blockchains:
2022-05-28 22:14:55 +00:00
2022-08-21 17:56:28 +00:00
- Ethereum and other EVM-compatible blockchains.
2022-09-08 13:38:52 +00:00
- Monero.
2022-08-21 17:56:28 +00:00
Ethereum contracts repo: https://codeberg.org/silverpill/mitra-contracts
2021-10-10 09:55:33 +00:00
2021-11-29 21:24:44 +00:00
Frontend repo: https://codeberg.org/silverpill/mitra-web
2022-07-02 13:46:57 +00:00
Demo instance: https://public.mitra.social/ (invite-only)
2021-11-20 20:34:33 +00:00
2022-04-13 10:43:19 +00:00
Matrix chat: [#mitra:halogen.city ](https://matrix.to/#/#mitra:halogen.city )
2021-04-09 00:22:17 +00:00
## Requirements
2022-04-30 16:04:01 +00:00
- Rust 1.54+ (when building from source)
2022-04-20 13:47:04 +00:00
- PostgreSQL 12+
2022-01-11 23:02:56 +00:00
- IPFS node (optional, see [guide ](./docs/ipfs.md ))
2021-04-09 00:22:17 +00:00
- Ethereum node (optional)
2022-09-01 12:47:00 +00:00
- Monero node and Monero wallet (optional)
2021-04-09 00:22:17 +00:00
2022-04-30 16:04:01 +00:00
## Installation
### Building from source
Run:
```
2022-05-04 19:44:38 +00:00
cargo build --release --features production
2022-04-30 16:04:01 +00:00
```
This command will produce two binaries in `target/release` directory, `mitra` and `mitractl` .
2022-05-11 21:05:44 +00:00
Install PostgreSQL and create the database.
Create configuration file by copying `contrib/mitra_config.yaml` and configure the instance. Default config file path is `/etc/mitra/config.yaml` , but it can be changed using `CONFIG_PATH` environment variable.
2022-04-30 16:04:01 +00:00
2022-05-04 19:44:38 +00:00
Start Mitra:
2022-04-30 16:04:01 +00:00
```
2022-05-04 19:44:38 +00:00
./mitra
2022-04-30 16:04:01 +00:00
```
An HTTP server will be needed to handle HTTPS requests and serve the frontend. See the example of [nginx configuration file ](./contrib/mitra.nginx ).
Building instructions for `mitra-web` frontend can be found at https://codeberg.org/silverpill/mitra-web#project-setup.
To run Mitra as a systemd service, check out the [systemd unit file example ](./contrib/mitra.service ).
2022-05-11 21:05:44 +00:00
### Debian package
Download and install Mitra package:
```
dpkg -i mitra.deb
```
Install PostgreSQL and create the database. Open configuration file `/etc/mitra/config.yaml` and configure the instance.
Start Mitra:
```
systemctl start mitra
```
An HTTP server will be needed to handle HTTPS requests and serve the frontend. See the example of [nginx configuration file ](./contrib/mitra.nginx ).
2021-04-09 00:22:17 +00:00
## Development
### Create database
```
docker-compose up
```
Test connection:
```
2022-03-05 12:48:30 +00:00
psql -h localhost -p 55432 -U mitra mitra
2021-04-09 00:22:17 +00:00
```
### Run web service
2022-04-30 19:26:09 +00:00
Create config file, adjust settings if needed:
2021-04-09 00:22:17 +00:00
```
cp config.yaml.example config.yaml
```
Compile and run service:
```
cargo run
```
### Run CLI
```
cargo run --bin mitractl
```
2021-11-13 17:37:31 +00:00
### Run linter
```
cargo clippy
```
2021-10-10 09:55:33 +00:00
### Run tests
```
cargo test
```
2021-11-14 20:09:46 +00:00
## Federation
2022-04-13 10:43:19 +00:00
See [FEDERATION.md ](./FEDERATION.md )
2021-11-14 20:09:46 +00:00
## Client API
2021-04-09 00:22:17 +00:00
### Mastodon API
2022-02-08 01:36:40 +00:00
Most methods are similar to Mastodon API, but Mitra is not fully compatible.
2021-04-09 00:22:17 +00:00
2021-12-29 12:07:56 +00:00
[OpenAPI spec ](./docs/openapi.yaml ) (incomplete)
2021-12-03 15:29:50 +00:00
2022-07-12 21:24:31 +00:00
## CLI
Commands must be run as the same user as the web service:
```
su mitra -c "mitractl generate-invite-code"
```
### Commands
2021-04-09 00:22:17 +00:00
2022-09-08 13:38:52 +00:00
Print help:
```shell
mitractl --help
```
2021-11-18 00:22:41 +00:00
Generate RSA private key:
```
mitractl generate-rsa-key
```
2021-11-15 21:43:58 +00:00
Generate invite code:
2021-04-09 00:22:17 +00:00
```
2021-11-15 21:43:58 +00:00
mitractl generate-invite-code
2021-04-09 00:22:17 +00:00
```
2021-11-15 21:43:58 +00:00
List generated invites:
2021-09-25 20:46:19 +00:00
```
2021-11-15 21:43:58 +00:00
mitractl list-invite-codes
2021-09-25 20:46:19 +00:00
```
2021-11-15 21:43:58 +00:00
Delete profile:
2021-04-09 00:22:17 +00:00
```
2022-08-11 23:12:07 +00:00
mitractl delete-profile 55a3005f-f293-4168-ab70-6ab09a879679
2021-04-09 00:22:17 +00:00
```
2021-11-15 21:43:58 +00:00
Delete post:
2021-04-09 00:22:17 +00:00
```
2022-08-11 23:12:07 +00:00
mitractl delete-post 55a3005f-f293-4168-ab70-6ab09a879679
2021-04-09 00:22:17 +00:00
```
2022-04-13 10:43:19 +00:00
Remove remote posts and media older than 30 days:
```
2022-08-11 23:12:07 +00:00
mitractl delete-extraneous-posts 30
2022-04-13 10:43:19 +00:00
```
2022-09-08 13:38:52 +00:00
Delete attachments that don't belong to any post:
2022-05-07 20:27:11 +00:00
```
2022-08-11 23:12:07 +00:00
mitractl delete-unused-attachments 5
2022-05-07 20:27:11 +00:00
```
2021-04-09 00:22:17 +00:00
Generate ethereum address:
```
mitractl generate-ethereum-address
```
2021-10-10 09:55:33 +00:00
2022-09-08 13:38:52 +00:00
Update synchronization starting block of Ethereum blockchain:
2022-06-20 20:26:43 +00:00
```shell
2022-08-11 23:12:07 +00:00
mitractl update-current-block 2000000
2022-06-20 20:26:43 +00:00
```
2022-09-08 13:38:52 +00:00
Create Monero wallet:
```shell
mitractl create-monero-wallet "mitra-wallet" "passw0rd"
```
2021-10-10 09:55:33 +00:00
## License
[AGPL-3.0 ](./LICENSE )
2022-04-13 10:43:19 +00:00
## Support
Monero: 8Ahza5RM4JQgtdqvpcF1U628NN5Q87eryXQad3Fy581YWTZU8o3EMbtScuioQZSkyNNEEE1Lkj2cSbG4VnVYCW5L1N4os5p