fix: Add /feed/personal route + lazy neighborhood group creation

- Add GET /feed/personal alias for /feed (Flutter uses this endpoint)
- Fix 'Neighborhood unavailable' board bug: GetMyNeighborhood now
  creates the neighborhood group lazily if group_id is NULL in the seed,
  matching the same auto-create logic as the Detect endpoint

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Patrick Britton 2026-02-17 18:06:46 -06:00
parent 0753fd91e6
commit d26e63ca1b
2 changed files with 22 additions and 0 deletions

View file

@ -350,6 +350,7 @@ func main() {
authorized.POST("/posts/:id/reactions/toggle", postHandler.ToggleReaction)
authorized.POST("/posts/:id/comments", postHandler.CreateComment)
authorized.GET("/feed", postHandler.GetFeed)
authorized.GET("/feed/personal", postHandler.GetFeed)
authorized.POST("/beacons", postHandler.CreateBeacon)
authorized.GET("/beacons/nearby", postHandler.GetNearbyBeacons)
authorized.POST("/beacons/:id/vouch", postHandler.VouchBeacon)

View file

@ -617,6 +617,27 @@ func (h *NeighborhoodHandler) GetMyNeighborhood(c *gin.Context) {
},
}
// If the seed has no group yet, create one now (lazy creation)
if groupID == nil {
seed := &seedRow{
ID: seedID,
Name: name,
City: city,
State: state,
ZipCode: zipCode,
Country: country,
Lat: lat,
Lng: lng,
RadiusMeters: radiusMeters,
}
newGroupID, createErr := h.createNeighborhoodGroup(ctx, seed)
if createErr != nil {
log.Printf("[Neighborhood] GetMyNeighborhood lazy group creation error: %v", createErr)
} else {
groupID = &newGroupID
}
}
if groupID != nil {
var groupName string
var memberCount int