feat: allow stripe promotion code - #1887
Conversation
fix veo3 adapter
fix: settings
fix: stripe支付成功未正确跳转
feat: 支持即梦视频3.0,支持文生图, 图生图, 首尾帧生图
fix: openai responses api 未统计图像生成调用计费
fix: VolcEngine渠道-图片生成 API-渠道测试报错
Unify the setup initialization endpoint’s error contract to match the rest
of the project and keep the frontend unchanged.
Changes
- controller/setup.go: Return HTTP 200 with {success:false, message} for all
predictable errors in POST /api/setup, including:
- already initialized
- invalid payload
- username too long
- password mismatch
- password too short
- password hashing failure
- root user creation failure
- option persistence failures (SelfUseModeEnabled, DemoSiteEnabled)
- setup record creation failure
- web/src/components/setup/SetupWizard.jsx: Restore catch handler to the
previous generic toast (frontend logic unchanged).
- web/src/helpers/utils.jsx: Restore the original showError implementation
(no Axios response.data parsing required).
Why
- Keep API behavior consistent across endpoints so the UI can rely on the
success flag and message in the normal .then() flow instead of falling
into Axios 4xx errors that only show a generic "400".
Impact
- UI now displays specific server messages during initialization without
frontend adaptations.
- Note: clients relying solely on HTTP status codes for error handling
should inspect the JSON body (success/message) instead.
No changes to the happy path; initialization success responses are unchanged.
🛠️ fix: Align setup API errors to HTTP 200 with {success:false, message}
- Added useRef to manage dropdown positioning in UserArea component. - Wrapped Dropdown in a div with a ref to ensure correct popup container. - Minor adjustments to maintain existing functionality and styling.
# Conflicts: # service/cf_worker.go
feat: implement SSRF protection settings and update related references
…nd-seperator feat: add thousand separators to token display in dashboard
fix(UserArea): Enhance UserArea dropdown positioning with useRef
feat: add jsconfig.json and configure path aliases
feat: add date range preset constants and use them in the log filter
feat: 新增支持目前已发布的amazon nova model
fix: add missing fields to Gemini request
…el-button feat: `获取模型列表`按钮白名单
fix: 修复多行代码复制换行丢失问题 & 优化API参数处理#1828
WalkthroughAdds a configurable Stripe promotion-codes toggle end-to-end: new setting variable, option map wiring, controller enabling AllowPromotionCodes in Stripe Checkout sessions, and UI controls plus i18n entries to expose the toggle. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as User
participant FE as Frontend (Settings UI)
participant API as API Server
participant C as Controller (genStripeLink)
participant S as Stripe
rect rgb(240,248,255)
Note over FE,API: Configure setting
U->>FE: Toggle "Allow promotion codes"
FE->>API: PUT /options { StripePromotionCodesEnabled: true|false }
API->>API: updateOptionMap parses and saves
API-->>FE: 200 OK
end
rect rgb(245,255,250)
Note over U,S: Checkout flow
U->>FE: Start Stripe top-up
FE->>API: POST /topup/stripe/session
API->>C: genStripeLink()
C->>C: Read setting.StripePromotionCodesEnabled
C->>S: Create Checkout Session { AllowPromotionCodes: bool }
S-->>C: Session URL
C-->>FE: Session URL
FE-->>U: Redirect to Stripe Checkout
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
controller/topup_stripe.go(1 hunks)model/option.go(2 hunks)setting/payment_stripe.go(1 hunks)web/src/components/settings/PaymentSetting.jsx(1 hunks)web/src/i18n/locales/en.json(1 hunks)web/src/i18n/locales/zh.json(1 hunks)web/src/pages/Setting/Payment/SettingsPaymentGatewayStripe.jsx(4 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
controller/topup_stripe.go (1)
setting/payment_stripe.go (1)
StripePromotionCodesEnabled(8-8)
model/option.go (2)
common/constants.go (1)
OptionMap(36-36)setting/payment_stripe.go (1)
StripePromotionCodesEnabled(8-8)
web/src/pages/Setting/Payment/SettingsPaymentGatewayStripe.jsx (1)
web/src/components/settings/PaymentSetting.jsx (1)
inputs(30-49)
| StripePromotionCodesEnabled: | ||
| props.options.StripePromotionCodesEnabled !== undefined | ||
| ? props.options.StripePromotionCodesEnabled | ||
| : false, |
There was a problem hiding this comment.
Convert StripePromotionCodesEnabled to a boolean before storing
props.options.StripePromotionCodesEnabled comes back as the string 'true'/'false'. Storing that string causes the switch to render as enabled (any non-empty string is truthy) and, worse, always serializes back to 'true' on submit. We end up flipping the setting on for anyone who tries to leave it off. Parse the incoming option into a real boolean before placing it in state/origin.
- StripePromotionCodesEnabled:
- props.options.StripePromotionCodesEnabled !== undefined
- ? props.options.StripePromotionCodesEnabled
- : false,
+ StripePromotionCodesEnabled:
+ props.options.StripePromotionCodesEnabled !== undefined
+ ? props.options.StripePromotionCodesEnabled === true ||
+ props.options.StripePromotionCodesEnabled === 'true'
+ : false,📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| StripePromotionCodesEnabled: | |
| props.options.StripePromotionCodesEnabled !== undefined | |
| ? props.options.StripePromotionCodesEnabled | |
| : false, | |
| StripePromotionCodesEnabled: | |
| props.options.StripePromotionCodesEnabled !== undefined | |
| ? props.options.StripePromotionCodesEnabled === true || | |
| props.options.StripePromotionCodesEnabled === 'true' | |
| : false, |
🤖 Prompt for AI Agents
In web/src/pages/Setting/Payment/SettingsPaymentGatewayStripe.jsx around lines
67 to 70, StripePromotionCodesEnabled is being set from props.options as a
string ('true'/'false') which results in incorrect truthy behavior and wrong
serialization; convert the incoming value to a real boolean before placing it in
state/origin (e.g., check for strict boolean true or compare the string to
'true' or use JSON.parse-like conversion) so the switch renders correctly and
submits the correct boolean value.
feat: allow stripe promotion code
The hardcoded codex CLI version (0.104.0) causes upstream rejection when using gpt-5.5 with compact, as the server treats the request as an outdated client and returns 400/502. Update codexCLIVersion, codexCLIUserAgent, and openAICodexProbeVersion to 0.125.0 to match the current Codex CLI release. Fixes QuantumNous#1933, QuantumNous#1887, QuantumNous#1865 Related: QuantumNous#1609, QuantumNous#1298, QuantumNous#849
#1869
Summary by CodeRabbit
New Features
Localization