Add Replay button to show a donation alert again
Test and Release / test (push) Successful in 6m43s
Test and Release / release (push) Successful in 24s

Donations > Replay queues the alert for the open alerts overlay. Requests
expire after 60 seconds, play once, and never re-apply totals, timers,
counters, rewards or tiers. Held, rejected and pending donations are excluded.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
shadowdaoandClaude Sonnet 5.5 committed 2026-11-27 21:21:19 -08:00
1 parent 96bae1cbf9
commit 971a4ac482
12 files changed
+258 -10

No files matched your search

+19 -1
View File
@@ -4,7 +4,7 @@ declare( strict_types=1 );
namespace StreamGoals\Overlay;
/** $wpdb adapter reading sg_goals, sg_donations, sg_state, sg_rules directly. */
final class WpdbDataSource implements OverlayDataSource, RecentDonationsSource, ActionsSource, AlertMediaSource, TiersSource {
final class WpdbDataSource implements OverlayDataSource, RecentDonationsSource, ActionsSource, AlertMediaSource, TiersSource, ReplaySource {
/** @var array<int,?array{url:string,mime:string,v:int,modified:string}> */
private array $attachments = array();
@@ -184,6 +184,24 @@ final class WpdbDataSource implements OverlayDataSource, RecentDonationsSource,
return (array) $rows;
}
public function pendingReplays( int $now ): array {
return Replays::pending( $now );
}
public function donationsByIds( array $ids ): array {
global $wpdb;
$ids = array_values( array_unique( array_filter( array_map( 'intval', $ids ), static fn( $i ) => $i > 0 ) ) );
if ( ! $ids ) {
return array();
}
$in = implode( ',', array_fill( 0, count( $ids ), '%d' ) );
return (array) $wpdb->get_results( $wpdb->prepare(
"SELECT id, goal_id, base_minor, currency, donor_name, is_anonymous, message, status, moderation FROM {$this->t('donations')}
WHERE status = 'completed' AND moderation = 'approved' AND id IN ($in)",
$ids
), ARRAY_A );
}
public function recentDonations( int $limit ): array {
global $wpdb;
$rows = $wpdb->get_results( $wpdb->prepare(