Discord: add reaction notification allowlist

This commit is contained in:
Shadow
2026-01-03 12:29:39 -06:00
committed by Peter Steinberger
parent cdfbd6e7eb
commit 451174ca10
11 changed files with 210 additions and 7 deletions

View File

@@ -197,6 +197,13 @@ export function applyConfigSnapshot(state: ConfigState, snapshot: ConfigSnapshot
typeof entry.requireMention === "boolean"
? entry.requireMention
: false,
reactionNotifications:
entry.reactionNotifications === "off" ||
entry.reactionNotifications === "all" ||
entry.reactionNotifications === "own" ||
entry.reactionNotifications === "allowlist"
? entry.reactionNotifications
: "allowlist",
users: toList(entry.users),
channels,
};

View File

@@ -292,6 +292,14 @@ export async function saveDiscordConfig(state: ConnectionsState) {
const slug = String(guild.slug ?? "").trim();
if (slug) entry.slug = slug;
if (guild.requireMention) entry.requireMention = true;
if (
guild.reactionNotifications === "off" ||
guild.reactionNotifications === "all" ||
guild.reactionNotifications === "own" ||
guild.reactionNotifications === "allowlist"
) {
entry.reactionNotifications = guild.reactionNotifications;
}
const users = parseList(guild.users);
if (users.length > 0) entry.users = users;
const channels: Record<string, unknown> = {};

View File

@@ -31,6 +31,7 @@ export type DiscordGuildForm = {
key: string;
slug: string;
requireMention: boolean;
reactionNotifications: "off" | "own" | "all" | "allowlist";
users: string;
channels: DiscordGuildChannelForm[];
};

View File

@@ -645,6 +645,26 @@ function renderProvider(
<option value="no">No</option>
</select>
</label>
<label class="field">
<span>Reaction notifications</span>
<select
.value=${guild.reactionNotifications}
@change=${(e: Event) => {
const next = [...props.discordForm.guilds];
next[guildIndex] = {
...next[guildIndex],
reactionNotifications: (e.target as HTMLSelectElement)
.value as "off" | "own" | "all",
};
props.onDiscordChange({ guilds: next });
}}
>
<option value="off">Off</option>
<option value="own">Own</option>
<option value="all">All</option>
<option value="allowlist">Allowlist</option>
</select>
</label>
<label class="field">
<span>Users allowlist</span>
<input
@@ -812,6 +832,7 @@ function renderProvider(
key: "",
slug: "",
requireMention: false,
reactionNotifications: "allowlist",
users: "",
channels: [],
},