# The Bad Space

As the fediverse is a largely unregulated space, The Bad Space arose from a need for collaborative safety tools that can be used identify instances that house bad actors, are poorly moderated, and/or contain inappropriate/offensive content (CSAM, hate speech, fascist ideology, etc.) that puts marginalized communities at risk for harassment and abuse.

The goal of TBS is to provide a way for communities to work together based on their specific needs and not a one-size-fits-all moderation approach for a more tailored and nuanced experience. 

## Requirements
TBS is built with the [Laravel](https://laravel.com/) framework, so PHP 8.2 and [Composer](https://getcomposer.org/doc/00-intro.md) is required, as well as [PostgreSQL](https://www.postgresql.org/download/) 14+ for the database.  [Git](https://git-scm.com/downloads) is not strictly required as the code base can be manually downloaded, but it does make installing and updating easier.

*NOTE*:  On Linux, some additional PHP extensions need to be installed, but don't worry it's easy. Run `sudo apt-get install php-mbstring`, `sudo apt-get install php-xml`  and `sudo apt-get install php-zip `to get them and you're good to go.

*NOTE*: Environment set up on a local machine can be a pain in the ass, so to make that easier [Herd](https://herd.laravel.com/) can be used for MacOS and Windows and [FlyEnv](https://www.macphpstudy.com/) for Linux folks that don't want to do it all by hand. [DBNgin](https://dbngin.com/) can be used to make database setup painless. Yes, and they are all free. 

## Install 
Use `git clone https://koodu.h-i.works/projects/thebadspace.git` to install or just go grab the zip from the repo and unzip it.

Create your database in PostgreSQL and remember the name of the database and the username and password used to access it. 

Go into the folder through your terminal and run `composer install` to grab all the dependencies needed and create the `.env` file that stores all project specific variables. 

Open the `.env` file and add your database information so it resembles the following:

```
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=your_database_name
DB_USERNAME=database_username
DB_PASSWORD=database_password
```

Now that the app is aware of what database is being used, it's time to set up the tables. 

Back in your terminal, run `php artisan migrate` and if your database is set up correctly, all the tables will be created automatically.

Congrats, you're all set up. 

## Usage
TBS can be run locally or on a remote server. 

To get up and running on your local machine, hop back in your terminal and run `php -S localhost:8000 -t public/ ` in the folder of the project. 

If you're running it on a server, use these configs to get going. 

**For Nginx**
```
server {  
      listen 80;
      server_name yourcoolassdomain.com;
      client_max_body_size 20M //Change to whatever to limit/increase file upload size
      location  / {
            try_files $uri /index.php$is_args$args;
      } 
}
```

**For Apache**
```
<VirtualHost *:80>
    ServerAdmin admin@yourcoolassdomain.com
    ServerName yourcoolassdomain.com
    ServerAlias www.yourcoolassdomain.com
    DocumentRoot /path-to-fipamo-folder/public
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
```

Remember to restart Apache/NGINX once these configs have been plugged in. 

Go the root domain of the site you just set up (or http://localhost:8000 if running locally) and you'll see a screen to set up an admin account. 

Once the admin account has been created, go to The Den section in the menu and login in.

### Adding Sources
The core of TBS is adding sources of the instances (currently just Mastodon, but more coming soon) to be used to compile exportable block lists. *Note:* While many instance block lists are publicly available, it is good practice to ask for permission to use them.

Sources can be added under the `Manage Sources` link. Fill in the appropriate information and then save. *Note:* Some instances keep their block lists private for safety reasons, so you will need an access token to use them. These tokens cannot be created by TBS and must be obtained from the instance itself. 

Once everything is filled in, save the source.

To remove a source from the compilation process, mark its status as active and save.

## Compiling Sources
Now it's time to grab the block list data from the individual sources entered needed to compile curation information. 

This can be done under `Manage Locations`  on the Den front page. Click `Update Source Data` to grab block list info from the sources added earlier. 

When that is completed, then click `Update Locations Data` to compile individual sources data into one that the site uses to display info about moderated instances. If this is being run for the first time, this must be clicked *twice*.

Once that's done, go to the main domain again, and you'll see the results of the compilation process. 
