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
@@ -154,6 +154,28 @@ final class Payloads {
|
||||
return array( 'alerts' => $alerts, 'last_id' => $lastId );
|
||||
}
|
||||
|
||||
/**
|
||||
* One alert per replay request whose donation is still public, in request order, tagged with the request number.
|
||||
*
|
||||
* @param array<int,array<string,mixed>> $rows
|
||||
* @param array<int,array{seq:int,id:int}> $requests
|
||||
*/
|
||||
public static function replays( array $rows, array $requests, ?callable $mediaFor = null ): array {
|
||||
$byId = array();
|
||||
foreach ( $rows as $r ) {
|
||||
if ( 'completed' === ( $r['status'] ?? '' ) && 'approved' === ( $r['moderation'] ?? '' ) ) {
|
||||
$byId[ (int) $r['id'] ] = $r;
|
||||
}
|
||||
}
|
||||
$out = array();
|
||||
foreach ( $requests as $q ) {
|
||||
if ( isset( $byId[ (int) $q['id'] ] ) ) {
|
||||
$out[] = array( 'replay' => (int) $q['seq'] ) + self::alert( $byId[ (int) $q['id'] ], $mediaFor );
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string,mixed> $r
|
||||
* @param (callable(array,string,string):?array)|null $mediaFor Builds the `media` block from (row, public name, amount display).
|
||||
|
||||
Reference in new issue
Block a user