Skip to content

Commit d948367

Browse files
committed
updated secure streams cache policy
Change-Id: Ia71aa475a26c218666eb1bd14ef4f3c2ba3bff3a
1 parent 257da8b commit d948367

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

app/ModelSerializers/Summit/SummitEventSecureStreamSerializer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public function serialize($expand = null, array $fields = [], array $relations =
4040
if (!count($relations)) $relations = $this->getAllowedRelations();
4141
if(!count($fields)) $fields = $this->getAllowedFields();
4242

43-
$key = sprintf("event_%s_secure_stream", $event->getId());
43+
$key = $event->getSecureStreamCacheKey();
44+
4445
Log::debug(sprintf("SummitEventSecureStreamSerializer::serialize cache key %s", $key));
4546

4647
if(Cache::has($key)){

app/Models/Foundation/Summit/Events/SummitEvent.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Doctrine\Common\Collections\ArrayCollection;
2525
use Doctrine\Common\Collections\Criteria;
2626
use Doctrine\ORM\Mapping as ORM;
27+
use Illuminate\Support\Facades\Cache;
2728
use Illuminate\Support\Facades\Config;
2829
use Illuminate\Support\Facades\Log;
2930
use models\exceptions\ValidationException;
@@ -1216,6 +1217,8 @@ public function getStreamDuration():int{
12161217
public function setStreamingUrl(?string $streaming_url): void
12171218
{
12181219
$this->streaming_url = $streaming_url;
1220+
$key = $this->getSecureStreamCacheKey();
1221+
if(Cache::has($key)) Cache::forget($key);
12191222
}
12201223

12211224
/**
@@ -1458,6 +1461,8 @@ public function setStreamingType(string $streaming_type): void
14581461
if (!in_array($streaming_type, self::ValidStreamingTypes))
14591462
throw new ValidationException(sprintf("%s is not a valid streaming type", $streaming_type));
14601463
$this->streaming_type = $streaming_type;
1464+
$key = $this->getSecureStreamCacheKey();
1465+
if(Cache::has($key)) Cache::forget($key);
14611466
}
14621467

14631468
/**
@@ -1570,6 +1575,10 @@ public function IsSecureStream(): bool
15701575
return $this->stream_is_secure;
15711576
}
15721577

1578+
public function getSecureStreamCacheKey():string{
1579+
return sprintf("event_%s_secure_stream", $this->id);
1580+
}
1581+
15731582
/**
15741583
* @param bool $stream_is_secure
15751584
*/
@@ -1578,6 +1587,9 @@ public function setStreamIsSecure(bool $stream_is_secure): void
15781587
Log::debug(sprintf("SummitEvent::setStreamIsSecure summit %s event %s stream_is_secure %s", $this->summit->getId(), $this->id, $stream_is_secure));
15791588
$this->stream_is_secure = $stream_is_secure;
15801589

1590+
$key = $this->getSecureStreamCacheKey();
1591+
if(Cache::has($key)) Cache::forget($key);
1592+
15811593
if($this->hasSummit() && $this->stream_is_secure && !$this->summit->hasMuxPrivateKey())
15821594
CreateMUXURLSigningKeyForSummit::dispatch($this->summit->getId());
15831595
}

0 commit comments

Comments
 (0)