Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - Recipe actions link to homepage for private recipes #4619

Open
6 tasks done
ianp1 opened this issue Nov 27, 2024 · 5 comments · May be fixed by #4676
Open
6 tasks done

[BUG] - Recipe actions link to homepage for private recipes #4619

ianp1 opened this issue Nov 27, 2024 · 5 comments · May be fixed by #4676
Labels
bug: confirmed bug Something isn't working

Comments

@ianp1
Copy link

ianp1 commented Nov 27, 2024

First Check

  • This is not a feature request.
  • I added a very descriptive title to this issue (title field is above this).
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the Mealie documentation, with the integrated search.
  • I already read the docs and didn't find an answer.
  • This issue can be replicated on the demo site (https://demo.mealie.io/).

What is the issue you are experiencing?

When using a recipe action on a recipe that is not publicly shared, the resolution of that action fails (example: bring! api).

When checking the URL that mealie provides for placeholder ${url}, it is using the public link (for example https://demo.mealie.io/g/home/r/recipe-name ), which does only point to the recipe when logged in. Therefore, the API fails to perform the recipe action.

IMO the recipe action should automatically create a short lived share link for this case.

Steps to Reproduce

  1. Create a private recipe
  2. Create a recipe action (e.g. https://api.getbring.com/rest/bringrecipes/deeplink?url=${url}&source=web)
  3. Perform recipe action on private recipe

Please provide relevant logs

No relevant logs

Mealie Version

Docker v2.3.0

Deployment

Docker (Linux)

Additional Deployment Details

No response

@michael-genson
Copy link
Collaborator

the recipe action should automatically create a short lived share link

I love this idea

@ianp1
Copy link
Author

ianp1 commented Nov 28, 2024

If my idea sounds reasonable, I might have a look at it myself. Do you have a quick pointer on where to start with this?

@michael-genson
Copy link
Collaborator

Mostly will be in here:

function parseRecipeActionUrl(url: string, recipe: Recipe): string {
/* eslint-disable no-template-curly-in-string */
return url
.replace("${url}", window.location.href)
.replace("${id}", recipe.id || "")
.replace("${slug}", recipe.slug || "")
/* eslint-enable no-template-curly-in-string */
};

You'll probably want to add a merge field like ${temporary-url} or ${private-url-expires-1732852870} (where 1732852870 is a UNIX timestamp). Then you'll need to generate a temporary URL via the API: https://github.com/mealie-recipes/mealie/blob/mealie-next/frontend/lib/api/user/recipes/recipe-share.ts

@ianp1
Copy link
Author

ianp1 commented Nov 29, 2024

I like the idea of making the private url expiration configurable, but a unix-timestamp seems impractical. To actually use it, you would need to adjust the recipe action url often. IMO a field like ${private-url-expires-in-60} to expire in 60 seconds would be more useful, wouldn´t it?

@michael-genson
Copy link
Collaborator

Yup that makes sense. Just spitballing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: confirmed bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants