mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-23 00:21:28 +00:00
fix: allow duplicate route IDs across groups and add group_id to send_logs
- Change validateRoutes to per-group ID uniqueness instead of global - Remove post-merge cross-group route ID uniqueness checks - Include groupId in msg:* KV key to prevent collision - Add group_id column to send_logs table (migration 0004) - Record groupId in send_logs for accurate permission filtering - Use groupId from log entries for admin log access checks
This commit is contained in:
parent
ab98c84896
commit
03eef7ae89
5 changed files with 26 additions and 29 deletions
|
|
@ -69,6 +69,7 @@ export async function dispatchEvent(config: Config, event: WebhookEvent, env: En
|
|||
const base: {
|
||||
ts: number;
|
||||
routeId: string;
|
||||
groupId: string | undefined;
|
||||
event: string;
|
||||
repo: string | undefined;
|
||||
target: string;
|
||||
|
|
@ -78,6 +79,7 @@ export async function dispatchEvent(config: Config, event: WebhookEvent, env: En
|
|||
} = {
|
||||
ts: Date.now(),
|
||||
routeId: route.id,
|
||||
groupId: route.groupId,
|
||||
event: event.event,
|
||||
repo: (event.payload.repository as { full_name?: string } | undefined)?.full_name,
|
||||
target: targetStr,
|
||||
|
|
@ -91,7 +93,8 @@ export async function dispatchEvent(config: Config, event: WebhookEvent, env: En
|
|||
const driver = getDriver(target);
|
||||
let result: SendResult;
|
||||
if (message.updateKey) {
|
||||
const kvKey = `msg:${route.id}:${message.updateKey}:${targetStr}`;
|
||||
const groupPrefix = route.groupId ? `${route.groupId}:` : "";
|
||||
const kvKey = `msg:${groupPrefix}${route.id}:${message.updateKey}:${targetStr}`;
|
||||
const existingId = await env.KV.get(kvKey);
|
||||
if (existingId) {
|
||||
result = await driver.edit(message, target, env, existingId);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue