Multiple meeting lobbies and beta-gated features (3.5.2)
- /meeting add-lobby, remove-lobby, lobbies: up to 10 lobbies per server, capped in the database - Deleted voice channels are dropped from the lobbies - Beta features: registered only in the beta server and usable only with the Beta Tester role (BETA_GUILD_ID, BETA_ROLE_ID); fails closed - /beta (bot owner only) shows how beta access is set up Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
1 parent
136377d81a
commit
a364435bab
15 files changed
+789
-52
No files matched your search
+27
@@ -73,6 +73,33 @@ CREATE TABLE IF NOT EXISTS meeting_settings (
|
||||
lobby_channel_id BIGINT
|
||||
);
|
||||
|
||||
-- A server can have several lobbies (at most 10; the trigger enforces it, and
|
||||
-- is the same as the API's migration 000020). meeting_settings.lobby_channel_id
|
||||
-- is the old single-lobby column, no longer read.
|
||||
CREATE TABLE IF NOT EXISTS meeting_lobbies (
|
||||
guild_id BIGINT NOT NULL,
|
||||
channel_id BIGINT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
PRIMARY KEY (guild_id, channel_id)
|
||||
);
|
||||
|
||||
CREATE OR REPLACE FUNCTION meeting_lobbies_limit() RETURNS trigger AS $$
|
||||
BEGIN
|
||||
PERFORM pg_advisory_xact_lock(NEW.guild_id);
|
||||
IF EXISTS (SELECT 1 FROM meeting_lobbies WHERE guild_id = NEW.guild_id AND channel_id = NEW.channel_id) THEN
|
||||
RETURN NEW;
|
||||
END IF;
|
||||
IF (SELECT COUNT(*) FROM meeting_lobbies WHERE guild_id = NEW.guild_id) >= 10 THEN
|
||||
RAISE EXCEPTION 'a server can have at most 10 lobby channels' USING ERRCODE = '54000';
|
||||
END IF;
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
DROP TRIGGER IF EXISTS meeting_lobbies_limit ON meeting_lobbies;
|
||||
CREATE TRIGGER meeting_lobbies_limit BEFORE INSERT ON meeting_lobbies
|
||||
FOR EACH ROW EXECUTE FUNCTION meeting_lobbies_limit();
|
||||
|
||||
CREATE TABLE IF NOT EXISTS meeting_temp_channels (
|
||||
guild_id BIGINT NOT NULL,
|
||||
channel_id BIGINT NOT NULL,
|
||||
|
||||
Reference in new issue
Block a user