Alert media: images/GIFs/videos/sounds tied to donation amount or reward; release tag collision fix
- Alerts\Resolver/Media/Template/AlertMedia/DefInput/DefRepository; Alerts admin screen with Media Library picker and live preview - Overlay: media resolved server-side from attachment IDs (MIME whitelist), playback with timeouts and autoplay-failure fallbacks - Workflow: pick the next free minute if the version tag already exists (two pushes in one minute failed 'Create release') Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1201db175b
commit
2c16a9ebbb
22 files changed
+1591
-22
No files matched your search
@@ -8,8 +8,24 @@ final class OverlayService {
|
||||
|
||||
public const WIDGETS = array( 'goal', 'timer', 'counter', 'alerts', 'actions' );
|
||||
|
||||
/** @var array<int,array<string,mixed>>|null */
|
||||
private ?array $defs = null;
|
||||
|
||||
public function __construct( private OverlayDataSource $source ) {}
|
||||
|
||||
/** Enabled alert definitions, loaded at most once per service instance (= per request). */
|
||||
private function defs(): array {
|
||||
if ( null === $this->defs ) {
|
||||
$this->defs = $this->source instanceof AlertMediaSource ? array_values( $this->source->alertDefs() ) : array();
|
||||
}
|
||||
return $this->defs;
|
||||
}
|
||||
|
||||
/** Extra ETag input so editing media definitions invalidates cached alert payloads even when no alert is pending. */
|
||||
public function etagSalt( string $widget ): string {
|
||||
return 'alerts' === $widget && $this->defs() ? md5( (string) json_encode( $this->defs() ) ) : '';
|
||||
}
|
||||
|
||||
public function payload( string $widget, int $now, ?int $since = null, bool $recent = false ): ?array {
|
||||
$goal = $this->source->activeGoal();
|
||||
$gid = $goal ? (int) $goal['id'] : 0;
|
||||
@@ -43,7 +59,16 @@ final class OverlayService {
|
||||
$rows[ $i ]['bonuses'] = $bonuses[ (int) ( $r['id'] ?? 0 ) ] ?? array();
|
||||
$rows[ $i ]['actions'] = $actions[ (int) ( $r['id'] ?? 0 ) ] ?? array();
|
||||
}
|
||||
return Payloads::alerts( $rows, $since, $recent ? 20 : 10, $recent );
|
||||
$mediaFor = null;
|
||||
$defs = ( $recent || null !== $since ) ? $this->defs() : array();
|
||||
if ( $defs && $ids && $this->source instanceof AlertMediaSource ) {
|
||||
$src = $this->source;
|
||||
$triggered = $src->triggeredActionsFor( $ids );
|
||||
$mediaFor = static fn( array $r, string $name, string $amount ): ?array => \StreamGoals\Alerts\AlertMedia::build(
|
||||
$r, $name, $amount, $defs, $triggered[ (int) ( $r['id'] ?? 0 ) ] ?? array(), static fn( int $id ): ?array => $src->attachment( $id )
|
||||
);
|
||||
}
|
||||
return Payloads::alerts( $rows, $since, $recent ? 20 : 10, $recent, $mediaFor );
|
||||
case 'actions':
|
||||
$rows = ( $gid && $this->source instanceof ActionsSource ) ? $this->source->menuActions( $gid ) : array();
|
||||
return Payloads::actionsMenu( $goal, $rows );
|
||||
|
||||
Reference in new issue
Block a user