1. 14 Apr, 2026 13 commits
    • erio's avatar
      fix(websearch): improve settings UI and hide config when globally disabled · 889b5b4f
      erio authored
      - API Key show/copy buttons moved inside input field (inline icons)
      - Proxy selector and test button on same row to save vertical space
      - Test opens a dialog modal instead of inline display
      - Hide all websearch config in channels/accounts when global toggle is off
      889b5b4f
    • erio's avatar
      fix(notify): remove percentage threshold from balance notification · cef22c70
      erio authored
      Balance low notification only supports fixed USD amount threshold.
      Percentage threshold is a quota concept, not applicable to balance.
      Reverted threshold_type from admin settings, user profile, and all
      backend/frontend layers. DB fields (balance_notify_threshold_type,
      total_recharged) retained for potential future quota use.
      cef22c70
    • erio's avatar
      fix: address audit findings for websearch and balance notification · 9e33d0c4
      erio authored
      - Fix GetByKeyForAuth not selecting balance notify fields (notifications
        never triggered in gateway path)
      - Fix provider-level ProxyURL never resolved: inject ProxyRepository into
        SettingService, resolve proxy URLs when building Manager
      - Fix admin manual balance adjustment not updating total_recharged
      - Add threshold_type input validation (reject invalid values)
      - Fix user threshold_type inheritance: custom threshold defaults to "fixed"
        instead of inheriting global type (prevents $5 being treated as 5%)
      - Add try-catch for clipboard.writeText (fails on non-HTTPS)
      - Add SetTotalRecharged to user Update for admin balance operations
      9e33d0c4
    • erio's avatar
      feat(notify): add percentage threshold type for balance low notification · f694afbb
      erio authored
      - Add threshold_type field (fixed/percentage) to system and user settings
      - Add total_recharged field to users table, auto-incremented on balance credit
      - Percentage mode: effective threshold = total_recharged × percentage / 100
      - User-level threshold_type inherits from system default when not set
      - Update admin settings UI with radio selector (fixed amount / percentage)
      - Migration: 102_add_balance_notify_threshold_type.sql
      f694afbb
    • erio's avatar
      feat(websearch): settings UI overhaul and quota improvements · d0674e0f
      erio authored
      - Remove Priority field, auto load-balance by quota remaining
      - Replace QuotaRefreshInterval (daily/weekly/monthly) with SubscribedAt
        (subscription date, monthly lazy refresh via Redis TTL)
      - Add collapsible provider cards, API key show/copy, usage progress bar
      - Add test endpoint (POST /web-search-emulation/test) bypassing quota
      - Wire WebSearchManagerBuilder on startup (was never called before)
      - Fix nextMonthlyReset day-of-month overflow (Jan 31 → Feb 28)
      - Fix non-deterministic sort in selectByQuotaWeight
      - Map ProxyID in builder for provider-level proxy tracking
      - Fix frontend timezone drift in subscribed_at date picker
      - Fix provider deletion index shift for expandedProviders state
      d0674e0f
    • erio's avatar
      fix(notify): address review findings - accountCost formula, dedup, refactor · c3812ce1
      erio authored
      - Fix accountCost calculation in finalizePostUsageBilling to match
        postUsageBilling (always multiply by AccountRateMultiplier)
      - Use strings.EqualFold for email dedup in collectBalanceNotifyRecipients
      - Extract CheckAccountQuotaAfterIncrement into smaller functions:
        buildQuotaDims + asyncSendQuotaAlert (< 30 lines each)
      - Add "not splittable" comments for HTML template functions
      - Extract QuotaNotifyToggle.vue sub-component to reduce
        QuotaLimitCard.vue from 404 to 339 lines
      c3812ce1
    • erio's avatar
      feat(notify): add balance low & account quota notification system · b32d1a2c
      erio authored
      - User balance low notification: email alert when balance drops below
        configurable threshold (user email + verified extra emails)
      - Account quota notification: broadcast email to admin-configured
        recipients when daily/weekly/total quota usage exceeds alert threshold
      - Admin settings: global enable/disable, default threshold, quota
        notification email list (Email Settings tab)
      - User profile: enable/disable, custom threshold, add/remove extra
        notification emails with verification code flow
      - Account quota: per-dimension alert toggle and threshold in quota
        control card
      - Trigger logic: first-crossing only (old >= threshold && new < threshold
        for balance; old < threshold && new >= threshold for quota), naturally
        prevents duplicate notifications without Redis dedup
      b32d1a2c
    • erio's avatar
      feat(channels): add custom account stats pricing rules · 7535e312
      erio authored
      Allow channels to configure independent model pricing for account
      statistics cost calculation, decoupled from user billing.
      
      Backend:
      - Migration 101: channels.apply_pricing_to_account_stats toggle,
        channel_account_stats_pricing_rules/model_pricing tables,
        usage_logs.account_stats_cost column
      - resolveAccountStatsCost: match rules by group/account, then channel
        pricing, fallback to original formula when unconfigured
      - Integrate into both GatewayService.recordUsageCore and
        OpenAIGatewayService.RecordUsage
      - Update 8 account stats SQL queries to use
        COALESCE(account_stats_cost, total_cost) * account_rate_multiplier
      - 23 unit tests for matching, pricing lookup, and cost calculation
      
      Frontend:
      - Channel edit dialog: toggle + custom rules UI with group/account
        multi-select and pricing entry cards
      - API types and i18n (zh/en)
      7535e312
    • erio's avatar
      feat(gateway): add web search emulation for Anthropic API Key accounts · 1b53ffca
      erio authored
      Inject web search capability for Claude Console (API Key) accounts that
      don't natively support Anthropic's web_search tool. When a pure
      web_search request is detected, the gateway calls Brave Search or Tavily
      API directly and constructs an Anthropic-protocol-compliant SSE/JSON
      response without forwarding to upstream.
      
      Backend:
      - New `pkg/websearch/` SDK: Brave and Tavily provider implementations
        with io.LimitReader, proxy support, and Redis-based quota tracking
        (Lua atomic INCR + TTL, DECR rollback on failure)
      - Global config via `settings.web_search_emulation_config` (JSON) with
        in-process cache + singleflight, input validation, API key merge on
        save, and sanitized API responses
      - Channel-level toggle via `channels.features_config` JSONB column
        (DB migration 101)
      - Account-level toggle via `accounts.extra.web_search_emulation`
      - Request interception in `Forward()` with SSE streaming response
        construction using json.Marshal (no manual string concatenation)
      - Manager hot-reload: `RebuildWebSearchManager()` called on config save
        and startup via `SetWebSearchRedisClient()`
      - 70 unit tests covering providers, manager, config validation,
        sanitization, tool detection, query extraction, and response building
      
      Frontend:
      - Settings → Gateway tab: Web Search Emulation config card with global
        toggle, provider list (add/remove, API key, priority, quota, proxy)
      - Channels → Anthropic tab: web search emulation toggle with global
        state linkage (disabled when global off)
      - Account Create/Edit modals: web search emulation toggle for API Key
        type with Toggle component
      - Full i18n coverage (zh + en)
      1b53ffca
    • erio's avatar
      fix(payment): critical audit fixes for security, idempotency and correctness · c738cfec
      erio authored
      Backend fixes:
      - #1: doSub subscription idempotency via audit log check
      - #2: markFailed only when status=RECHARGING (prevents overwriting COMPLETED)
      - #3: ExpireTimedOutOrders checks upstream payment before expiring
      - #4: Public verify endpoint for payment result page (no auth required)
      - #5: EasyPay QueryOrder returns amount, confirmPayment handles zero amount
      - #6: WxPay notifyUrl priority: request-first, config-fallback
      - #7: EasyPay remove double URL decode in VerifyNotification
      - #8: checkPaid/cancelUpstreamPayment use order's provider instance
      - #9: Amount NaN/Inf/negative validation in order creation and refund
      - #10: Refund amount comparison uses tolerance instead of float64 ==
      - #11: Skip balance deduction on retry when previous rollback failed
      - #12: checkPaid logs fulfillment errors instead of silently ignoring
      - #13: WxPay certSerial added to required config fields
      
      Frontend fixes:
      - Payment result page no longer requires authentication
      - Public verify API fallback for expired sessions
      c738cfec
    • erio's avatar
      fix: audit fixes - magic strings to constants, frontend any/catch, LB tests · 56e4a9a9
      erio authored
      Backend:
      - Define OrderTypeBalance/Subscription, EntityStatusActive, DeductionType*,
        NotificationStatus* constants in payment/types.go
      - Replace all magic strings in payment_order, payment_fulfillment, payment_refund
      - Add local constants in easypay.go (tradeStatusSuccess, signTypeMD5)
      - Add 27 unit tests for load balancer (filterByLimits, pickLeastAmount,
        getInstanceChannelLimits, startOfDay)
      
      Frontend:
      - Remove all `any` types in SettingsView.vue (18 catch blocks + 1 payload)
      - Fix bare catch blocks in PaymentResultView, PaymentView
      - Add `unknown` type annotation to all catch blocks
      
      chore: bump version to 0.1.108.140
      56e4a9a9
    • erio's avatar
      fix(payment): audit fixes for alipay/wxpay/stripe payment providers · 5bae3b05
      erio authored
      Backend:
      - Extract YuanToFen/FenToYuan to payment/amount.go using shopspring/decimal
      - Require alipay publicKey in config validation
      - Fix wxpay webhook response to return JSON per V3 spec
      - Remove wxpay certSerial fallback to publicKeyId
      - Define magic strings as named constants in wxpay/alipay providers
      - Add slog warning for wxpay H5→Native payment downgrade
      - Make EncryptionKey validation return error on invalid (non-empty) key
      - Make decryptConfig propagate errors instead of returning nil
      - Add idempotency check in doBalance to prevent stuck FAILED retries
      
      Frontend:
      - Fix dashboard currency symbol from $ to ¥
      - Fix AdminPaymentPlansView any type to proper SubscriptionPlan type
      - Make quick amount buttons follow selected payment method limits
      - Center help image with larger height and text below
      5bae3b05
    • erio's avatar
  2. 13 Apr, 2026 2 commits
  3. 12 Apr, 2026 3 commits
  4. 11 Apr, 2026 11 commits
    • erio's avatar
    • erio's avatar
    • erio's avatar
    • erio's avatar
      chore: remove all sora dead code and fork-specific sora_client_enabled · d67ecf89
      erio authored
      Upstream removed sora feature (090_drop_sora.sql) but left i18n keys
      and wire.go references. Clean up:
      - Remove entire sora i18n block from en.ts and zh.ts (~190 lines)
      - Remove sora nav key and unused 'data' settings tab key
      - Remove sora_client_enabled from settings (fork-specific)
      - Remove SoraMediaCleanupService from wire.go
      d67ecf89
    • erio's avatar
      fix(payment): propagate reason/metadata in API error responses · faee59ee
      erio authored
      The API client's error interceptor was dropping the reason and metadata
      fields from backend error responses. This caused PaymentView to miss
      specific error codes (TOO_MANY_PENDING, CANCEL_RATE_LIMITED) and fall
      back to generic error messages.
      faee59ee
    • erio's avatar
      fix(payment): pass expires_at for Stripe countdown timer · a020fc52
      erio authored
      Stripe payment path was setting expiresAt to empty string, causing
      PaymentStatusPanel to fall back to hardcoded 30-minute default when
      the popup redirect switches to the waiting view.
      a020fc52
    • erio's avatar
      feat(payment): add H5/mobile payment support · 75155903
      erio authored
      Backend:
      - Parse EasyPay `payurl2` field, prefer H5 link on mobile
      - Add `device=mobile` to EasyPay submit.php (popup) mode
      - Expand isMobile detection keywords (add ipad/ipod)
      
      Frontend:
      - Add `isMobileDevice()` utility (userAgentData + UA regex)
      - Mobile + pay_url: direct redirect instead of QR/popup
      - Popup blocked fallback: auto-redirect when window.open fails
      - Stripe WeChat Pay: dynamic client param (mobile_web vs web)
      75155903
    • erio's avatar
      refactor(payment): code standards fixes and regression repairs · e3a000e0
      erio authored
      Backend:
      - Split payment_order.go (546→314 lines) into payment_order_lifecycle.go
      - Replace magic strings with constants in factory, easypay, webhook handler
      - Add rate limit/validity unit constants in payment_order_lifecycle, payment_service
      - Fix critical regression: add PaymentEnabled to GetPublicSettings response
      - Add missing migration 099_fix_migrated_purchase_menu_label_icon.sql
      
      Frontend:
      - Fix StripePopupView.vue: replace `as any` with typed interface, use extractApiErrorMessage
      - Fix AdminOrderTable.vue: replace hardcoded column labels with i18n t() calls
      - Fix SubscriptionsView.vue: replace hardcoded Today/Tomorrow with i18n
      - Extract duplicate statusBadgeClass/canRefund/formatOrderDateTime to orderUtils.ts
      - Add missing i18n keys: common.today, common.tomorrow, payment.orders.orderType/actions
      - Remove dead PurchaseSubscriptionView.vue (replaced by PaymentView)
      e3a000e0
    • erio's avatar
      fix(payment): remove purchase_subscription fields replaced by payment system · 27cd2f8e
      erio authored
      The built-in payment system replaces the old external purchase subscription
      iframe approach. Remove purchase_subscription_enabled/url from admin settings
      interface and form defaults, as the Payment tab now handles this functionality.
      Kept in stores/app.ts fallback to match backend DTO response structure.
      27cd2f8e
    • erio's avatar
      fix(payment): resolve PR audit issues · e1547d78
      erio authored
      - Add payment navigation to AppSidebar (user orders + admin payment menu group with collapse)
      - Add 5 missing nav i18n keys (myOrders, orderManagement, paymentDashboard, paymentConfig, paymentPlans)
      - Renumber payment migrations 090-100 → 092-102 to avoid conflict with upstream 090/091
      - Remove non-payment sora_client_enabled change, restore upstream purchase_subscription fields
      - Remove extra 'data' from SettingsTab type union
      e1547d78
    • erio's avatar
      feat(payment): add complete payment system with multi-provider support · 63d1860d
      erio authored
      Add a full payment and subscription system supporting EasyPay (Alipay/WeChat),
      Stripe, and direct Alipay/WeChat Pay providers with multi-instance load balancing.
      63d1860d
  5. 10 Apr, 2026 2 commits
  6. 09 Apr, 2026 9 commits