Fix share assets, shared photo UI, and live show expiry
This commit is contained in:
@@ -24,6 +24,7 @@ class Event extends Model
|
||||
'name' => 'array',
|
||||
'description' => 'array',
|
||||
'live_show_token_rotated_at' => 'datetime',
|
||||
'live_show_token_expires_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected static function booted(): void
|
||||
@@ -47,6 +48,7 @@ class Event extends Model
|
||||
}
|
||||
|
||||
app(EventJoinTokenService::class)->extendExpiryForEvent($event);
|
||||
$event->refreshLiveShowTokenExpiry();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -164,6 +166,8 @@ class Event extends Model
|
||||
public function ensureLiveShowToken(): string
|
||||
{
|
||||
if (is_string($this->live_show_token) && $this->live_show_token !== '') {
|
||||
$this->refreshLiveShowTokenExpiry();
|
||||
|
||||
return $this->live_show_token;
|
||||
}
|
||||
|
||||
@@ -179,11 +183,34 @@ class Event extends Model
|
||||
$this->forceFill([
|
||||
'live_show_token' => $token,
|
||||
'live_show_token_rotated_at' => now(),
|
||||
'live_show_token_expires_at' => $this->computeLiveShowTokenExpiry(),
|
||||
])->save();
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
public function refreshLiveShowTokenExpiry(): void
|
||||
{
|
||||
if (! is_string($this->live_show_token) || $this->live_show_token === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->forceFill([
|
||||
'live_show_token_expires_at' => $this->computeLiveShowTokenExpiry(),
|
||||
])->saveQuietly();
|
||||
}
|
||||
|
||||
private function computeLiveShowTokenExpiry(): \Carbon\CarbonInterface
|
||||
{
|
||||
$eventDate = $this->date;
|
||||
|
||||
if ($eventDate instanceof \Carbon\CarbonInterface) {
|
||||
return $eventDate->copy()->addDay()->endOfDay();
|
||||
}
|
||||
|
||||
return now()->addDay();
|
||||
}
|
||||
|
||||
public function getSettingsAttribute($value): array
|
||||
{
|
||||
if (is_array($value)) {
|
||||
|
||||
Reference in New Issue
Block a user