Add BlacklistType enum and extend configuration for file storage
This commit is contained in:
parent
0071c4ebea
commit
85e20d38d2
2 changed files with 93 additions and 1 deletions
|
@ -4,13 +4,18 @@
|
||||||
|
|
||||||
use FederationServer\Classes\Configuration\DatabaseConfiguration;
|
use FederationServer\Classes\Configuration\DatabaseConfiguration;
|
||||||
use FederationServer\Classes\Configuration\RedisConfiguration;
|
use FederationServer\Classes\Configuration\RedisConfiguration;
|
||||||
|
use FederationServer\Classes\Configuration\FileStorageConfiguration;
|
||||||
|
|
||||||
class Configuration
|
class Configuration
|
||||||
{
|
{
|
||||||
private static ?\ConfigLib\Configuration $configuration = null;
|
private static ?\ConfigLib\Configuration $configuration = null;
|
||||||
private static ?DatabaseConfiguration $databaseConfiguration = null;
|
private static ?DatabaseConfiguration $databaseConfiguration = null;
|
||||||
private static ?RedisConfiguration $redisConfiguration = null;
|
private static ?RedisConfiguration $redisConfiguration = null;
|
||||||
|
private static ?FileStorageConfiguration $fileStorageConfiguration = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the configuration with default values.
|
||||||
|
*/
|
||||||
public static function initialize(): void
|
public static function initialize(): void
|
||||||
{
|
{
|
||||||
self::$configuration = new \ConfigLib\Configuration('federation_server');
|
self::$configuration = new \ConfigLib\Configuration('federation_server');
|
||||||
|
@ -29,12 +34,21 @@
|
||||||
self::$configuration->setDefault('redis.password', null);
|
self::$configuration->setDefault('redis.password', null);
|
||||||
self::$configuration->setDefault('redis.database', 0);
|
self::$configuration->setDefault('redis.database', 0);
|
||||||
|
|
||||||
|
self::$configuration->setDefault('file_storage.max_size', 52428800); // 50 MB
|
||||||
|
self::$configuration->setDefault('file_storage.path', '/var/www/uploads');
|
||||||
|
|
||||||
self::$configuration->save();
|
self::$configuration->save();
|
||||||
|
|
||||||
self::$databaseConfiguration = new DatabaseConfiguration(self::$configuration->get('database'));
|
self::$databaseConfiguration = new DatabaseConfiguration(self::$configuration->get('database'));
|
||||||
self::$redisConfiguration = new RedisConfiguration(self::$configuration->get('redis'));
|
self::$redisConfiguration = new RedisConfiguration(self::$configuration->get('redis'));
|
||||||
|
self::$fileStorageConfiguration = new FileStorageConfiguration(self::$configuration->get('file_storage'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the configuration values.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public static function getConfiguration(): array
|
public static function getConfiguration(): array
|
||||||
{
|
{
|
||||||
if(self::$configuration === null)
|
if(self::$configuration === null)
|
||||||
|
@ -45,6 +59,11 @@
|
||||||
return self::$configuration->getConfiguration();
|
return self::$configuration->getConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the configuration library instance.
|
||||||
|
*
|
||||||
|
* @return \ConfigLib\Configuration
|
||||||
|
*/
|
||||||
public static function getConfigurationLib(): \ConfigLib\Configuration
|
public static function getConfigurationLib(): \ConfigLib\Configuration
|
||||||
{
|
{
|
||||||
if(self::$configuration === null)
|
if(self::$configuration === null)
|
||||||
|
@ -55,6 +74,11 @@
|
||||||
return self::$configuration;
|
return self::$configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the database, Redis, and file storage configurations.
|
||||||
|
*
|
||||||
|
* @return DatabaseConfiguration
|
||||||
|
*/
|
||||||
public static function getDatabaseConfiguration(): DatabaseConfiguration
|
public static function getDatabaseConfiguration(): DatabaseConfiguration
|
||||||
{
|
{
|
||||||
if(self::$databaseConfiguration === null)
|
if(self::$databaseConfiguration === null)
|
||||||
|
@ -65,6 +89,11 @@
|
||||||
return self::$databaseConfiguration;
|
return self::$databaseConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Redis configuration.
|
||||||
|
*
|
||||||
|
* @return RedisConfiguration
|
||||||
|
*/
|
||||||
public static function getRedisConfiguration(): RedisConfiguration
|
public static function getRedisConfiguration(): RedisConfiguration
|
||||||
{
|
{
|
||||||
if(self::$redisConfiguration === null)
|
if(self::$redisConfiguration === null)
|
||||||
|
@ -74,4 +103,20 @@
|
||||||
|
|
||||||
return self::$redisConfiguration;
|
return self::$redisConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the file storage configuration.
|
||||||
|
*
|
||||||
|
* @return FileStorageConfiguration
|
||||||
|
*/
|
||||||
|
public static function getFileStorageConfiguration(): FileStorageConfiguration
|
||||||
|
{
|
||||||
|
if(self::$fileStorageConfiguration === null)
|
||||||
|
{
|
||||||
|
self::initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return self::$fileStorageConfiguration;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
47
src/FederationServer/Classes/Enums/BlacklistType.php
Normal file
47
src/FederationServer/Classes/Enums/BlacklistType.php
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace FederationServer\Classes\Enums;
|
||||||
|
|
||||||
|
enum BlacklistType : string
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Spam or automated spam content.
|
||||||
|
*/
|
||||||
|
case SPAM = 'SPAM';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scam content, such as fraudulent schemes or deceptive practices.
|
||||||
|
*/
|
||||||
|
case SCAM = 'SCAM';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abuse of the service, such as harassment or threats.
|
||||||
|
*/
|
||||||
|
case SERVICE_ABUSE = 'SERVICE_ABUSE';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Illegal content, such as content that violates laws or regulations.
|
||||||
|
*/
|
||||||
|
case ILLEGAL_CONTENT = 'ILLEGAL_CONTENT';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maliciously intended to spread harmful software or viruses.
|
||||||
|
*/
|
||||||
|
case MALWARE = 'MALWARE';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Phishing attempts, such as attempts to steal personal information.
|
||||||
|
*/
|
||||||
|
case PHISHING = 'PHISHING';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Child Sexual Abuse Material (CSAM).
|
||||||
|
*/
|
||||||
|
case CSAM = 'CSAM';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Other types of content that do not fit into the above categories.
|
||||||
|
* Should rarely be used.
|
||||||
|
*/
|
||||||
|
case OTHER = 'OTHER';
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue