Coffee journaling on ATProto (alpha) alpha.arabica.social
coffee
17
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: gate profile pages to Arabica users only

Non-Arabica users (no feed registration and no Arabica records) now
get a 404 page instead of a full profile. Applies to both the full
page and the HTMX partial endpoint.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+44 -2
+26
internal/handlers/handlers.go
··· 1945 1945 userProfile = h.getUserProfile(ctx, didStr) 1946 1946 } 1947 1947 1948 + // Check if this is an Arabica user (has records or is registered in feed) 1949 + isArabicaUser := h.feedRegistry.IsRegistered(did) || 1950 + len(profileData.Brews) > 0 || len(profileData.Beans) > 0 || 1951 + len(profileData.Roasters) > 0 || len(profileData.Grinders) > 0 || 1952 + len(profileData.Brewers) > 0 1953 + 1954 + if !isArabicaUser { 1955 + layoutData := h.buildLayoutData(r, "Profile Not Found", isAuthenticated, didStr, userProfile) 1956 + w.WriteHeader(http.StatusNotFound) 1957 + if err := pages.ProfileNotFound(layoutData).Render(r.Context(), w); err != nil { 1958 + log.Error().Err(err).Msg("Failed to render profile not found page") 1959 + } 1960 + return 1961 + } 1962 + 1948 1963 // Check if the viewing user is the profile owner 1949 1964 isOwnProfile := isAuthenticated && didStr == did 1950 1965 ··· 2022 2037 if err != nil { 2023 2038 log.Error().Err(err).Str("did", did).Msg("Failed to fetch user data for profile partial") 2024 2039 http.Error(w, "Failed to load profile data", http.StatusInternalServerError) 2040 + return 2041 + } 2042 + 2043 + // Check if this is an Arabica user (has records or is registered in feed) 2044 + isArabicaUser := h.feedRegistry.IsRegistered(did) || 2045 + len(profileData.Brews) > 0 || len(profileData.Beans) > 0 || 2046 + len(profileData.Roasters) > 0 || len(profileData.Grinders) > 0 || 2047 + len(profileData.Brewers) > 0 2048 + 2049 + if !isArabicaUser { 2050 + http.Error(w, "User not found", http.StatusNotFound) 2025 2051 return 2026 2052 } 2027 2053
-2
internal/web/pages/notfound.templ
··· 2 2 3 3 import "arabica/internal/web/components" 4 4 5 - // NotFound renders the 404 page 6 5 templ NotFound(layout *components.LayoutData) { 7 6 @components.Layout(layout, NotFoundContent()) 8 7 } 9 8 10 - // NotFoundContent renders the 404 content 11 9 templ NotFoundContent() { 12 10 <div class="page-container-lg"> 13 11 <div class="card p-8 text-center">
+18
internal/web/pages/profile.templ
··· 272 272 </div> 273 273 } 274 274 275 + // ProfileNotFound renders a 404 page for non-Arabica users 276 + templ ProfileNotFound(layout *components.LayoutData) { 277 + @components.Layout(layout, profileNotFoundContent()) 278 + } 279 + 280 + templ profileNotFoundContent() { 281 + <div class="page-container-lg"> 282 + <div class="card p-8 text-center"> 283 + <div class="text-6xl mb-4 font-bold text-brown-800">404</div> 284 + <h2 class="text-2xl font-bold text-brown-900 mb-4">Page Not Found</h2> 285 + <p class="text-brown-700 mb-6">This profile doesn't exist on Arabica</p> 286 + <a href="/" class="btn-primary py-3 px-6 shadow-lg hover:shadow-xl"> 287 + Back to Home 288 + </a> 289 + </div> 290 + </div> 291 + } 292 + 275 293 // ProfileModals renders entity form modals for own profile 276 294 templ ProfileModals(roasters []RoasterOption) { 277 295 @BeanFormModalProfile(roasters)