mirror of
https://github.com/Elysola/WebHooker.git
synced 2026-11-21 01:23:40 +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:
1 parent
ab98c84896
commit
03eef7ae89
5 files changed
+26
-29
No files matched your search
+7
-3
@@ -4,6 +4,7 @@ export interface SendRecord {
|
||||
id?: number;
|
||||
ts: number;
|
||||
routeId: string;
|
||||
groupId?: string;
|
||||
event: string;
|
||||
repo?: string;
|
||||
target: string;
|
||||
@@ -22,12 +23,13 @@ export interface SendRecord {
|
||||
}
|
||||
|
||||
const COLUMNS =
|
||||
"id, ts, route_id, event, repo, target, ok, error, status, message_id, delivery_id, platform, actor, action, duration_ms, error_code, attempts, detail";
|
||||
"id, ts, route_id, group_id, event, repo, target, ok, error, status, message_id, delivery_id, platform, actor, action, duration_ms, error_code, attempts, detail";
|
||||
|
||||
interface LogRow {
|
||||
id: number;
|
||||
ts: number;
|
||||
route_id: string;
|
||||
group_id: string | null;
|
||||
event: string;
|
||||
repo: string | null;
|
||||
target: string;
|
||||
@@ -50,6 +52,7 @@ function toRecord(r: LogRow): SendRecord {
|
||||
id: r.id,
|
||||
ts: r.ts,
|
||||
routeId: r.route_id,
|
||||
groupId: r.group_id ?? undefined,
|
||||
event: r.event,
|
||||
repo: r.repo ?? undefined,
|
||||
target: r.target,
|
||||
@@ -72,12 +75,13 @@ export async function recordSend(db: D1Database, record: SendRecord): Promise<vo
|
||||
try {
|
||||
await db
|
||||
.prepare(
|
||||
`INSERT INTO send_logs (ts, route_id, event, repo, target, ok, error, status, message_id, delivery_id, platform, actor, action, duration_ms, error_code, attempts, detail)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
`INSERT INTO send_logs (ts, route_id, group_id, event, repo, target, ok, error, status, message_id, delivery_id, platform, actor, action, duration_ms, error_code, attempts, detail)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
)
|
||||
.bind(
|
||||
record.ts,
|
||||
record.routeId,
|
||||
record.groupId ?? null,
|
||||
record.event,
|
||||
record.repo ?? null,
|
||||
record.target,
|
||||
|
||||
Reference in new issue
Block a user