mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6823] [CLOSED] feat(panel): add server-wide toggle for sponsor content #6465
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#6465
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/6823
Author: @libmur-dev
Created: 10/14/2026
Status: ❌ Closed
Base:
main← Head:feat/persistent-sponsor-opt-out📝 Commits (1)
cf4c9b6feat(panel): add persistent opt-out for sponsor content📊 Changes
39 files changed (+789 additions, -11 deletions)
View changed files
📝
frontend/public/openapi.json(+43 -1)📝
frontend/src/api/queries/useAllSettings.ts(+7 -1)➕
frontend/src/api/queries/useSponsorVisibility.ts(+22 -0)📝
frontend/src/api/queries/useSponsorsQuery.ts(+11 -3)📝
frontend/src/api/queryKeys.ts(+1 -0)➕
frontend/src/components/command-palette/CommandPalette.stories.tsx(+92 -0)📝
frontend/src/components/command-palette/CommandPalette.tsx(+4 -0)📝
frontend/src/generated/examples.ts(+2 -0)📝
frontend/src/generated/schemas.ts(+8 -0)📝
frontend/src/generated/types.ts(+2 -0)📝
frontend/src/generated/zod.ts(+2 -0)📝
frontend/src/layouts/AppSidebar.tsx(+6 -2)📝
frontend/src/models/setting.ts(+1 -0)📝
frontend/src/pages/api-docs/endpoints.ts(+8 -1)📝
frontend/src/pages/settings/GeneralTab.tsx(+17 -0)📝
frontend/src/pages/sponsors/SponsorsPage.tsx(+5 -1)📝
frontend/src/schemas/setting.ts(+1 -0)➕
frontend/src/test/sponsor-opt-out.test.tsx(+179 -0)📝
internal/web/controller/index.go(+14 -1)📝
internal/web/controller/setting.go(+11 -0)...and 19 more files
📄 Description
Summary
Add a persistent Show sponsor ads setting under Settings → General, enabled by default. Administrators can turn it off to remove sponsor content across the panel, including the login page, and stop the server from fetching or serving sponsor lists and logos. They can turn it back on in the same settings screen.
Why
Server owners should be able to decide whether their panel displays sponsor ads and whether their server requests advertising data. The current 24-hour dismissal is stored in the browser. It does not provide a persistent choice for the whole panel or stop advertising requests from the server.
The new setting applies to all browsers and survives restarts and normal updates. Sponsor ads remain enabled by default, preserving the current behavior for owners who leave the setting unchanged.
Closes #6818.
What changed
showSponsorAdsin the existing database settings table, with a default oftrue. No schema migration is required./sponsorsreturns an empty array without advertising contact details, and logo requests return 404. Previously cached content is not served, including when the upstream source is unavailable.GET /sponsors/enabled, without exposing administrative settings. This endpoint and the sponsor list and logo responses useCache-Control: no-store. The internal cache still reduces upstream requests when ads are enabled.showSponsorAds. Update API documentation and generated schemas, and translate the setting label and description into all 13 supported languages, including English and Russian.Type of change / areas affected
How was this tested?
main. Both fail there because sponsor content and advertising contact details are still returned.go build ./..., targeted backend tests, TypeScript checks, lint, formatting, the production frontend build and the Storybook build passed. Tests also passed withgo test -race -shuffle=on -count=1 -p 1forinternal/web/service/panel,internal/web/controllerandinternal/web/service.Some local checks remain unsuccessful:
TestGatewayRequestedHeartbeatDoesNotRaceTickerbecause the socket connection was closed.ERR_CONNECTION_REFUSED. The same failure occurred with an unchanged SponsorCard story onmain; the Storybook build and the separate Chromium checks against the running panel passed.These failures were also reproduced on unchanged
main. The full local test suite has not passed; CI should pass before merging.Screenshots
Screenshots show the setting enabled in English and disabled in Russian, plus the login page with and without sponsor content. All screenshots are from an isolated local panel; the displayed sponsor uses test data.
Setting enabled (English)
Setting disabled (Russian)
Login with sponsor ads enabled
Login with sponsor ads disabled
Breaking changes
None. Sponsor ads are enabled by default. API clients that omit
showSponsorAdsleave the stored value unchanged.Checklist
mainare described above.Русская версия
Добавлена постоянная настройка «Показывать спонсорские объявления» в разделе «Настройки → Общие». По умолчанию она включена. Администратор может отключить её, чтобы убрать рекламу во всей панели, включая страницу входа, и прекратить загрузку и выдачу списка спонсоров и логотипов на сервере. Повторно включить рекламу можно в том же разделе настроек.
Обоснование
Владелец сервера должен сам решать, показывать ли спонсорскую рекламу в панели и загружать ли рекламные данные из внешних источников. Сейчас скрытие рекламы на 24 часа действует только в одном браузере. Такой способ не даёт отключить рекламу для всей панели и не прекращает рекламные запросы сервера.
Новая настройка действует для всех браузеров и сохраняется после перезапусков и штатных обновлений. По умолчанию реклама остаётся включённой: для владельцев, которые не меняют настройку, поведение панели сохраняется.
Изменение закрывает задачу #6818.
Что изменено
showSponsorAdsхранится в существующей таблице настроек БД. Значение по умолчанию —true; миграция схемы не требуется./sponsorsвозвращает пустой массив без контактов для размещения рекламы, а запросы логотипов получают ответ 404. Ранее закэшированная реклама не выдаётся, в том числе при недоступности внешнего источника.GET /sponsors/enabledтолько признак того, включена ли реклама. Административные настройки при этом не раскрываются. Этот ответ, а также ответы со списком спонсоров и логотипами содержатCache-Control: no-store. Когда реклама включена, внутренний кэш по-прежнему сокращает число запросов к внешнему источнику.showSponsorAds, значение в БД не меняется. Обновлены документация API и сгенерированные схемы. Название и описание настройки переведены на все 13 поддерживаемых языков, включая русский и английский.Тип изменения и затронутые части
Проверки
main. Оба завершаются ошибкой: реклама и контакты для её размещения продолжают выдаваться.go build ./..., целевые серверные тесты, проверка типов TypeScript, lint, проверка форматирования, сборка интерфейса для production и сборка Storybook. Дляinternal/web/service/panel,internal/web/controllerиinternal/web/serviceтакже прошли тесты сgo test -race -shuffle=on -count=1 -p 1.Некоторые локальные проверки завершились ошибками:
TestGatewayRequestedHeartbeatDoesNotRaceTickerиз-за закрытия соединения.ERR_CONNECTION_REFUSED. Та же ошибка возникла при проверке неизменённого примера SponsorCard наmain. При этом сборка Storybook и отдельные проверки работающей панели в Chromium прошли.Все перечисленные ошибки воспроизведены и на неизменённом
main. Полный набор локальных тестов не прошёл; перед слиянием должны пройти проверки CI.Скриншоты
Скриншоты показывают включённую настройку на английском, отключённую — на русском и страницу входа с рекламой и без неё. Все скриншоты сделаны в изолированной локальной панели; для показанного спонсора использованы тестовые данные.
Несовместимые изменения
Отсутствуют. По умолчанию спонсорская реклама включена. Если API-клиент не передаёт
showSponsorAds, значение в БД остаётся прежним.Контрольный список
main, описаны выше.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.