geschenkgutscheine implementiert ("Paket verschenken"). Neuer Upload-Provider: Sparkbooth.
This commit is contained in:
@@ -124,6 +124,79 @@ class PhotoboothProvisioner
|
||||
});
|
||||
}
|
||||
|
||||
public function enableSparkbooth(Event $event, ?PhotoboothSetting $settings = null): Event
|
||||
{
|
||||
$settings ??= PhotoboothSetting::current();
|
||||
$event->loadMissing('tenant');
|
||||
|
||||
return DB::transaction(function () use ($event, $settings) {
|
||||
$username = $this->generateUniqueUsername($event, $settings);
|
||||
$password = $this->credentialGenerator->generatePassword();
|
||||
$path = $this->buildPath($event);
|
||||
$expiresAt = $this->resolveExpiry($event, $settings);
|
||||
|
||||
$event->forceFill([
|
||||
'photobooth_enabled' => true,
|
||||
'photobooth_mode' => 'sparkbooth',
|
||||
'sparkbooth_username' => $username,
|
||||
'sparkbooth_password' => $password,
|
||||
'sparkbooth_expires_at' => $expiresAt,
|
||||
'sparkbooth_status' => 'active',
|
||||
'photobooth_path' => $path,
|
||||
'sparkbooth_uploads_last_24h' => 0,
|
||||
])->save();
|
||||
|
||||
return tap($event->refresh(), function (Event $refreshed) use ($password) {
|
||||
$refreshed->setAttribute('plain_sparkbooth_password', $password);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public function rotateSparkbooth(Event $event, ?PhotoboothSetting $settings = null): Event
|
||||
{
|
||||
$settings ??= PhotoboothSetting::current();
|
||||
|
||||
if ($event->photobooth_mode !== 'sparkbooth' || ! $event->sparkbooth_username) {
|
||||
return $this->enableSparkbooth($event, $settings);
|
||||
}
|
||||
|
||||
return DB::transaction(function () use ($event, $settings) {
|
||||
$password = $this->credentialGenerator->generatePassword();
|
||||
$expiresAt = $this->resolveExpiry($event, $settings);
|
||||
|
||||
$event->forceFill([
|
||||
'sparkbooth_password' => $password,
|
||||
'sparkbooth_expires_at' => $expiresAt,
|
||||
'sparkbooth_status' => 'active',
|
||||
'photobooth_enabled' => true,
|
||||
'photobooth_mode' => 'sparkbooth',
|
||||
])->save();
|
||||
|
||||
return tap($event->refresh(), function (Event $refreshed) use ($password) {
|
||||
$refreshed->setAttribute('plain_sparkbooth_password', $password);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public function disableSparkbooth(Event $event): Event
|
||||
{
|
||||
return DB::transaction(function () use ($event) {
|
||||
$event->forceFill([
|
||||
'photobooth_enabled' => false,
|
||||
'photobooth_mode' => 'ftp',
|
||||
'sparkbooth_username' => null,
|
||||
'sparkbooth_password' => null,
|
||||
'sparkbooth_expires_at' => null,
|
||||
'sparkbooth_status' => 'inactive',
|
||||
'sparkbooth_last_upload_at' => null,
|
||||
'sparkbooth_uploads_last_24h' => 0,
|
||||
'sparkbooth_uploads_total' => 0,
|
||||
])->save();
|
||||
|
||||
return $event->refresh();
|
||||
});
|
||||
}
|
||||
|
||||
protected function resolveExpiry(Event $event, PhotoboothSetting $settings): CarbonInterface
|
||||
{
|
||||
$eventEnd = $event->date ? Carbon::parse($event->date) : now();
|
||||
@@ -143,6 +216,7 @@ class PhotoboothProvisioner
|
||||
|
||||
$exists = Event::query()
|
||||
->where('photobooth_username', $username)
|
||||
->orWhere('sparkbooth_username', $username)
|
||||
->whereKeyNot($event->getKey())
|
||||
->exists();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user