Add Replay button to show a donation alert again
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:
1 parent
96bae1cbf9
commit
971a4ac482
12 files changed
+258
-10
No files matched your search
@@ -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(
|
||||
|
||||
Reference in new issue
Block a user