sojorn/sojorn_docs/troubleshooting/test_image_upload_2025-01-05.md
Patrick Britton 38653f5854 Sojorn Backend Finalization & Cleanup - Complete Migration from Supabase
##  Phase 1: Critical Feature Completion (Beacon Voting)
- Add VouchBeacon, ReportBeacon, RemoveBeaconVote methods to PostRepository
- Implement beacon voting HTTP handlers with confidence score calculations
- Register new beacon routes: /beacons/:id/vouch, /beacons/:id/report, /beacons/:id/vouch (DELETE)
- Auto-flag beacons at 5+ reports, confidence scoring (0.5 base + 0.1 per vouch)

##  Phase 2: Feed Logic & Post Distribution Integrity
- Verify unified feed logic supports all content types (Standard, Quips, Beacons)
- Ensure proper distribution: Profile Feed + Main/Home Feed for followers
- Beacon Map integration for location-based content
- Video content filtering for Quips feed

##  Phase 3: The Notification System
- Create comprehensive NotificationService with FCM integration
- Add CreateNotification method to NotificationRepository
- Implement smart deep linking: beacon_map, quip_feed, main_feed
- Trigger notifications for beacon interactions and cross-post comments
- Push notification logic with proper content type detection

##  Phase 4: The Great Supabase Purge
- Delete function_proxy.go and remove /functions/:name route
- Remove SupabaseURL, SupabaseKey from config.go
- Remove SupabaseID field from User model
- Clean all Supabase imports and dependencies
- Sanitize codebase of legacy Supabase references

##  Phase 5: Flutter Frontend Integration
- Implement vouchBeacon(), reportBeacon(), removeBeaconVote() in ApiService
- Replace TODO delay in video_comments_sheet.dart with actual publishComment call
- Fix compilation errors (named parameters, orphaned child properties)
- Complete frontend integration with Go API endpoints

##  Additional Improvements
- Fix compilation errors in threaded_comment_widget.dart (orphaned child property)
- Update video_comments_sheet.dart to use proper named parameters
- Comprehensive error handling and validation
- Production-ready notification system with deep linking

##  Migration Status: 100% Complete
- Backend: Fully migrated from Supabase to custom Go/Gin API
- Frontend: Integrated with new Go endpoints
- Notifications: Complete FCM integration with smart routing
- Database: Clean of all Supabase dependencies
- Features: All functionality preserved and enhanced

Ready for VPS deployment and production testing!
2026-01-30 09:24:31 -06:00

3.4 KiB

Test Image Upload - Quick Verification

Current Configuration

  • R2 Bucket: sojorn-media
  • Account ID: 7041ca6e0f40307190dc2e65e2fb5e0f
  • Custom Domain: media.gosojorn.com
  • Upload URL: https://7041ca6e0f40307190dc2e65e2fb5e0f.r2.cloudflarestorage.com/sojorn-media
  • Public URL: https://media.gosojorn.com

Quick Test

1. Verify Custom Domain is Connected

Go to: https://dash.cloudflare.com → R2 → sojorn-media bucket → Settings

Under "Custom Domains", you should see:

  • media.gosojorn.com with status "Active"

If not connected:

  1. Click "Connect Domain"
  2. Enter: media.gosojorn.com
  3. Wait 1-2 minutes for activation

2. Test Upload in App

With the app running:

  1. Tap compose button
  2. Select an image
  3. Add some text
  4. Post

Watch for:

  • Success notification
  • Image appears in feed
  • No error messages

3. Check What URL Was Generated

After uploading, check the database:

SELECT id, body, image_url, created_at
FROM posts
WHERE image_url IS NOT NULL
ORDER BY created_at DESC
LIMIT 1;

Expected URL format: https://media.gosojorn.com/[uuid].[ext]

4. Test URL Directly

Copy the image_url from database and test in browser or curl:

curl -I https://media.gosojorn.com/[filename-from-database]

Expected response: HTTP/2 200 OK

Troubleshooting

Edge Function Logs

Check for upload errors:

npx supabase functions logs upload-image --project-ref zwkihedetedlatyvplyz -f

Look for:

  • "Successfully uploaded to R2"
  • "Missing R2_PUBLIC_URL" (means secret not set)
  • "R2 upload failed" (means authentication/permission issue)

Environment Variables

Verify all secrets are set:

npx supabase secrets list --project-ref zwkihedetedlatyvplyz

Required secrets:

  • R2_ACCOUNT_ID
  • R2_ACCESS_KEY
  • R2_SECRET_KEY
  • R2_PUBLIC_URL

Common Issues

Issue Cause Solution
Upload fails with 401 Invalid R2 credentials Check R2_ACCESS_KEY and R2_SECRET_KEY
Upload succeeds but image 404 Domain not connected Connect media.gosojorn.com to bucket
"Missing R2_PUBLIC_URL" Secret not set/propagated Wait 2 minutes, redeploy function
Image loads slowly Not cached Normal for first load, subsequent loads cached

Expected Behavior

Upload Flow:

  1. User selects image → App processes/filters
  2. App uploads to edge function → Edge function uploads to R2
  3. Edge function returns: https://media.gosojorn.com/[uuid].jpg
  4. App saves post with image_url to database
  5. Feed queries posts with image_url
  6. PostItem widget displays image

Performance:

  • First upload: 2-5 seconds (depending on image size)
  • Image load: <1 second (Cloudflare CDN)
  • Subsequent loads: Instant (cached)

Next Steps After Success

Once working:

  1. Upload multiple images to test different sizes/formats
  2. Test filters (grayscale, sepia, etc.)
  3. Verify images show in all views (feed, profile, chains)
  4. Check image quality and compression
  5. Test on different devices/networks

If Still Not Working

Share the following information:

  1. Edge function logs (last 10 lines)
  2. App console output (any errors)
  3. Database query result (image_url value)
  4. Cloudflare R2 bucket settings screenshot
  5. Whether domain shows "Active" in R2 settings

Everything is configured - ready to test now! 🚀