Skip to content

Conversation

@Maphikza
Copy link
Member

API Migration and Personal Mode Enhancement

🎯 Summary

This PR migrates the allowed users system to use the new unified backend API endpoints and introduces a new
"Personal Mode" for single-user private relays. It also improves mode labels for better user clarity.

🔧 API Migration Changes

Endpoint Updates

  • GET: ~/api/settings/allowed_users~/api/settings
  • POST: ~/api/settings/allowed_users~/api/settings

Data Structure Changes

  • Response parsing: Updated to extract from data.settings.allowed_users
  • Request format: Updated to send nested settings.allowed_users structure
  • Backward compatibility: Maintains existing UI/UX while adapting to new API

Error Handling

  • ✅ Added fallback for missing tiers data using defaults
  • ✅ Improved error handling for missing response data
  • ✅ Fixed TypeScript errors with proper type casting

🆕 New Personal Mode

"Free - Only Me" Mode

  • 🎯 Purpose: Perfect for single-user private relays
  • 💾 Data Limit: Unlimited access
  • 💰 Pricing: Free (no cost)
  • 🔐 Access: Requires NPUB management (invite-only for self)
  • 🎨 UI: Orange theme color for visual distinction

Configuration

personal: {
  readOptions: [{ value: 'allowed_users', label: 'Only Me' }],
  writeOptions: [{ value: 'allowed_users', label: 'Only Me' }],
  allowsFreeTiers: true,
  requiresNpubManagement: true
}

🏷️ Improved Mode Labels

Enhanced clarity for all relay modes:

| Old Label      | New Label                 | Use Case                               |
|----------------|---------------------------|----------------------------------------|
| Free Mode      | Free - Public Relay       | Open access with optional tiers        |
| Paid Mode      | Paid - Subscription Tiers | Subscription-based access control      |
| Exclusive Mode | Free - Invite Only        | Manual NPUB management, multiple users |
|  NEW          | Free - Only Me            | Single user personal relay             |

🔍 Technical Details

Files Modified

- src/api/allowedUsers.api.ts - API endpoint migration and personal mode support
- src/types/allowedUsers.types.ts - Added personal mode types and configurations
- src/components/allowed-users/components/ModeSelector/ModeSelector.tsx - Updated UI labels

Type Safety

-  Added proper TypeScript type casting
-  Extended AllowedUsersMode type union
-  Updated all mode configuration records

API Logic

-  Personal mode handles tier filtering like free mode (active tier only)
-  Proper reconstruction of tier data for UI display
-  Maintains existing behavior for all other modes

🧪 Testing

Backend Compatibility

-  Works with new unified /api/settings endpoint
-  Handles nested response structure correctly
-  Sends data in expected nested format

Frontend Functionality

-  All existing modes work as before
-  New personal mode integrates seamlessly
-  Mode switching works correctly
-  Tier management functions properly

🚀 Deployment Notes

Prerequisites

- Backend must support unified /api/settings endpoint
- Backend must accept nested settings.allowed_users structure
- Backend should return settings.allowed_users in responses

Backward Compatibility

-  No breaking changes to existing functionality
-  Graceful fallbacks for missing data
-  Maintains all existing UI/UX patterns

📋 Checklist

- API endpoints updated to unified structure
- Response parsing handles nested data correctly
- Request format updated for new backend structure
- TypeScript errors resolved
- Personal mode fully implemented
- Mode labels improved for clarity
- All existing functionality preserved
- Error handling improved
- Code committed and pushed to feature branch

---
Ready for review and testing! 🎉

Maphikza added 13 commits June 18, 2025 14:01
- Implement free, paid, and exclusive modes with distinct tier configurations
- Add mode-specific default tiers (free: 100MB-1GB, paid: 1-10GB with pricing, exclusive: 2-25GB)
- Create comprehensive allowed users page with permissions and tier management
- Add API integration for allowed users settings and NPUB management
- Implement tier validation and automatic price handling per mode
- Add navigation and routing for allowed users functionality
- Apply dark background (#25284B) with light text (#d9d9d9) for better readability
- Maintain visual consistency across all alert components
- Improve contrast and accessibility for notification messages
- Replace separate read/write tabs with single unified table
- Add read/write access toggle switches for instant permission management
- Enhance add user modal with permission selection toggles
- Improve bulk import to support permission flags (r/w/rw)
- Update export format to include permission information
- Streamline user experience - manage all permissions from one view
- Add 'All Users' option to exclusive mode write access for more flexibility
- Create custom styled switches with better visibility in off state
- Use dark gray background (#434343) for unchecked switches instead of faded appearance
- Add proper styling for loading and disabled switch states
- Improve user experience in both table view and modal forms
- Maintain excellent appearance of checked/on state while making off state clearly visible
…system

- Remove SubscriptionTiersManager and SubscriptionSection components
- Clean up relay settings layouts to remove subscription props
- Update allowed users API to handle free mode tier selection
- Improve NPubManagement component with better error handling
- Enhance TiersConfig with radio button selection for free mode
- Clean up relay settings types and hooks
Update relay count endpoint from /api/relaycount to /api/relay/count
and remove commented code.
- Migrate useRelaySettings and useChartData hooks to new backend API structure
- Add core kinds protection system to prevent removal of essential event types
- Implement file size limit controls for photos, videos, and audio
- Add FileSizeLimitInput component with proper theme integration
- Update MediaSection to include configurable file size inputs
- Create transformation functions for new backend settings format
- Support dynamic media types and chart data from backend configuration
- Add TypeScript interfaces for new API structure
- Redesign FileSizeLimitInput with compact horizontal layout
- Move file size controls to bottom of each media section for better UX flow
- Reduce component footprint with smaller margins and inline design
- Fix theme integration using CSS variables instead of props.theme
- Remove unused description prop and simplify component interface
- Improve visual hierarchy: toggle → formats → size limits
- Update RelayInfoSettings.tsx to use tags mode for custom NIP support
- Add number conversion logic to ensure NIPs are sent as numbers to backend
- Enhance useGenericSettings.ts with comprehensive field mapping for all groups
- Remove query_cache from settings types as it's no longer used
- Fix image moderation and wallet settings to use prefixed fields directly
- Add comprehensive field mapping for wallet, general, and image moderation settings
- Remove query cache panel from advanced settings layout
- Update general settings to read from both server and relay sections
- Ensure proper bidirectional field mapping for all settings groups
- Delete NestFeederSettings.tsx and QueryCacheSettings.tsx files
- Remove nest feeder and query cache from SettingsPage.tsx navigation
- Remove from SettingsNavigation.tsx tabs array
- Remove nest feeder logic from useGenericSettings.ts hook
- Remove from settings type definitions
- Clean up unused imports (DatabaseOutlined, ApiOutlined)
- Update advanced settings layout to exclude removed components
- Remove NestFeederPanel.tsx and QueryCachePanel.tsx to fix TypeScript errors
- Fix relay info pubkey mapping to use 'public_key' from backend
- Update reverse mapping for saving relay pubkey correctly
- Remove default empty value for pubkey since it exists in backend
- Fix TypeScript error in allowedUsers.api.ts with proper type casting
- Update API endpoints to use unified /api/settings endpoint
- Update response parsing for new nested settings.allowed_users structure
- Update request format to send data in settings.allowed_users structure
- Add new 'personal' mode for single-user private relays
- Update mode labels for better clarity:
  * free -> 'Free - Public Relay'
  * paid -> 'Paid - Subscription Tiers'
  * exclusive -> 'Free - Invite Only'
  * personal -> 'Free - Only Me' (NEW)
- Add personal mode configuration with unlimited access and NPUB management
- Update API logic to handle personal mode like free mode for tier filtering
Maphikza added 4 commits June 24, 2025 11:24
- Update useRelaySettings.ts to send correct field names (mime_patterns, max_size_mb)
- Add backward compatibility for reading both old and new field names
- Add comprehensive logging to useChartData.ts to debug media count issues
- Ensure media definitions are always sent with complete structure to avoid backend conflicts
- Add tierConversion utility with MB/GB/TB conversion and validation
- Create TierEditor component with number input + unit dropdown
- Update AllowedUsersTier to use price_sats and monthly_limit_bytes
- Migrate DEFAULT_TIERS to new format with proper byte values
- Update API layer to send/receive new backend format
- Fix all TypeScript errors in tier management components
- Add validation for 1MB-1TB range and unlimited tiers
- Maintain backward compatibility during transition

Backend format: {name, price_sats, monthly_limit_bytes, unlimited}
Frontend UI: User-friendly number + unit selection with real-time validation
- Change from horizontal layout to 2x2 grid for better visual organization
- Update button labels and order to match design: Only Me, Invite Only, Public Relay, Subscription
- Increase button height to 80px to properly accommodate two-line text
- Add proper flexbox layout to prevent text overlapping
- Improve typography with larger main labels and smaller subtitle text
- Maintain existing colors and functionality while improving layout

Layout: Top row (Only Me, Invite Only), Bottom row (Public Relay, Subscription)
…oding

- Add working View All button functionality with modal display
- Implement horizontal list layout for better scrolling through many subscribers
- Use proper nostr-tools nip19.npubEncode() for correct npub format display
- Add fallback to original hex format if encoding fails
- Improve visual design with larger avatars, better shadows, and modern card styling
- Remove loading spinner that was blocking content display
- Enhance hover effects and typography for better user experience

Each subscriber now displays with avatar, name, and properly formatted npub/hex
@f7f376a1fcd0d0e11a10ed1b6577c9 f7f376a1fcd0d0e11a10ed1b6577c9 merged commit bdc4c08 into main Jun 24, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants