🆙 More fixes 🆙

This commit is contained in:
Remco
2026-01-19 17:32:44 +01:00
parent 3f9e928952
commit 521f9c884c
6 changed files with 46 additions and 30 deletions
@@ -67,6 +67,7 @@ class CreateNewUser implements CreatesNewUsers
'ip_current' => $ip,
'auth_ticket' => '',
'home_room' => (int) (setting('hotel_home_room') ?: 0),
'referral_code' => '',
]);
$user->update([
@@ -134,17 +135,20 @@ class CreateNewUser implements CreatesNewUsers
private function sendDiscordWebhook(string $username, string $ip, string $email): void
{
if (setting('discord_webhook_url') === '') {
Log::error('Discord webhook url not provided', ['Please provide a discord webhook url before being able to send any webhook requests.']);
Log::error('Discord webhook url not provided', [
'message' => 'Please provide a discord webhook url before being able to send any webhook requests.',
]);
return;
}
$request = Http::asJson()->post(setting('discord_webhook_url'), [
'username' => sprintf('%s Bot', setting('hotel_name')),
'content' => "User: {$username} has just registered, with the IP: {$ip} and E-mail: {$email}",
]);
$request = Http::asJson()->post(
url: setting('discord_webhook_url'),
data: [
'username' => sprintf('%s Bot', setting('hotel_name')),
'content' => "User: {$username} has just registered, with the IP: {$ip} and E-mail: {$email}",
]
);
// Log the error in-case webhook wasn't sent
if (! $request->successful()) {
Log::error('Failed to send Discord webhook notification', [
'username' => $username,
@@ -8,7 +8,6 @@ class UserObserver
{
public function created(User $user): void
{
// We voegen haakjes toe zodat PHP 8.5 de volgorde begrijpt
$isHcEnabled = (setting('give_hc_on_register') ?: '0') === '1';
$user->settings()->create([
@@ -8,14 +8,14 @@ use Illuminate\Support\Facades\Cache;
class PermissionsService
{
public ?Collection $permissions;
public private(set) ?Collection $permissions;
public function __construct()
{
$this->permissions = Cache::remember(
'website_permissions',
now()->addMinutes(30),
fn () => WebsitePermission::all()->pluck('min_rank', 'permission')
key: 'website_permissions',
ttl: now()->addMinutes(30),
callback: fn () => WebsitePermission::all()->pluck('min_rank', 'permission')
);
}
@@ -37,9 +37,9 @@ class PermissionsService
Cache::forget('website_permissions');
$this->permissions = Cache::remember(
'website_permissions',
now()->addMinutes(30),
fn () => WebsitePermission::all()->pluck('min_rank', 'permission')
key: 'website_permissions',
ttl: now()->addMinutes(30),
callback: fn () => WebsitePermission::all()->pluck('min_rank', 'permission')
);
}
}
+14 -4
View File
@@ -12,7 +12,7 @@ class RconService
{
protected ?Socket $socket = null;
public bool $isConnected = false;
public private(set) bool $isConnected = false;
protected array $config = [];
@@ -28,7 +28,7 @@ class RconService
private function initialize(): void
{
$this->socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$this->socket = @socket_create(domain: AF_INET, type: SOCK_STREAM, protocol: SOL_TCP);
if (! $this->socket) {
$error = socket_strerror(socket_last_error());
@@ -39,8 +39,18 @@ class RconService
return;
}
socket_set_option($this->socket, SOL_SOCKET, SO_RCVTIMEO, ['sec' => 5, 'usec' => 0]);
socket_set_option($this->socket, SOL_SOCKET, SO_SNDTIMEO, ['sec' => 5, 'usec' => 0]);
socket_set_option(
socket: $this->socket,
level: SOL_SOCKET,
option: SO_RCVTIMEO,
value: ['sec' => 5, 'usec' => 0]
);
socket_set_option(
socket: $this->socket,
level: SOL_SOCKET,
option: SO_SNDTIMEO,
value: ['sec' => 5, 'usec' => 0]
);
if (! @socket_connect($this->socket, $this->config['ip'], $this->config['port'])) {
$error = socket_strerror(socket_last_error());
+11 -7
View File
@@ -10,15 +10,17 @@ use Throwable;
class SettingsService
{
public ?Collection $settings;
public private(set) ?Collection $settings;
public function __construct()
{
try {
$this->settings = Cache::remember(
'website_settings',
now()->addMinutes(5),
fn () => Schema::hasTable('website_settings') ? WebsiteSetting::all()->pluck('value', 'key') : collect()
key: 'website_settings',
ttl: now()->addMinutes(5),
callback: fn () => Schema::hasTable('website_settings')
? WebsiteSetting::all()->pluck('value', 'key')
: collect()
);
} catch (Throwable) {
$this->settings = collect();
@@ -40,9 +42,11 @@ class SettingsService
try {
$this->settings = Cache::remember(
'website_settings',
now()->addMinutes(5),
fn () => Schema::hasTable('website_settings') ? WebsiteSetting::all()->pluck('value', 'key') : collect()
key: 'website_settings',
ttl: now()->addMinutes(5),
callback: fn () => Schema::hasTable('website_settings')
? WebsiteSetting::all()->pluck('value', 'key')
: collect()
);
} catch (Throwable) {
$this->settings = collect();
@@ -47,12 +47,11 @@ return new class extends Migration
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn(array_merge([
$table->dropColumn([
'two_factor_secret',
'two_factor_recovery_codes',
], Fortify::confirmsTwoFactorAuthentication() ? [
'two_factor_confirmed_at',
] : []));
...(Fortify::confirmsTwoFactorAuthentication() ? ['two_factor_confirmed_at'] : []),
]);
});
}
};