fix(sidebar): gate outbox+webhook badge polls on INTERNAL scope (no more 403 spam)

This commit is contained in:
Александр Зимин
2026-05-14 22:41:28 +00:00
parent 55a1171ac4
commit ac74a8fbd9
3 changed files with 68 additions and 8 deletions
+15 -2
View File
@@ -372,7 +372,13 @@ export const outboxStatsQuery = queryOptions({
refetchInterval: 30_000,
})
export const useOutboxStats = () => useQuery(outboxStatsQuery)
/**
* Outbox stats poll. Backend gate INTERNAL scope — пользователь без
* нужной роли получает 403. Передавай {@code enabled=false} для
* unauthenticated/non-INTERNAL users чтобы не спамить console 403'ами.
*/
export const useOutboxStats = (enabled = true) =>
useQuery({ ...outboxStatsQuery, enabled })
export const dlqQuery = (page: number, size: number) =>
queryOptions({
@@ -399,7 +405,14 @@ export const webhookSubscriptionsQuery = queryOptions({
},
})
export const useWebhookSubscriptions = () => useQuery(webhookSubscriptionsQuery)
/**
* Webhook subscriptions list. INTERNAL-scoped (admin/webhooks/...). Same
* pattern as {@link useOutboxStats} — pass {@code enabled=false} для
* pollers (Sidebar badge) когда user не имеет INTERNAL scope, чтобы
* избежать 403 spam.
*/
export const useWebhookSubscriptions = (enabled = true) =>
useQuery({ ...webhookSubscriptionsQuery, enabled })
export const webhookSubscriptionQuery = (id: string) =>
queryOptions({