Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c6d93ad5f | ||
|
|
da1365f060 | ||
|
|
f8d6bc2195 |
No files matched your search
@@ -45,6 +45,12 @@ with the Live credentials and switch the mode to Live in Settings.
|
||||
or a bonus event above a minimum amount. Amounts can be measured on the base donation or including fee cover.
|
||||
- **Overlays:** StreamGoals → Overlays. Copy a widget URL into OBS as a **Browser Source** (suggested 800×200
|
||||
for the goal bar; transparent background is built in). Keep the URL private; "Regenerate token" invalidates it.
|
||||
- **Rewards (actions for set amounts):** StreamGoals > Rewards. Add things you do on stream for a set amount, for example
|
||||
"$5: eat an every-flavor bean" or "$25: 25 pushups". Each reward is either *exactly this amount* or *every time the
|
||||
donation adds up to this amount* (a $10 donation triggers a $5 reward twice). Rewards appear as buttons on the donation
|
||||
form, as a **Rewards menu** overlay for OBS, and as a highlighted line in the donation alert. Triggered rewards land in a
|
||||
**queue** on the Rewards screen so you can tick them off as you do them. Rewards count the donation amount, not the
|
||||
optional fee cover, and must be at least your minimum donation.
|
||||
- **Test:** "Send test donation" on the Overlays screen shows an alert without touching real totals.
|
||||
|
||||
## Privacy and moderation
|
||||
|
||||
@@ -73,3 +73,11 @@ PHP (namespace `StreamGoals\Actions`):
|
||||
- `Recorder::forDonation(int $donationId): void` — called after a donation becomes `completed` (same place the rules engine is applied); matches on the donation's BASE amount (not fee cover) using the goal's enabled actions and records events. Never throws.
|
||||
Public/overlay: the donate form shows each enabled action as a button (amount + title); the overlay has a new `actions` widget (the menu for the active goal) and alert payloads gain `actions`: `[ {title, times} ]` read from sg_action_events (anonymous donors' actions are still shown; names stay masked).
|
||||
Amounts must be >= Settings::effectiveMin().
|
||||
|
||||
## Schema v3 (Installer, DB_VERSION 3)
|
||||
- `sg_goals.close_at_target` TINYINT: when 1, the goal is closed to donors as soon as its raised total reaches or exceeds the target (status becomes `complete`, same as the manual "Complete" action).
|
||||
- `sg_alert_defs` — owner-defined alert presentations (media from the WordPress Media Library; attachment ids, never raw URLs):
|
||||
id, goal_id (0 = all goals), trigger_type `amount` | `reward`, min_minor (for `amount`: applies when the donation BASE amount >= min_minor; the highest matching min_minor wins),
|
||||
action_id (for `reward`: applies when that reward triggered; a reward definition wins over an amount definition), title (admin label),
|
||||
visual_id + visual_type (`image` | `video` | '' none), sound_id (audio attachment, 0 none), volume 0-100, duration_ms (how long an image/GIF stays; videos play to the end, capped),
|
||||
message (template with {name} {amount} {reward}; '' = default text), enabled, sort, created_at.
|
||||
@@ -8,7 +8,7 @@ namespace StreamGoals\Core;
|
||||
*/
|
||||
final class Installer {
|
||||
|
||||
public const DB_VERSION = '2';
|
||||
public const DB_VERSION = '3';
|
||||
|
||||
public static function activate(): void {
|
||||
self::install_schema();
|
||||
@@ -39,6 +39,7 @@ final class Installer {
|
||||
starts_at DATETIME NULL,
|
||||
ends_at DATETIME NULL,
|
||||
counts_fees TINYINT(1) NOT NULL DEFAULT 0,
|
||||
close_at_target TINYINT(1) NOT NULL DEFAULT 0,
|
||||
created_at DATETIME NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
) $c;" );
|
||||
@@ -122,6 +123,26 @@ final class Installer {
|
||||
KEY status_id (status,id)
|
||||
) $c;" );
|
||||
|
||||
dbDelta( "CREATE TABLE {$p}alert_defs (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
goal_id BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
trigger_type VARCHAR(8) NOT NULL DEFAULT 'amount',
|
||||
min_minor BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
action_id BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
title VARCHAR(120) NOT NULL DEFAULT '',
|
||||
visual_id BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
visual_type VARCHAR(6) NOT NULL DEFAULT '',
|
||||
sound_id BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
volume TINYINT UNSIGNED NOT NULL DEFAULT 80,
|
||||
duration_ms INT UNSIGNED NOT NULL DEFAULT 6000,
|
||||
message VARCHAR(255) NOT NULL DEFAULT '',
|
||||
enabled TINYINT(1) NOT NULL DEFAULT 1,
|
||||
sort INT NOT NULL DEFAULT 0,
|
||||
created_at DATETIME NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
KEY goal_enabled (goal_id,enabled)
|
||||
) $c;" );
|
||||
|
||||
update_option( 'sg_db_version', self::DB_VERSION );
|
||||
}
|
||||
}
|
||||
@@ -67,7 +67,8 @@ final class ActionRepositoryTest extends TestCase {
|
||||
|
||||
public function test_installer_schema_defines_both_tables_and_unique_key(): void {
|
||||
$src = (string) file_get_contents( dirname( __DIR__, 2 ) . '/includes/Core/Installer.php' );
|
||||
$this->assertStringContainsString( "DB_VERSION = '2'", $src );
|
||||
$this->assertSame( 1, preg_match( "/DB_VERSION = '(\\d+)'/", $src, $m ), 'DB_VERSION constant not found' );
|
||||
$this->assertGreaterThanOrEqual( 2, (int) $m[1], 'the actions tables arrived in schema version 2; later versions must keep them' );
|
||||
$this->assertStringContainsString( 'CREATE TABLE {$p}actions (', $src );
|
||||
$this->assertStringContainsString( 'CREATE TABLE {$p}action_events (', $src );
|
||||
$this->assertStringContainsString( 'UNIQUE KEY donation_action (donation_id,action_id)', $src );
|
||||
|
||||
Reference in new issue
Block a user