Improve recipe listing - check both uploader and owner
- Add better debug logging for recipe filtering - Check both uploader and owner fields when filtering by actor_id - This handles S-expression recipes that use 'owner' field Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -127,15 +127,19 @@ class RecipeService:
|
|||||||
# Check if cache has a list method for recipes
|
# Check if cache has a list method for recipes
|
||||||
if hasattr(self.cache, 'list_by_type'):
|
if hasattr(self.cache, 'list_by_type'):
|
||||||
items = self.cache.list_by_type('recipe')
|
items = self.cache.list_by_type('recipe')
|
||||||
logger.info(f"Found {len(items)} recipe items in cache")
|
logger.info(f"Found {len(items)} recipe items in cache for actor_id={actor_id}")
|
||||||
for content_hash in items:
|
for content_hash in items:
|
||||||
recipe = await self.get_recipe(content_hash)
|
recipe = await self.get_recipe(content_hash)
|
||||||
if recipe:
|
if recipe:
|
||||||
uploader = recipe.get("uploader")
|
uploader = recipe.get("uploader")
|
||||||
logger.info(f"Recipe {content_hash[:12]}: uploader={uploader}, actor_id={actor_id}")
|
owner = recipe.get("owner")
|
||||||
|
logger.info(f"Recipe {content_hash[:12]}: name={recipe.get('name')}, uploader={uploader}, owner={owner}, actor_id={actor_id}")
|
||||||
# Filter by actor - L1 is per-user
|
# Filter by actor - L1 is per-user
|
||||||
if actor_id is None or uploader == actor_id:
|
# Check both uploader and owner fields for flexibility
|
||||||
|
if actor_id is None or uploader == actor_id or owner == actor_id:
|
||||||
recipes.append(recipe)
|
recipes.append(recipe)
|
||||||
|
else:
|
||||||
|
logger.warning("Cache does not have list_by_type method")
|
||||||
|
|
||||||
# Sort by name
|
# Sort by name
|
||||||
recipes.sort(key=lambda r: r.get("name", ""))
|
recipes.sort(key=lambda r: r.get("name", ""))
|
||||||
|
|||||||
Reference in New Issue
Block a user