Fix relay banner live delivery and view retries

Signed-off-by: coder 0 <d97ebdbb198c7237c94f84ea8bb8a73583ea067407eebd0062abbb3962527fb1@buzz.block.builderlab.xyz>
This commit is contained in:
coder 0
2026-09-17 11:00:05 -04:00
parent 1ddbc0ef77
commit bd4bb3bae6
8 changed files with 1068 additions and 75 deletions

View File

@@ -1757,10 +1757,23 @@ CREATE TABLE relay_banner_user_state (
CREATE INDEX idx_relay_banner_user_state_pubkey
ON relay_banner_user_state (community_id, pubkey, banner_id);
CREATE TABLE relay_banner_view_acks (
banner_id BIGINT NOT NULL REFERENCES relay_banners(id) ON DELETE CASCADE,
community_id UUID NOT NULL REFERENCES communities(id) ON DELETE CASCADE,
pubkey BYTEA NOT NULL CHECK (length(pubkey) = 32),
view_id UUID NOT NULL,
viewed_at TIMESTAMPTZ NOT NULL DEFAULT now(),
PRIMARY KEY (banner_id, community_id, pubkey, view_id)
);
CREATE INDEX idx_relay_banner_view_acks_pubkey
ON relay_banner_view_acks (community_id, pubkey, banner_id);
INSERT INTO _operator_global_tables (table_name, reason) VALUES
('relay_banners', 'deployment-global operator-configured banner; no community_id intentionally'),
('relay_banner_communities', 'deployment-global banner targeting allowlist; community_id is target provenance only'),
('relay_banner_user_state', 'deployment-global per-user banner display state; community_id scopes the targeted impression only');
('relay_banner_user_state', 'deployment-global per-user banner display state; community_id scopes the targeted impression only'),
('relay_banner_view_acks', 'deployment-global per-render banner idempotency keys; community_id scopes the targeted impression only');
-- Attach the universal fence to every existing table carrying community_id,
@@ -1814,6 +1827,7 @@ SELECT attach_community_write_fence('relay_invites');
SELECT attach_community_write_fence('relay_members');
SELECT attach_community_write_fence('relay_banner_communities');
SELECT attach_community_write_fence('relay_banner_user_state');
SELECT attach_community_write_fence('relay_banner_view_acks');
SELECT attach_community_write_fence('scheduled_workflow_fires');
SELECT attach_community_write_fence('subscriptions');
SELECT attach_community_write_fence('thread_metadata');